Skip to content

Implement 'Tactful Extraction' logic for token-frugal surgical reads #19561

Description

@adamfweidman

Motivation

Current context baseline is approximately 36.6k tokens per turn. Large file reads often 'firehose' the context, leading to bloat (previously observed at +15k tokens/turn).

The goal of 'Tactful Extraction' is to establish a surgical code-discovery hierarchy:

  1. grep_search: Primary scout for locating symbols.
  2. shell/sed: scalpel for semantic block extraction (preferred for specific line ranges).
  3. read_file: surgical range-reading (migrated to 1-based start/end lines).

Telemetry indicates that making ~2.1% more targeted tool calls results in a ~6.9% reduction in total input tokens.

Changes

  • read_file migration: Switched from 0-based 'offset'/'limit' to 1-based 'start_line'/'end_line' for better model alignment.
  • Surgical Guidance: Updated tool descriptions and system prompts to mandate 'token-frugal' behavior.
  • Tool Hierarchy: Emphasized the use of 'grep_search' and 'sed' via 'run_shell_command' for efficient context management.

Status

This work is temporarily sidelined in favor of other priorities but remains a key architectural goal for efficiency.

Linked Draft PR: #18924

Activity

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

Metadata

Metadata

Assignees

Labels

area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitykind/enhancementpriority/p3Backlog - a good idea but not currently a priority.status/bot-triagedworkstream-rollupLabel used to tag epics and features that are associated with one of the three primary workstreams🔒 maintainer only⛔ Do not contribute. Internal roadmap item.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions