Add --output-format json for structured output
This is a feature request from @MiddleW4y on Discord
Please explain the motivation behind the feature request. goose run only outputs plain text, making it hard to parse tool calls and responses programmatically.
Describe the solution you'd like Similar to Claude Code's --output-format json functionality, add --output-format json flag to output structured data
goose run --output-format json --text "analyze this code"
should output
{
"messages": [...],
"tool_calls": [...],
"responses": [...],
"metadata": {"total_tokens": 1250, "status": "completed"}
}
- [x] I have verified this does not duplicate an existing feature request
Thanks for adding this issue! stream-json output format would be great also, rather than just one big JSON output at the end. Like streaming json objects to stdout
{"type": "tool_call", ...}
{"type": "message", "role": "assistant", ...}
etc etc
This way you could easily build other kinds of UI on top of goose
you should be able to get this to work by running a recipe
I would like to work on this!
thank you so much. go for it. if you end up picking up future issues..you can self assign the issue in your repo..by commenting .take
The issue you are trying to assign to yourself is already assigned.
Gotcha
Hi @blackgirlbytes, I’d like to contribute to this issue if it’s still available. Could you please assign it to me? Thanks!
Hi, @Roshansingh9 . Thanks for your interest! It looks like @aazam-gh originally asked to be assigned to this, so I want to give them time to work on this issue. If it turns out they don't want this issue anymore then you can pick it up. But in the mean time, you can check here for more Hacktoberfest issues: https://github.com/block/goose/issues/4705
Please read it in detail to learn how to self-assign yourself to a ticket. You will not need me to assign you.
Thanks!
Hi @aazam-gh - wanted to check on your progress with this issue and see if you needed any help :)
Removing this Hacktoberfest labels from this issue. Given that it will take more time to contribute to this issue, and there is no PR ready for review, I want to make sure the remaining time this week is used to get all final submissions merged! Anyone is welcome to reopen this if they have a PR ready to contribute.
Hi! @taniandjerry I've implemented the --output-format json feature as requested and created a pull request. The implementation includes:
- Added
--output-formatflag togoose runcommand - JSON output with messages, tool calls, responses, and metadata
- Backward compatibility maintained
- Manual testing completed
The feature is ready for review! @blackgirlbytes