feat(run_agent): extend codex intermediate-ack detection to French + relax prior-tool bail - #22059
Open
Julientalbot wants to merge 1 commit into
Open
feat(run_agent): extend codex intermediate-ack detection to French + relax prior-tool bail#22059Julientalbot wants to merge 1 commit into
Julientalbot wants to merge 1 commit into
Conversation
…relax prior-tool bail
The _looks_like_codex_intermediate_ack heuristic that re-routes narrative
acknowledgement turns into the post-tool nudge had two coverage gaps:
1. The future-ack regex, action_markers and workspace_markers were
English-only. French Telegram users routinely produce IWE patterns
("Je vais vérifier le dossier", "Je corrige le binding", "Je relance
le dashboard") that fell through detection.
2. The bail-on-prior-tool was global to the entire session, so any tool
call earlier in the conversation permanently disabled detection.
On long Telegram/CLI sessions (90 turns) this masked a fresh
narration-only turn even when the *current* turn had no tool yet.
Changes:
- Replace the global bail with a current-turn-only check (since the
most recent user message).
- Extend the future-ack regex with FR phrases (je vais, je corrige,
je relance, je vérifie, je moccupe, cest noté, etc.).
- Extend action_markers with FR verb stems (vérifi, corrig, relanc,
examin, cherch, analys, lanc, etc.) — substring match handles
conjugations.
- Extend workspace_markers with FR nouns (répertoire, dossier,
arborescence, projet, fichier, chemin, code, base de code).
Tests: 10 new cases in TestLooksLikeCodexIntermediateAck covering EN
regression, FR positives (verifier, corriger, relancer, diagnostiquer,
examiner), FR negatives (no action+workspace, no future ack), and the
relaxed prior-tool bail.
This was referenced May 8, 2026
teknium1
reviewed
Jul 13, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for identifying two still-present detector gaps. Current main still performs the full-history tool bail at agent/agent_runtime_helpers.py:2639 and its acknowledgement regex remains English-only at agent/agent_runtime_helpers.py:2648.
Problems
run_agent.py:3503adds barecodeas a substring workspace marker. A response such as “Je vais vérifier le code postal” also matches the proposedje vaisfuture-ack andvérifiaction markers, so it would receive an unnecessary continuation nudge.- The changed implementation location is stale:
run_agent.py:1552-1563now forwards toagent/agent_runtime_helpers.py:2619, and focused detector coverage lives intests/agent/test_intent_ack_continuation.py.
Suggested changes
- Port the current-turn-only tool check and French cases to the helper and its focused test module.
- Remove or qualify bare
code, and add a negativecode postalregression test.
Automated hermes-sweeper review.
| "projet", | ||
| "fichier", | ||
| "chemin", | ||
| "code", |
Contributor
There was a problem hiding this comment.
Bare code is too broad for substring matching: “Je vais vérifier le code postal” also matches the proposed future-ack and vérifi action markers, producing a false continuation. Please remove or qualify this marker and cover that negative case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
_looks_like_codex_intermediate_ackre-routes narrative acknowledgement turns ("I'll check the directory") into the post-tool nudge so the agent keeps working instead of ending the turn on a promise. Two coverage gaps were limiting it on real-world sessions:1. English-only patterns. The future-ack regex and the
action_markers/workspace_markerstuples only knew English. French Telegram/CLI users routinely produce IWE patterns that fall through detection:These are direct French equivalents of "I'll check...", "Let me fix..." — same intent, same need for nudge re-routing, but the detector returned
Falseand the turn ended on a narration-only response, leaving the user in an IWE spiral.2. Global bail on prior tool. The current implementation bails as soon as any message in
messageshasrole == "tool":On long Telegram/CLI sessions (60–90 turns), the first tool call permanently disables detection for the rest of the conversation, even when the current user turn has produced zero tools. Captured from a real Alfred session: a fresh narration-only turn at message #150 was masked because a
terminalcall had executed at message #9.Fix
A. Localize the bail to the current turn only. Walk back from the end of
messagesto the most recentusermessage; only that slice counts as the "current turn". A tool earlier in the session no longer invalidates detection.B. Extend the future-ack regex with French intent verbs:
C. Extend
action_markerswith French verb stems (substring match handles conjugations):D. Extend
workspace_markerswith French nouns:The multi-condition guard (
(user_targets_workspace or assistant_targets_workspace) and assistant_mentions_action) is unchanged — false-positive risk on opinion-style French ("Je vais réfléchir à ça") remains contained.Tests
New
TestLooksLikeCodexIntermediateAckclass intests/run_agent/test_run_agent.pywith 10 cases:test_english_ack_with_workspace_action— regressiontest_french_ack_je_vais_verifier_dossier— canonical FR IWEtest_french_je_corrige_le_binding— from a real Alfred Telegram sessiontest_french_je_relance_le_dashboard— sametest_french_action_diagnostiquer_arborescencetest_french_action_examiner_repertoiretest_french_no_action_no_workspace_returns_false— opinion ("Je vais réfléchir") stays outtest_french_no_future_ack_returns_false— no future-tense verb stays outtest_prior_tool_outside_current_turn_does_not_bail— relaxed bail regressiontest_tool_in_current_turn_bails— relaxed bail still bails when correctpytest tests/run_agent/test_run_agent.py -v -k LooksLikeCodexIntermediateAck→ 10 passed.Why now
Pairs naturally with the existing English narration coverage and PR #6757 (which generalizes intermediate-ack detection to all
api_modes). Whether #6757 lands first or this PR does, the regex/markers extension here applies orthogonally. The relaxed bail also helps any agent stack where a single session legitimately interleaves productive tool turns with narration-only ones — common on Telegram/CLI gateways.This is the second of a small series of PRs improving IWE detection on grok-4.x via xAI direct (paired with #22055 which transmits
reasoning.effortto xAI Responses).