[FEATURE] Add a limit parameter to k8s_get_resources to bound context growth
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
調査の方向性
kubectl get のラッパーである k8s_get_resources から開始し、all_namespaces と各出力形式がどのように処理されるかを追跡します。デフォルトが無制限のままになるのか有限になるのかを解決し、そのうえで、JSON の有効性を維持し、YAML を指定どおりに処理しながら、limit と切り捨ての合計値が正しく表現されることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Problem
k8s_get_resources wraps kubectl get and has no way to bound how much it returns. On a large cluster an agent that calls it with all_namespaces=true gets every row of every namespace in a single tool result, which goes straight into the model's context.
In our production estate this is the single largest source of context growth. An agent turn that issued a handful of cluster-wide k8s_get_resources calls reached several million input tokens and exhausted the model's context window, which ends the turn with an error rather than a large-but-usable answer. The failure is also expensive, because the oversized listing is paid for on every subsequent turn that carries the history.
Prompt guidance alone has not been enough for us. Telling the agent to query narrowly reduces how often it happens, but the tool still permits an unbounded listing, so a single unlucky call undoes it. The parameters today are resource_type, resource_name, namespace, all_namespaces and output — none of them cap result size.
Proposal
Add an optional limit parameter to k8s_get_resources that caps the number of resources returned, with limit=0 returning everything.
Two details matter for it to be safe:
- The truncated result should say it was truncated and give the totals. A silently shortened listing reads as complete, so the model draws conclusions from partial data — which is worse than the original problem.
- Truncation has to respect the output format. Slicing lines out of a
-o jsondocument would return an invalid one, so JSON should be cut at itsitemsarray and YAML left alone.
Whether the default should be a finite cap or unlimited is the main open question. A finite default is what actually protects agents that do not know to pass the parameter, but it changes behaviour for existing callers. Happy to follow whichever the maintainers prefer.
I have a change ready and will open a PR against this issue.
- 主要言語
- Go
- スター
- 35
- フォーク
- 30
- 平均マージ
- 3日 23時間
- マージ済み PR(30日)
- 3
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
kagent-dev/tools のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
kagent-dev/tools#54 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
kagent-dev/tools#80 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
kagent-dev/tools#69 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
kagent-dev/tools#68 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
kagent-dev/tools#60 · リアクション 1 件 ·
kagent-dev/tools の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
Bob Shell support オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
santhosh-tekuri/jsonschema#276 ·