Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[FEATURE] Add a limit parameter to k8s_get_resources to bound context growth

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go, kubernetes
領域
devops, tooling

調査の方向性

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 json document would return an invalid one, so JSON should be cut at its items array 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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

kagent-dev/tools のほかの issue

kagent-dev/tools の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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