feat(agent): echo initiating message_id on relay_message#3434
Draft
VojtechBartos wants to merge 1 commit into
Draft
feat(agent): echo initiating message_id on relay_message#3434VojtechBartos wants to merge 1 commit into
VojtechBartos wants to merge 1 commit into
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Pass the id of the user_message command that initiated a turn from the handler closure to relayAgentResponse and include it as an optional message_id field in the relay_message POST body. Each turn's relay carries its own initiating message's id; the field is omitted when no id is known (e.g. the boot prompt), so older backends are unaffected.
4c745d2 to
f11ab9f
Compare
Draft
2 tasks
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.
Problem
When a turn finishes, the agent-server relays the final answer to the backend's
relay_messageendpoint with onlytext/text_parts. The relay carries no correlation to the user message it answers, so the backend has to guess who to @-mention in Slack from mutable state, which mis-tags replies in multiplayer threads.Changes
messageIdof theuser_messagecommand that initiated the turn (the same id already used for duplicate-delivery suppression) as an optionalmessage_idfield in therelay_messagePOST body. The id is captured in the handler closure, so overlapping turns each relay their own initiating message's id.The consuming backend change (using
message_idto attribute Slack replies) lands separately in PostHog/posthog, as a follow-up to the Slack follow-up queue work (PostHog/posthog#70806, PostHog/posthog#70762).How did you test this?
/commandHTTP endpoint (including overlapping turns, the no-id case, and no id leaking from a failed turn into the next),relayAgentResponsepass-through, and therelay_messagerequest body shape.pnpm --filter @posthog/agent test— 78 files, 1295 tests passed.pnpm --filter @posthog/agent typecheckandbiome checkon touched files — clean.Automatic notifications