Skip to content

feat(events): context and cost per agent step, ACP-aware run detail #65

Description

@FreshlyBrewedCode

Parent

#62

What to build

ADR 0013 §5 and the SPA side of the change.

  • AgentStepFinished gains optional context: { used, size } and
    cost: { amount, currency }, taken from the last usage signal of the step, including for
    cancelled steps. Update the usage doc comment: "as the agent reports it", which means the
    last message on opencode and the whole turn on Claude.
  • Run detail shows context in use and window size from context where present. It falls
    back to agentStepContextTokens for old logs. Cost shows per step and summed per run where
    present.
  • Live context: while a step runs, the SPA reads the acp.usage CUSTOM chunks to show
    context filling up.
  • Transcript tool titles: ACP tool calls carry a descriptive title (Edit math.ts) in the
    raw event. Show it instead of the generic kind (edit, read, execute) where present.
  • Tests for the schema, the fold, and the rendering.

Acceptance

  • bun run check and bun run test:e2e green.
  • A real Claude run shows context and cost in run detail. Validate in the browser.
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

    taskA single self-contained piece of work that ships as one PR

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions