Repository navigation
Opt-in outbound history append endpoint (hardened version of #10) - #11
Merged
Merged
Conversation
- Gate /history/outgoing behind MAWS_HISTORY_APPEND_ENABLED (default off) in the runtime and behind history_append.enabled in bootstrap, so bots that do not opt in keep byte-identical request/worker paths and SAM templates. - Never drop an append because the user lock is busy: wait for the lock, then raise so Lambda async retries or SQS try again (the caller already got a 202). Webhook jobs keep the existing drop behavior. - Attribute appended messages to the answering agent (MAWS_HISTORY_APPEND_ROLE, bot component_name, or the only agent) with msg_type "agent", so MAS shows them as the agent's own turn and name/type filters include them. - Return 502 instead of raising when the FIFO enqueue fails. - Document the opt-in, chat_id/event_id guidance and shared-history caveat. - Add tests for disabled isolation, stale timestamps, FIFO, lock waits and retries, author resolution, and a real-manager conversation check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #10 by @jmcafferata (its commit is included unchanged) and hardens it before merging.
What it adds
POST /history/outgoinglets a service that sends WhatsApp/Telegram messages outside the bot (bulk templates, reminders, auto-replies) record them in the user's MAWS history, so the agent has that context when the user answers. Requests are authenticated with a timestamped HMAC-SHA256 (MAWS_HISTORY_WRITE_SECRET) and deduplicated byevent_id.Changes on top of #10
append_historyjobs whenMAWS_HISTORY_APPEND_ENABLED=true; bootstrap only deploys the route whenhistory_append.enabledis set inparams.json. Previously the route was added to every generated template.busy_policy=drop, a busy user lock used to silently discard the append after the caller got a 202. Appends now wait for the lock (MAWS_HISTORY_APPEND_LOCK_WAIT_SECONDS, default 60) and otherwise raise so Lambda async retries / SQS retry. Webhook jobs keep the existing drop behavior.history_append.role/MAWS_HISTORY_APPEND_ROLE, the bot'scomponent_name, or the only agent) withmsg_type="agent", instead ofrole="assistant", which MAS showed as a user turn and which agents withpositive_filterskipped.chat_id/event_idguidance and the shared-history caveat.Verification
mas/is untouched; pre-existing tests are unchanged and pass (146 passed, 1 skipped; CI green on 3.9-3.12)./history/outgoingwith only the secret set) through main's and this branch's runtime with the feature off: identical responses and side effects. A control run with the feature on differs only in the 5 endpoint scenarios.AgentSystemManagerconversation check.🤖 Generated with Claude Code