Skip to content

Measure what an agent step costs, so cache and compaction changes can be judged by their effect #56422

Open

Description

@dat-rd

Measure what a step costs

The harness has no way to answer "is this change cheaper?" Today the cache policy is checked by asserting that a cache_control marker lands where a test expected one, which proves the marker exists but not that it saves anything.

That gap is measurable rather than theoretical. Against a provider stand-in that counts the tokens of the request it receives and reports a cache read only for a prefix an earlier request already wrote:

  • The shipped default policy (tools + system + one tail breakpoint) reaches ~91% reuse over a 20-step conversation, with uncached input staying roughly flat while the conversation grows tenfold.
  • Marking more of the tail does not help (tail: 2 measures equal), and tail: 3 is measurably worse, because each step's newest turn is new regardless and the provider only allows four breakpoints.
  • Dropping the tail breakpoint is the expensive mistake: +66% on the same conversation.

Two related open questions would benefit from the same measurement, and I would rather add numbers than guesses:

The proposal is a test fixture, not a production change: a provider stand-in in test/fixture/ that meters requests the runner already made, plus cases that assert the reuse it measures. Happy to split it smaller if that is easier to review, or to keep it purely as a fixture and let follow-up PRs add the measurements.

Activity

  1. opencode-agent commented on Oct 17, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed write-up and the numbers. To restate the request: you'd like a metering provider stand-in in test/fixture/ so that cache and compaction changes can be judged by how much prompt cache is actually reused, not just by where cache_control markers land. Maintainers will look at it alongside your PR.

    Related items that could use this kind of measurement:

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions