Repository navigation
feat(agy): wire up real token usage via --output-format json - #110
Merged
Merged
Conversation
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>
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.
Summary
lib/cli-usage.jsalready documented and tested agy's exact--output-format jsonenvelope shape ({"status","response","usage":{"input_tokens","output_tokens","cache_read_tokens"}}), but noagy-*registry entry ever turned on the flag or declaredusage_fromto use it — every agy dispatch reportedtokens_in/tokens_outasnull, the same blind spotclaude'susage_fromclosed in 0.54.0.--output-format json+usage_fromto all 12agy-*edit_exists/read_onlytransports (registry-only change, nolib/dispatch.jsorlib/cli-usage.jscode changes).agy1.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'sfailure_markersfix — 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 feedingparseCliUsageagy's real print-timeout envelope (zero usage, empty response) — parses correctly instead of returning nulllib/false-success.test.js: two new end-to-endrunDispatchtests — (1)usage_from+failure_markerscompose 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 usagelib/registry.transports.test.js: added agy's real captured envelope toRECORDED_ENVELOPES, strengthening the existing "usage_from parses recorded output" check beyond a synthetic round-tripnode --test lib/*.test.js: 509 pass, 1 pre-existing skip, 0 failAPPROVE. One flagged item ("do other transports have the same gap?") is already covered by the existing registry-wideusage_from/--output-formatconsistency test, which passes clean across the whole registry. Addressed two nice-to-have suggestions (a successful-dispatch regression test, and a comment on whythinking_tokensis left unmapped).🤖 Generated with Claude Code