Skip to content

kubectl exec support — truncate output before reaching LLM context #2057

Open

Description

@gulshanCloud

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.

Activity

  1. added
    enhancement
    help wanted
    on May 27, 2026
  2. pszymkowiak commented on May 27, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    ✨ Category feature
    🟡 Priority medium
    🎯 Confidence 92%

    Summary

    Feature request to add kubectl exec to RTK's hook rewriter with output truncation rules; well-scoped with clear proposed behavior and real cost impact.


    Triaged automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clienhancementhelp wantedpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions