rtk-ai/rtk

`kubectl exec` support — truncate output before reaching LLM context

Open

#2057 aperta il 23 mag 2026

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)Rust (2914 fork)batch import
area:clienhancementhelp wantedpriority:medium

Metriche repository

Star
 (48.085 star)
Metriche merge PR
 (Merge medio 11g 1h) (45 PR mergiate in 30 g)

Descrizione

Feature Request: kubectl exec output truncation

RTK version: 0.39.0

Problem

kubectl exec is not handled by the RTK hook rewriter. When Claude Code runs kubectl exec -n $NS $POD -- <cmd>, the full output enters the LLM context unfiltered.

From rtk discover:

  • kubectl exec: 591 unhandled instances
  • Estimated saveable tokens: high (log files, large outputs)

Proposed behavior

# Input
kubectl exec -n prod mypod -- cat /var/log/app.log

# RTK rewrite → one of:
kubectl exec -n prod mypod -- cat /var/log/app.log | tail -100
# or auto-pipe through rtk summarizer

Suggested rules

  • If command produces file output (cat, less, tail) → append | tail -100
  • If command produces structured output (ps, env, df) → pipe through rtk smart
  • Management commands (rm, kill, mkdir, chmod) → pass through unchanged
  • Already truncated (| head, | tail, > /tmp/) → pass through unchanged

Why this matters

Each untruncated kubectl exec output adds ~10-50K tokens to context.
Cache reads at $0.30/M × 50+ turns = $0.15-0.75 per command per session.
591 unhandled instances in our history = significant real-world spend.

Workaround (current)

We have a custom PreToolUse hook that blocks untruncated kubectl exec and shows a rewrite suggestion. Happy to share if useful as reference implementation.

Guida contributor