feat: provider-wide output compaction/truncation layer for CLI tool results

Đang mở
#105 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 5 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
tooling

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

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-configuration annotations, 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=0 to 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 StructuredContent and output schema validation?

References

Ngôn ngữ chính
Go
Star
39
Fork
35
Merge trung bình
4 ngày 10 giờ
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của kagent-dev/tools

Tất cả issue của kagent-dev/tools

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.