[Feature Request] Mitigate exponential token consumption & add token budget guardrails

オープン
#2,468 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

  • #2482 @juniorhillory-creator による — マージされずにクローズ

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript

調査の方向性

The request names no files, tests, or entry points. Start by locating where task context and tool outputs are added to conversation history, then trace how token usage is tracked. Done means the team has defined and implemented the requested budget pause, output truncation, and targeted edit behavior, with tests covering those flows.

索引モデルが issue の本文から書いたものです。

説明

enhancement

Is your feature request related to a problem? Please describe.
When running multi-step agentic tasks (like a 10-step debugging loop), token consumption scales exponentially due to the sliding window context. By step 5 or 6, the agent is re-sending the system prompt and all previous tool outputs (like massive linter errors or read_file contents), which drastically inflates API costs and quickly eats up the context window.

Describe the solution you'd like
To make agentic loops more sustainable, I suggest implementing a few context-management guardrails:

  1. Hard Token Budgets / Limits: Add a UI setting to set a maximum token budget per task (e.g., "Pause agent if task exceeds 100,000 tokens"). If the loop hits this, it pauses and asks the user if they want to summarize the context or continue.
  2. Raw Output Truncation: Automatically truncate or summarize massive terminal outputs (like npm error logs or large read_file payloads) before injecting them back into the context history.
  3. Targeted Diff Enforcement: Provide a built-in strict mode (or update system instructions) that heavily penalizes full-file rewrites via write_file and enforces targeted edits via edit_file to save on expensive output tokens.

Describe alternatives you've considered
Currently, my only workaround is to manually kill the task when the history gets too long and start a fresh session, or route repetitive tasks to my local Ollama models to avoid API costs.

Additional context
When the agent rewrites large files, it not only burns output tokens but also frequently busts the API prompt cache for subsequent turns. Better context pruning would keep cache hit rates higher and significantly reduce user costs.

主要言語
TypeScript
スター
2k
フォーク
301
平均マージ
3日 14時間
マージ済み PR(30日)
103

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Zoo-Code-Org/Zoo-Code のほかの issue

Zoo-Code-Org/Zoo-Code の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。