Skip to content

Add relevance gates, per-call size caps, and byte/cost accounting for tool outputs entering provider payloads #405

Description

@baron

Impact

Unbounded tool result bodies can flow into provider payloads without clear byte/cost visibility. Tool storms remain hard to see until context quality or reliability degrades. Sub-session model use, including intentional high-tier consultation, also needs cost attribution rather than prohibition.

Actual behavior

  • Tool outputs can enter transcripts/payloads at full size without per-call caps or relevance gates before provider injection.
  • There is no sufficiently visible accounting of bytes contributed per tool call, turn, session, or sub-session model call.

Expected behavior

  • Configurable per-tool-call size cap with truncation markers and a retrieval path for full artifacts.
  • Byte accounting per tool call, turn, and session, surfaced in diagnostics and/or usage UI.
  • Sub-session model consultations, including high-tier models when intentionally used, are visible and attributed to the parent/session cost model.

Publishable evidence

  • About 247 MB of rollout function-call output.
  • Worst injections up to about 1.75M characters.
  • About 11k exec_command calls observed in rollout data.

Scope / non-goals

In scope:

  • per-call caps,
  • truncation/retrieval UX,
  • byte accounting,
  • usage attribution for sub-session calls.

Non-goal:

  • forbidding or discouraging high-tier model consultation by subagents. This issue is about visibility and attribution, not restriction.

Likely affected areas

  • Sources/RepoPrompt/Features/AgentMode/Runtime/ToolTracking/
  • Sources/RepoPrompt/Features/AgentMode/Runtime/Usage/
  • Sources/RepoPrompt/Features/AgentMode/Runtime/Usage/Claude/
  • Sources/RepoPrompt/Features/AgentMode/Runtime/Usage/Codex/
  • Sources/RepoPrompt/Infrastructure/MCP/
  • Sources/RepoPrompt/Features/AgentMode/Views/
  • Tests/RepoPromptTests/AgentMode/
  • Tests/RepoPromptTests/MCP/

Acceptance criteria

  • Per-tool-call output cap exists with configurable limit.
  • Truncated outputs include a clear marker and retrieval hint for the full artifact.
  • Per-turn and per-session byte accounting is available in diagnostics or usage UI.
  • Sub-session model usage is attributed to the parent/session in usage reporting.
  • Tests cover cap behavior and accounting totals.

Interlinks

Part of #406. Related: #398, #399, and #401.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:agent-modeAgent Mode runtime and interfacearea:mcpMCP server, clients, and connection visibilityenhancementNew feature or requestuxUser experience and interaction design

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions