Skip to content

warn: emit stderr warning on RTK_DISABLED=1 (#508)#528

Open
ousamabenyounes wants to merge 2 commits intortk-ai:developfrom
ousamabenyounes:fix/rtk-disabled-warning
Open

warn: emit stderr warning on RTK_DISABLED=1 (#508)#528
ousamabenyounes wants to merge 2 commits intortk-ai:developfrom
ousamabenyounes:fix/rtk-disabled-warning

Conversation

@ousamabenyounes
Copy link
Contributor

Summary

Fixes #508 — AI agents overuse RTK_DISABLED=1 after encountering a single filtering issue, silently killing token savings for the entire session.

Real impact observed: 801 commands in a session, 243 (30%) used RTK_DISABLED=1 unnecessarily. Savings dropped from ~65% to 48%.

Fix: When the rewrite hook detects RTK_DISABLED=1, emit a warning on stderr:

[rtk] RTK_DISABLED=1 detected — skipping filter for this command. Remove RTK_DISABLED=1 to restore token savings.

The agent sees this warning in real-time and learns to stop overusing the bypass.

Why this works

  • Warning is on stderr (not stdout) — no impact on command output or piping
  • The bypass still works exactly as before — no behavior change
  • Agents (Claude, Gemini) read stderr and adjust behavior
  • A single warning per command is enough to break the pattern

Before/After

# BEFORE: agent silently bypasses RTK on 30% of commands
RTK_DISABLED=1 git status    # no output, no warning → agent keeps doing it

# AFTER: agent sees the cost
RTK_DISABLED=1 git status
# stderr: [rtk] RTK_DISABLED=1 detected — skipping filter for this command.
#         Remove RTK_DISABLED=1 to restore token savings.
# → agent stops overusing it

Test plan

  • 3 existing RTK_DISABLED tests pass (return value unchanged)
  • Full suite: 764 passed, 0 failed
  • cargo fmt && cargo clippy && cargo test all green
  • validate-docs.sh passes

Generated with Claude Code

ousamabenyounes and others added 2 commits March 12, 2026 06:13
When the rewrite hook sees RTK_DISABLED=1, it now prints a warning to
stderr before skipping the rewrite. This educates AI agents to stop
overusing the bypass — a real session showed 30% of commands using
RTK_DISABLED=1 unnecessarily, dropping savings from ~65% to 48%.

The warning is on stderr (not stdout) so it doesn't affect command
output or piping. The bypass still works exactly as before.

Fixes rtk-ai#508

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verifies that `rtk rewrite "RTK_DISABLED=1 git status"` emits the
warning on stderr, not just that rewrite_command returns None.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant