rtk-ai/rtk

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

Open

#2,057 opened on 2026年5月23日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)Rust (2,914 forks)batch import
area:clienhancementhelp wantedpriority:medium

Repository metrics

Stars
 (48,085 stars)
PR merge metrics
 (平均マージ 11d 1h) (30d で 45 merged PRs)

説明

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.

コントリビューターガイド