Skip to content

feat(agy): wire up real token usage via --output-format json - #110

Merged
fnnzzz merged 1 commit into
mainfrom
feat/agy-json-usage
Sep 10, 2026
Merged

fnnzzz merged 1 commit into
mainfrom
feat/agy-json-usage

Conversation

@fnnzzz

@fnnzzz fnnzzz commented Sep 10, 2026

Copy link
Copy Markdown
Member

Summary

  • lib/cli-usage.js already documented and tested agy's exact --output-format json envelope shape ({"status","response","usage":{"input_tokens","output_tokens","cache_read_tokens"}}), but no agy-* registry entry ever turned on the flag or declared usage_from to use it — every agy dispatch reported tokens_in/tokens_out as null, the same blind spot claude's usage_from closed in 0.54.0.
  • Adds --output-format json + usage_from to all 12 agy-* edit_exists/read_only transports (registry-only change, no lib/dispatch.js or lib/cli-usage.js code changes).
  • Verified live against the real agy 1.2.0 binary: a real file-writing task returns real usage numbers and the file is genuinely created, and composes correctly with fix(agy): declare failure_markers for the print-timeout watchdog #109's failure_markers fix — the JSON envelope goes to stdout, the print-timeout notice goes to stderr separately, so the marker still forces a failure on non-blank stdout, and the print-timeout's own all-zero usage still parses (rather than falling back to raw JSON as the answer).

Test plan

  • lib/cli-usage.test.js: new unit test feeding parseCliUsage agy's real print-timeout envelope (zero usage, empty response) — parses correctly instead of returning null
  • lib/false-success.test.js: two new end-to-end runDispatch tests — (1) usage_from + failure_markers compose on the print-timeout path (marker still wins, zero usage still extracted), (2) a genuine successful dispatch under JSON output stays a success and reports real usage
  • lib/registry.transports.test.js: added agy's real captured envelope to RECORDED_ENVELOPES, strengthening the existing "usage_from parses recorded output" check beyond a synthetic round-trip
  • node --test lib/*.test.js: 509 pass, 1 pre-existing skip, 0 fail
  • Consensus gate: 4/4 reviewers responded (ollama-gpt-oss-120b, qwencloud-qwen-flash-character, qwencloud-qwen-plus-character, ollama-gpt-oss-20b-key), all APPROVE. One flagged item ("do other transports have the same gap?") is already covered by the existing registry-wide usage_from/--output-format consistency test, which passes clean across the whole registry. Addressed two nice-to-have suggestions (a successful-dispatch regression test, and a comment on why thinking_tokens is left unmapped).

🤖 Generated with Claude Code

lib/cli-usage.js already documented and tested agy's exact JSON
envelope shape ({"status","response","usage":{...}}), but no agy-*
registry entry ever declared --output-format json or usage_from to
use it. Every agy dispatch reported tokens_in/tokens_out as null —
the same blind spot claude's usage_from closed in 0.54.0.

Adds --output-format json and usage_from to all 12 agy-*
edit_exists/read_only transports. Verified live against agy 1.2.0:
a real file-writing task returns real usage numbers and the file is
actually created, and the print-timeout marker fix from #109 still
composes correctly (the JSON envelope goes to stdout, the
print-timeout notice to stderr, separately) — the marker still forces
a failure on non-blank stdout, and zero usage still parses instead of
falling back to raw JSON as the answer.

Consensus: 4/4 reviewers responded, all APPROVE. One flagged item
(whether other transports have the same gap) is already covered by
the existing registry-wide "usage_from asks for structured output"
test, which passes clean. Addressed two nice-to-have suggestions:
added a successful-dispatch regression test and a comment documenting
why thinking_tokens is left unmapped (cli-usage.js has no slot for it
today; out of scope for a registry-only change).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@fnnzzz
fnnzzz merged commit 2a942d6 into main Sep 10, 2026
2 checks passed
@fnnzzz fnnzzz mentioned this pull request Sep 16, 2026
2 of 3 tasks
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.

1 participant