-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Add support for output-format stream-jsonflag for headless mode #10883
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
Conversation
|
Size Change: +8.72 kB (+0.05%) Total Size: 17.8 MB
ℹ️ View Unchanged
|
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.
Excited for this feature, thanks @anj-s!
I was expecting this new mode to be an option on the existing --output-format flag. Right now, we have --output-format which accepts text and json. This new mode would be --output-format=stream-json, keeping all output-related formats under a single, consistent flag.
.option('output-format', {
type: 'string',
description: 'The output format for the response.',
choices: ['text', 'json', 'stream-json'],
})Was there a specific reason for introducing a new, separate --stream-format=output-json flag instead of extending the existing one?
Overall, this looks great - I'm happy to approve once we clarify the configuration.
…g for headless mode (google-gemini#10883)
TLDR
Adds
--output-format stream-jsonflag for non-interactive mode, enabling real-time JSONL event streaming. This allows external tools and scripts to monitor AI agent progress in real-time instead of waiting for a single JSON response at the end.Dive Deeper
Key features:
init,message,tool_use,tool_result,error,result--output-format jsonunchangedEvent sequence example:
{"type":"init","timestamp":"...","session_id":"abc123","model":"gemini-2.0-flash-exp"} {"type":"message","role":"user","content":"List files","timestamp":"..."} {"type":"tool_use","tool_name":"Bash","tool_id":"bash-123","parameters":{"command":"ls"},"timestamp":"..."} {"type":"tool_result","tool_id":"bash-123","status":"success","output":"file1.txt\nfile2.txt","timestamp":"..."} {"type":"message","role":"assistant","content":"Here are the files...","delta":true,"timestamp":"..."} {"type":"result","status":"success","stats":{"total_tokens":100,"input_tokens":50,"output_tokens":50,"duration_ms":1200,"tool_calls":1},"timestamp":"..."}Documentation:
Added to README.md and docs/
Reviewer Test Plan
Testing Matrix
Linked issues / bugs
fixes #8203