feat: provider-wide output compaction/truncation layer for CLI tool results
维护者通常 5 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by reading the implementation of k8s_get_resources from #83 and how providers return results through mcp.TextOutput; the issue names internal/commands and mcp.TextResult as possible integration points. Work out how output formats, structured content, configuration, and metrics should fit together. Done means a shared layer reduces oversized provider output safely and clearly reports truncation, with the open design questions resolved.
由索引模型根据 Issue 内容生成。
描述
Summary
#83 (closing #82) adds a limit parameter to k8s_get_resources to cap result size. That fixes one tool, but the underlying problem is general: almost every provider returns raw CLI output (kubectl, helm, istioctl, cilium, argo, kubescape, ...) straight into the model's context via mcp.TextOutput. Large outputs (cluster-wide listings, describe, logs, proxy-config dumps, scan reports) can blow up token usage and exhaust the context window.
Rather than adding ad-hoc limits per tool, we should consider a shared output-reduction layer, inspired by rtk-ai/rtk — a CLI proxy that reduces LLM token consumption by 60–90% on common dev commands by filtering/compacting command output.
Proposal
Add a shared component in internal/ (e.g. alongside internal/commands or as a post-processor applied in mcp.TextResult) that:
- Truncates safely per format — row-based for tabular output (preserving headers),
items-level for JSON, passthrough for formats without a safe cut point (generalizing the approach in #83). - Always emits an explicit truncation notice with totals and how to narrow the query, so partial data is never mistaken for complete data.
- Compacts noisy output — e.g. strip
managedFields,last-applied-configurationannotations, empty/default fields, collapse repeated log lines, dedupe events. - Is configurable — global defaults via server flags/env/Helm values (e.g. max bytes/rows/tokens), with per-call overrides (
limit=0to disable) where it makes sense. - Is observable — metrics for bytes in/out and truncation counts per tool/provider.
Open questions
- Default on (bounded) vs opt-in? (Same trade-off raised in #83.)
- Size budget unit: rows, bytes, or estimated tokens?
- Should per-command filters live in Go code, or be declarative/config-driven like rtk's filters?
- How does this interact with
StructuredContentand output schema validation?
References
- #82, #83 —
limitfork8s_get_resources - https://github.com/rtk-ai/rtk
- 主要语言
- Go
- 星标
- 39
- 派生
- 35
- 平均合并
- 4 天 10 小时
- 30 天内合并 PR
- 8
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
kagent-dev/tools 的其他 Issue
-
LLM-backed tools are registered without an LLM可能已有人在做 @ntmspavan 于 7 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 67/100
kagent-dev/tools#93 · 1 条评论 ·
维护者通常 5 天内回复
-
Helm chart sets env vars the server never reads可能已有人在做 @lbarrosby 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 67/100
kagent-dev/tools#92 ·
维护者通常 5 天内回复
-
[BUG] Failed commands return only "exit status 1"; the command's error never reaches the agent可能已有人在做 @sathpal 于 34 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 69/100
kagent-dev/tools#89 ·
维护者通常 5 天内回复
-
[BUG] MCP clients get no tools from v0.3.0: kubescape_get_vulnerability_details outputSchema is not an object可能重新可做 @nishanthchandr4 于 47 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
kagent-dev/tools#87 · 2 条评论 ·
维护者通常 5 天内回复
-
Tool calls produce no span and the kubectl subprocess drops trace context可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
kagent-dev/tools#102 ·
维护者通常 5 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
Add CybeDefend未关闭
难度 1/5 1 小时以内 新手友好度 66/100
slavakurilyak/awesome-ai-agents#1031 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
kagent-dev/kagent#3792 ·
维护者通常 1 天内回复
-
ai-driven-qa bug claude Minor
难度 2/5 1-3 小时 新手友好度 68/100
linagora/cozy-stack#5374 ·
维护者通常 1 天内回复
-
new-compilers request
难度 2/5 1-3 小时 新手友好度 65/100
compiler-explorer/compiler-explorer#9640 ·
维护者通常 1 天内回复