Skip to content

fix: accept metadata-only SSE chunks instead of aborting stream in StreamingResponseAggregator#918

Merged
kdroste-google merged 3 commits into
mainfrom
fix/ph-issue-782
May 29, 2026
Merged

fix: accept metadata-only SSE chunks instead of aborting stream in StreamingResponseAggregator#918
kdroste-google merged 3 commits into
mainfrom
fix/ph-issue-782

Conversation

@kdroste-google
Copy link
Copy Markdown
Collaborator

Modified version of #783

Instead of ignoring the SSE chunks with no candidates, this version accepts them and passes them downstream to further processing (they contain usageMetadata)

anishesg and others added 3 commits May 29, 2026 12:26
…amingResponseAggregator

## Link to Issue or Description of Change

Signed-off-by: anish k <ak8686@princeton.edu>
@kdroste-google kdroste-google requested a review from wolo-lab May 29, 2026 12:45
@kdroste-google
Copy link
Copy Markdown
Collaborator Author

Manual tests:
Replace quickstart main with

func main() {
	ctx := context.Background()

	model, err := gemini.NewModel(ctx, "gemini-3.1-flash-lite", &genai.ClientConfig{
		Backend:  genai.BackendVertexAI,
		Project:  "PROJECT",
		Location: "global",
	})
	if err != nil {
		log.Fatalf("Failed to create model: %v", err)
	}

	a, err := llmagent.New(llmagent.Config{
		Name:        "weather_time_agent",
		Model:       model,
		Description: "Helpful Agent",
		Instruction: "Your purpose is to help the user by using search tool.",
		Tools: []tool.Tool{
			geminitool.GoogleSearch{},
		},
	})
	if err != nil {
		log.Fatalf("Failed to create agent: %v", err)
	}

	config := &launcher.Config{
		AgentLoader: agent.NewSingleLoader(a),
	}

	l := full.NewLauncher()
	if err = l.Execute(ctx, config, os.Args[1:]); err != nil {
		log.Fatalf("Run failed: %v\n\n%s", err, l.CommandLineSyntax())
	}
}

Execute:

echo "What are some recent movie recommendations?" | go run ./examples/quickstart/main.go  --streaming_mode sse

@kdroste-google kdroste-google linked an issue May 29, 2026 that may be closed by this pull request
@kdroste-google
Copy link
Copy Markdown
Collaborator Author

@anishesg , please be aware, basing on your PR I have created a new one (with your contributions included), solving the issue in a different way.

@kdroste-google kdroste-google merged commit 2472d61 into main May 29, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming SSE aggregator aborts on metadata-only chunks

3 participants