Skip to content

loopguard: pass over rtk's command prefix - #247

Merged
Saksham Uboweja (SakshamUboweja) merged 1 commit into
microsoft:mainfrom
VISHNU0906:fix/loopguard-rtk-prefix
Nov 18, 2026
Merged

Saksham Uboweja (SakshamUboweja) merged 1 commit into
microsoft:mainfrom
VISHNU0906:fix/loopguard-rtk-prefix

Conversation

@VISHNU0906

Copy link
Copy Markdown
Contributor

rtk's Codex mode has the agent type rtk pytest, rtk proxy npm test and rtk git checkout -- f. trace.strip_rtk_prefix already takes that prefix off for the micro-skill classifier (and te doctor calls rtk compatible), but the loop guard read the command as typed:

  • status_of_tests("rtk pytest -q") was None, so the run was no verification and a failing one after the last edit left resolved_proxy() True.
  • rtk git status; pytest lost the run's own exit status, because rtk was not a quiet head.
  • rtk proxy sed -i ... was no edit and rtk git checkout -- f was no revert.

What changed:

  • trace/calls.py: RTK_WORDS (rtk, optionally proxy) is the one definition; RTK_PREFIX_RE is built from it and matches exactly what it did before.
  • loopguard/turn.py: _PREFIX_RE passes over RTK_WORDS, only when a command follows, so K=2 rtk pytest and rtk K=2 pytest both count and a bare rtk is left alone.
  • loopguard/shell_edits.py: _bare drops the prefix the way strip_rtk_prefix does.

Tests in tests/test_live_core.py cover runs behind the prefix through TurnGuard.fold, what stays undecided (rtk, rtk proxy, --collect-only, rtk proxy echo pytest, a pipe), and the read/edit/revert cases. 11 of the 16 fail with the source change reverted.

Checked with python -m pytest tests experiments/tests on Python 3.10 and 3.13 (1575 passed, 34 skipped on both), and scripts/dead_code.py shows the same as main. It also merges cleanly with #240, which edits the same regex.

Saksham Uboweja (@SakshamUboweja)

rtk's Codex mode has the agent type `rtk pytest`, `rtk proxy npm test`
and `rtk git checkout -- f`. trace.strip_rtk_prefix already removes that
prefix for the micro-skill classifier, but the loop guard did not, so a
test run behind it was no verification (a failing one after the last edit
left the turn green), `rtk git status; pytest` lost its own exit status,
and `rtk proxy sed -i` was no edit.

turn._PREFIX_RE now passes over trace.RTK_WORDS, the same definition
RTK_PREFIX_RE is built from, and shell_edits._bare drops the prefix the
way strip_rtk_prefix does.

Signed-off-by: KVR Vishnu <46535652+VISHNU0906@users.noreply.github.com>
@SakshamUboweja
Saksham Uboweja (SakshamUboweja) merged commit 4b6b4cf into microsoft:main Nov 18, 2026
11 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.

2 participants