Skip to content

Feature Request: Fine-Grained Context Cost Attribution #1441

Description

@vindia9

Problem / motivation

In multi-turn agent sessions, costs come not only from generation but also from repeatedly carrying prior content into later requests. It would be useful to attribute these costs to specific context sources and content blocks.

1. Cost Attribution by Context Source

Break down tokens and costs by source:

  • Harness / agent runtime
  • Prompts: system, schema, skills, user, and runtime injections
  • Shell commands: command, arguments, and output
    • Drill down by command and subcommand, such as git, git diff, and git log
  • Tool calls: arguments, results, reads, and writes
  • Bidirectional tools and agent-to-agent interactions
  • Attachments: images, documents, code, and other inputs
  • Reminders and automation context
  • Assistant-generated content

2. Generation vs. Repeated-Carry Cost

For each content block, distinguish between:

  • Its initial generation cost
  • Its cost when later used as input
  • How many subsequent requests carried it
  • Its cumulative repeated-carry cost
  • Its total lifetime cost

This would reveal content that was inexpensive to generate but became costly because it remained in the context for many turns.

3. Content-Level Drill-Down and Traceability

Allow users to open a cost item and inspect:

  • The original content and its source
  • Where it first appeared
  • Its token size
  • Which later requests carried it
  • Generation, repeated-carry, and lifetime costs
  • Whether it is still present in the current context

A stable identifier for each context block could help track the same content across requests.

4. Visualization

Possible views include:

  • A sortable table for exact attribution
  • Pie or donut charts for cost proportions
  • Petal or sunburst charts for hierarchical breakdowns
  • Timelines or stacked charts for context growth across turns
  • Cumulative curves for repeated-carry costs
  • Sankey diagrams showing content flow from generation to reuse

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions