feat(cli): add --output-format json flag for structured query output#2916
Open
xmxdeusltd wants to merge 1 commit intoNousResearch:mainfrom
Open
feat(cli): add --output-format json flag for structured query output#2916xmxdeusltd wants to merge 1 commit intoNousResearch:mainfrom
xmxdeusltd wants to merge 1 commit intoNousResearch:mainfrom
Conversation
Add --output-format flag to hermes chat with 'text' (default) and 'json' options. When set to 'json', outputs a single JSON object with structured metrics aligned with Codex/Claude Code output formats: - type, subtype, is_error (status) - result, session_id (response) - model, provider (runtime info) - num_turns, duration_ms, total_cost_usd (performance) - usage.input_tokens, output_tokens, cache_read/creation, reasoning_tokens - tool_call_count JSON mode auto-enables quiet mode and suppresses streaming UI output (response box, spinners) so stdout contains only valid JSON. Enables programmatic orchestration of Hermes by external tools (e.g. Symphony, CI/CD pipelines) that need structured agent output.
Author
|
Aim was to create parity with codex app-server / claude cli json outputs. It's a mild addition and shouldn't interfere with anything else (unless you have bigger plans for this) |
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
Adds
--output-format jsonflag tohermes chat -qfor structured output.Why
Enables programmatic orchestration of Hermes by external tools (Symphony, CI pipelines, MCP servers) that need structured agent output — token counts, cost, session ID, model info — in a machine-readable format.
Output schema aligns with Codex
--jsonand Claude Code--output-format jsonconventions (type/subtype/is_error/result/session_id/usage/duration_ms/total_cost_usd).How to test
hermes chat -q "What is 2+2?" --output-format jsonReturns clean JSON:
{"type":"result","subtype":"success","is_error":false,"result":"4", "session_id":"...","model":"...","provider":"...","num_turns":1, "duration_ms":3509,"total_cost_usd":0.0,"usage":{...},"tool_call_count":0}Text mode (default) is unchanged.
--output-format jsonauto-enables quiet mode so stdout is clean JSON only.Changes
hermes_cli/main.py: Add--output-formatargument (choices: text/json, default: text) + pass through kwargscli.py: Addoutput_formatparameter tomain(), JSON implies quiet, suppress streaming UI during agent run, emit structured JSON resultTested on
python3 -m json.tool