-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(core): preserve id/timestamp/usage when extracting generate_response result #3032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3263259
374ebc7
db5ccfb
e7040ae
5a64548
c545181
25b43f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1621,10 +1621,19 @@ private Msg extractResponseData(Msg responseMsg) { | |
| Map<String, Object> metadata = new HashMap<>(responseMsg.getMetadata()); | ||
| metadata.put(MessageMetadataKeys.STRUCTURED_OUTPUT, responseData); | ||
| metadata.remove("response"); | ||
| // Preserve the source message's identity fields, consistent with the other | ||
| // message-rebuild paths (wrapNativeStructuredResult, markRetryResidue): a fresh | ||
| // builder synthesizes a new id/timestamp and drops the usage field. | ||
| // Note: on this path mergeCollectedMetadata later overwrites the usage field with | ||
| // the call's aggregated value; the copy here is defensive, keeping the | ||
| // intermediate rebuild consistent with the other paths. | ||
| return Msg.builderForRole(responseMsg.getRole()) | ||
| .id(responseMsg.getId()) | ||
| .name(responseMsg.getName()) | ||
| .content(responseMsg.getContent()) | ||
| .metadata(metadata) | ||
| .timestamp(responseMsg.getTimestamp()) | ||
| .usage(responseMsg.getUsage()) | ||
|
Collaborator
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.
|
||
| .build(); | ||
| } | ||
| return responseMsg; | ||
|
|
||
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.
Id now flows from the tool-built
response_msginto the message appended to the session context at line 1381 (scope.state.contextMutable().add(out)), where previously the rebuild synthesized a fresh id. Please confirm no consumer keys on message id uniqueness within a single context:PostActingEvent.getToolResultMsg()(which carries the sameresponse_msg) and the structured result are now id-identical, and anything that de-dupes, reconciles replay, or maps events to messages by id (the AG-UI replay/session-state path is exactly such a consumer) can collapse the two into one.name/timestampwere already copied bymergeCollectedMetadata, soidis the only genuinely new identity being propagated here — worth one sentence in the PR description on which downstream consumers were checked.