Skip to content

claude.print/codex usage: record token & cost in State and reports #79

Description

@qinhaihong-red

Parent

#1

What to build

Carved out of #9 (claude.print adapter) — see the scope decision recorded on that
issue. #9 ships the adapter and normalizes exit_status, stdout, stderr,
structured_output, and artifacts, but deliberately does not plumb the Agent
CLI's reported token/cost usage, because doing so extends the vendor-neutral Adapter
contract (ADR 0006) and the persisted node output shape — a cross-cutting change worth
its own issue.

This issue adds usage as a first-class, vendor-neutral concept:

  • Add a neutral usage representation to AgentResult (e.g. input/output tokens and
    a cost figure), populated by each real Adapter from the CLI's own usage report
    (claude -p --output-format json exposes token counts and total_cost_usd;
    codex exec exposes its equivalent).
  • Thread usage through NodeResult into State, persisted inside the node's existing
    normalized_output JSON payload
    (no new State column — avoids a schema migration of
    the kind Resume across schema versions: node.cause column has no migration #76 had to repair).
  • Surface usage where run results are shown. The dedicated Reporter is Reporters and caw report in four formats #12; until it
    lands, the existing caw run / caw resume run summary is the surfacing point.
  • Update ADR 0006 to record the contract extension (the AgentResult.usage field and the
    rule that usage rides inside the persisted output, not a new column).

Acceptance criteria

Blocked by

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions