Skip to content

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

Merged
FlorianBruniaux merged 2 commits intortk-ai:developfrom
ousamabenyounes:fix/rtk-disabled-warning
Mar 31, 2026
Merged

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

Conversation

@ousamabenyounes
Copy link
Copy Markdown
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 ousamabenyounes force-pushed the fix/rtk-disabled-warning branch from 93d0c31 to a47f485 Compare March 13, 2026 11:33
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 20, 2026

CLA assistant check
All committers have signed the CLA.

@aeppling
Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

ousamabenyounes and others added 2 commits March 26, 2026 19:03
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>
Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.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>
Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
@ousamabenyounes ousamabenyounes force-pushed the fix/rtk-disabled-warning branch from a47f485 to 4ce95a3 Compare March 26, 2026 19:04
@ousamabenyounes
Copy link
Copy Markdown
Contributor Author

Rebased on upstream/develop (includes PR #826 reorganization). Resolved conflict in src/discover/registry.rs by preserving the eprintln! warning on top of the HEAD version — both the RTK_DISABLED guard and the stderr warning are intact. All tests pass.

@FlorianBruniaux FlorianBruniaux merged commit 7e6452c into rtk-ai:develop Mar 31, 2026
9 checks passed
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.

4 participants