Repository navigation
fix(go): decode TOOL_CALL_CHUNK, thinking and subagent events in the events package - #3180
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
…events package EventFromJSON had no case for TOOL_CALL_CHUNK or the five THINKING_* events and rejected them as "unknown event type", although validEventTypes accepts them. EventDecoder.DecodeEvent had no case for TOOL_CALL_CHUNK or the three SUBAGENT_* events and returned them as a *RawEvent, so a consumer switching on the concrete type silently dropped them. Add the missing cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Looks good as-is. A few optional regression tests would strengthen the coverage:
I wouldn’t block this PR on those tests. We’ll wait to hear back from you before merging. |
@ag-ui/a2a-middleware
@ag-ui/a2ui-middleware
@ag-ui/event-throttle-middleware
@ag-ui/mcp-apps-middleware
@ag-ui/mcp-middleware
@ag-ui/a2a
@ag-ui/adk-js
@ag-ui/adk
@ag-ui/ag2
@ag-ui/agno
@ag-ui/antigravity
@ag-ui/aws-strands
@ag-ui/claude-agent-sdk
@ag-ui/claude-managed-agents
@ag-ui/crewai
@ag-ui/langchain
@ag-ui/langgraph
@ag-ui/llamaindex
@ag-ui/mastra
@ag-ui/pydantic-ai
@ag-ui/vercel-ai-sdk
@ag-ui/watsonx
@ag-ui/a2ui-toolkit
create-ag-ui-app
@ag-ui/client
@ag-ui/core
@ag-ui/encoder
@ag-ui/proto
commit: |
This branch has not been deployed
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.
What's wrong
pkg/core/eventshas two decoders, and neither covers every type invalidEventTypes:EventFromJSON(events.go) has no case forTOOL_CALL_CHUNKor the five deprecatedTHINKING_*events, so it returnsunknown event type: TOOL_CALL_CHUNK.TOOL_CALL_CHUNKis a normal protocol event (spec/1.0/fixtures/ToolCallChunkEvent/valid/minimal.json). The Go SDK has aToolCallChunkEventstruct and aNewToolCallChunkEventconstructor, and its ownValidateaccepts the type.EventDecoder.DecodeEvent(decoder.go) has no case forTOOL_CALL_CHUNK,SUBAGENT_STARTED,SUBAGENT_FINISHEDorSUBAGENT_ERROR. These fall through todefaultand come back as a*RawEventthat wraps the payload. If a consumer switches on*ToolCallChunkEventor*SubagentStartedEvent, those events never reach that branch, and nothing reports an error. The example client (example/client/internal/event/parse.go) decodes through this function.The fix
The missing cases are added to both switches. Each one uses the struct the package already defines.
Test
pkg/core/events/decoder_coverage_test.goloops overvalidEventTypes. For each type it checks two things:EventFromJSONreturns an event of that type.DecodeEventdoesn't fall back to*RawEvent, except forRAWitself.Because it walks the map, the test also catches the next event type that gets added to the map without a decoder case.
On
mainthe test fails with 10 errors: 6EventFromJSON ... unknown event typeand 4DecodeEvent ... fell back to *RawEvent. It passes with the fix. Mutation check: I reverted onlyevents.goanddecoder.go, and the named test failed with the same 10 errors.Checks
cd sdks/community/go && go test ./... -v: all packages ok, 126 top-level tests passed.gofmtis clean for the added lines.events.gohas formatting differences that predate this change, and they aren't touched here.🤖 Generated with Claude Code