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

Offen
#105 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 5 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
25/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Aktiv
Tech-Stack
go
Bereich
tooling

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
Go
Sterne
39
Forks
35
Ø Merge
4 T. 10 Std.
Gemergte PRs (30 T.)
8

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

  • Enthält ein Dockerfile oder eine Docker-Compose-Datei
  • Keine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus kagent-dev/tools

Alle Issues in kagent-dev/tools

Ähnliche Issues

Weitere Issues zu Go

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.