This repository was archived by the owner on Aug 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
feat(agent): echo initiating message_id on relay_message #3434
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -989,9 +989,11 @@ export class AgentServer { | |
|
|
||
| if (result.stopReason === "end_turn") { | ||
| // Relay the response to Slack. For follow-ups this is the primary | ||
| // delivery path — the HTTP caller only handles reactions. | ||
| this.relayAgentResponse(this.session.payload).catch((err) => | ||
| this.logger.debug("Failed to relay follow-up response", err), | ||
| // delivery path — the HTTP caller only handles reactions. Echo the | ||
| // initiating message's id so the backend can attribute the answer. | ||
| this.relayAgentResponse(this.session.payload, messageId).catch( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A caller with a valid token for a multiplayer run can submit another participant's message ID because the request body value is forwarded without checking its owner. If the relay endpoint uses that ID directly for attribution, the answer is attached to the wrong sender; validate that the ID belongs to the authenticated user and current task/run before forwarding it. Rule Used: When implementing new features, ensure that owners... (source) Learned From |
||
| (err) => | ||
| this.logger.debug("Failed to relay follow-up response", err), | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -3635,7 +3637,10 @@ ${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions} | |
| }; | ||
| } | ||
|
|
||
| private async relayAgentResponse(payload: JwtPayload): Promise<void> { | ||
| private async relayAgentResponse( | ||
| payload: JwtPayload, | ||
| messageId?: string, | ||
| ): Promise<void> { | ||
| if (!this.session) { | ||
| return; | ||
| } | ||
|
|
@@ -3679,6 +3684,7 @@ ${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions} | |
| payload.run_id, | ||
| message, | ||
| messageParts, | ||
| messageId, | ||
| ); | ||
| } catch (error) { | ||
| this.logger.debug("Failed to relay initial agent response to Slack", { | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When another command starts before this unawaited relay finishes flushing, that turn resets and repopulates the session-wide response buffer. The first relay can then read the later turn's text while retaining the first turn's
messageId, causing the backend to attribute the wrong answer to a participant. Capture the completed response with the ID before another turn can mutate the buffer, or serialize relay completion with turn processing.