-
Notifications
You must be signed in to change notification settings - Fork 49
Surface inbound AG-UI CUSTOM events as metadata instead of dropping them #694
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
Changes from all commits
dc05ac8
77bed09
2bcbe82
393b5e6
76e2809
aaf250e
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 |
|---|---|---|
|
|
@@ -377,6 +377,10 @@ type pendingToolCall struct { | |
|
|
||
| type toolCallAccumulator struct { | ||
| pending map[string]*pendingToolCall | ||
| // customSeq counts emitted custom events so each one is assigned a unique | ||
| // synthetic MessageID, keeping it in its own message rather than being merged | ||
| // into (and overwriting) an unrelated assistant message when collected. | ||
| customSeq int | ||
| // lastChunkMessageID is the MessageID of the most recent | ||
| // TextMessageChunkEvent that carried one. Chunks that omit MessageID | ||
| // continue that message. | ||
|
|
@@ -510,6 +514,19 @@ func (a *toolCallAccumulator) onEvent(evt aguiEvents.Event) ([]*agent.ResponseUp | |
| CreatedAt: eventTime(evt), | ||
| Contents: message.Contents{newJSONDataContent(e.Delta, "application/json-patch+json")}, | ||
| }}, nil | ||
| case *aguiEvents.CustomEvent: | ||
| a.customSeq++ | ||
| return []*agent.ResponseUpdate{{ | ||
| Role: message.RoleAssistant, | ||
| MessageID: fmt.Sprintf("agui-custom-%d", a.customSeq), | ||
| CreatedAt: eventTime(evt), | ||
| AdditionalProperties: map[string]any{ | ||
| "agui_custom_event": map[string]any{ | ||
|
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. Parity issue — key name and payload shape diverge from the Python client The Python AG-UI client ( The Python payload also includes return ChatResponseUpdate(
role="assistant",
contents=[],
additional_properties={
"thread_id": self.thread_id,
"run_id": self.run_id,
"ag_ui_custom_event": {
"name": event.get("name"),
"value": event.get("value"),
"raw_type": raw_event_type,
},
},
)Upstream Python reference: Suggested fixes:
Member
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. PratikDhanave (@PratikDhanave) can you resolve the parity gap? |
||
| "name": e.Name, | ||
|
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. Parity issue — missing The Python Consider adding the AG-UI thread/run IDs here to keep observability parity with the Python SDK.
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. Parity gap: missing context metadata and The Python reference implementation ( additional_properties={
"thread_id": self.thread_id,
"run_id": self.run_id,
"ag_ui_custom_event": {
"name": event.get("name"),
"value": event.get("value"),
"raw_type": raw_event_type, # "CUSTOM" or "CUSTOM_EVENT"
},
}This Go implementation differs in three ways:
Suggested fix — align with the pattern used for other metadata updates: case *aguiEvents.CustomEvent:
a.customSeq++
return []*agent.ResponseUpdate{{
Role: message.RoleAssistant,
MessageID: fmt.Sprintf("agui-custom-%d", a.customSeq),
CreatedAt: eventTime(evt),
AdditionalProperties: map[string]any{
"agui_thread_id": a.threadID, // thread in from run() closure or accumulator field
"agui_run_id": a.runID,
"agui_custom_event": map[string]any{
"name": e.Name,
"value": e.Value,
},
},
}}, nil |
||
| "value": e.Value, | ||
| }, | ||
|
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. Cross-SDK parity gap: The Python implementation in
In addition, the key name itself differs: Python uses Suggested remediation:
|
||
| }, | ||
|
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. Parity gap: custom event metadata key diverges from Python upstream The Python Suggested fix: rename to |
||
| }}, nil | ||
| case *aguiEvents.MessagesSnapshotEvent: | ||
| return []*agent.ResponseUpdate{{ | ||
| Role: message.RoleAssistant, | ||
|
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. Parity gap: missing The Python upstream surfaces three additional fields alongside additional_properties={
"thread_id": self.thread_id,
"run_id": self.run_id,
"ag_ui_custom_event": {
"name": ...,
"value": ...,
"raw_type": raw_event_type, # distinguishes CUSTOM vs CUSTOM_EVENT
},
}The Go implementation omits |
||
|
|
||
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.
Parity issue — key name diverges from Python SDK
The upstream Python
_handle_custom_eventuses"ag_ui_custom_event"(with underscore afterag) as theadditional_propertieskey. This PR uses"agui_custom_event"(no underscore). Callers inspectingAdditionalPropertiescross-SDK will need different spellings.Suggested rename to
"ag_ui_custom_event"to matchmicrosoft/agent-framework→_event_converters.py.