rtk-ai/rtk
Auf GitHub ansehen`kubectl exec` support — truncate output before reaching LLM context
Open
#2.057 geöffnet am 23. Mai 2026
area:clienhancementhelp wantedpriority:medium
Repository-Metriken
- Stars
- (48.085 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 11T 1h) (45 gemergte PRs in 30 T)
Beschreibung
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.