Skip to content

fix(engine): enforce tool use for stop/pause/cancel commands - #2814

Merged
serrrfirat merged 3 commits into
stagingfrom
fix/2808-stop-command-active-mission
Apr 23, 2026
Merged

serrrfirat merged 3 commits into
stagingfrom
fix/2808-stop-command-active-mission

Conversation

@serrrfirat

Copy link
Copy Markdown
Collaborator

Summary

  • Add stop/pause/cancel/halt/disable to the orchestrator's tool-intent nudge and execution-obligation detectors so the LLM is forced to actually call mission_pause/mission_list instead of narrating about them
  • Add bare imperative detection ("stop", "stop pinging", "pause") with startswith guard to avoid false positives like "I can't stop"
  • 5 regression tests covering true positives and false negatives for both detectors

Closes #2808

Test plan

  • cargo fmt — clean
  • cargo clippy --all --benches --tests --examples --all-features — zero warnings
  • cargo test -p ironclaw_engine — 466/466 pass
  • New tests: signals_tool_intent_stop_pause_cancel, signals_tool_intent_no_false_positive_stop_discussion, signals_execution_intent_stop_pause_cancel, signals_execution_intent_bare_stop, signals_execution_intent_no_false_positive_stop_in_sentence

🤖 Generated with Claude Code

The LLM was narrating about calling mission_pause/mission_list instead of
actually executing them because neither the tool-intent nudge nor the
execution obligation recognized stop/pause/cancel as action commands.

- Add stop/pause/cancel/halt/disable to signals_tool_intent ACTION_VERBS
  so the nudge fires when the LLM says "I'll pause the mission"
- Add stop/pause/cancel phrases to signals_execution_intent EXEC_PHRASES
  so the obligation system forces tool calls for "stop it", "pause the X"
- Add bare imperative detection (startswith) for "stop", "stop pinging",
  "pause", "cancel" — avoids false positives like "I can't stop"
- Add 5 regression tests covering true positives and false negatives

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added size: M 50-199 changed lines risk: low Changes to docs, tests, or low-risk modules contributor: core 20+ merged PRs labels Apr 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for 'stop', 'pause', 'cancel', 'halt', and 'disable' intents in the orchestrator, including updates to tool and execution intent logic and new unit tests. Feedback suggests expanding the execution phrase lists for consistency and refactoring the bare command detection to handle punctuation by using word-based splitting.

Comment on lines +165 to +167
"stop it", "stop that", "stop this", "stop the ",
"pause it", "pause that", "pause this", "pause the ",
"cancel it", "cancel that", "cancel this", "cancel the ",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the verbs added to signals_tool_intent, please include the "halt" and "disable" variants in EXEC_PHRASES.

Suggested change
"stop it", "stop that", "stop this", "stop the ",
"pause it", "pause that", "pause this", "pause the ",
"cancel it", "cancel that", "cancel this", "cancel the ",
"stop it", "stop that", "stop this", "stop the ",
"pause it", "pause that", "pause this", "pause the ",
"cancel it", "cancel that", "cancel this", "cancel the ",
"halt it", "halt that", "halt this", "halt the ",
"disable it", "disable that", "disable this", "disable the ",

"cancel it", "cancel that", "cancel this", "cancel the ",
"please run ", "please execute ", "please fetch ",
"please send ", "please deploy ",
"please stop ", "please pause ", "please cancel ",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Add "please halt " and "please disable " to the list of polite execution phrases.

Suggested change
"please stop ", "please pause ", "please cancel ",
"please stop ", "please pause ", "please cancel ", "please halt ", "please disable ",

Comment on lines +179 to +185
trimmed = lower.strip()
IMPERATIVE_STARTS = ["stop ", "pause ", "cancel ", "halt "]
BARE_COMMANDS = ["stop", "pause", "cancel", "halt"]
if trimmed in BARE_COMMANDS:
return True
if any(trimmed.startswith(s) for s in IMPERATIVE_STARTS):
return True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current bare imperative detection is too strict and misses commands with trailing punctuation (e.g., "stop.") or commands on the first line of a multi-line message. Using a word-based check on the first word is more robust and handles punctuation correctly.

Suggested change
trimmed = lower.strip()
IMPERATIVE_STARTS = ["stop ", "pause ", "cancel ", "halt "]
BARE_COMMANDS = ["stop", "pause", "cancel", "halt"]
if trimmed in BARE_COMMANDS:
return True
if any(trimmed.startswith(s) for s in IMPERATIVE_STARTS):
return True
# Bare imperative commands at the start of the message.
# "stop", "pause", "cancel", "halt", "disable" are unambiguous commands
# that don't match the "verb + pronoun/article" pattern above.
# Checking the first word avoids false positives like "I can't stop".
words = lower.split()
BARE_COMMANDS = ["stop", "pause", "cancel", "halt", "disable"]
if words and words[0].rstrip(".,!?") in BARE_COMMANDS:
return True
References
  1. When detecting commands or keywords in a string, use token-based or word-boundary checks instead of simple substring containment to avoid false positives (e.g., 'sync' matching 'nc', 'ghost' matching 'host').

serrrfirat and others added 2 commits April 22, 2026 11:39
- Add missing "please halt " to EXEC_PHRASES for consistency with
  please stop/pause/cancel
- Strip trailing punctuation from bare commands so "Stop." and "cancel!"
  are detected
- Add 2 regression tests covering both fixes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ency (#2814)

- Add "halt it/that/this/the" and "disable it/that/this/the" to
  EXEC_PHRASES for consistency with signals_tool_intent
- Add "please disable " to polite execution phrases
- Add "disable" to BARE_COMMANDS and IMPERATIVE_STARTS
- Add regression test for halt/disable execution intent phrases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@serrrfirat

Copy link
Copy Markdown
Collaborator Author

Addressed all review feedback from gemini-code-assist:

  1. halt/disable in EXEC_PHRASES — Added "halt it/that/this/the" and "disable it/that/this/the" for consistency with signals_tool_intent (4304d2f, 9b10521)
  2. "please halt/disable" — Added both to polite execution phrases (4304d2f, 9b10521)
  3. Bare imperative punctuation + disable — Strip trailing punctuation via rstrip(".,!?;:") so "Stop." and "cancel!" match; added "disable" to BARE_COMMANDS and IMPERATIVE_STARTS (4304d2f, 9b10521)

All 468 engine tests pass, fmt clean.

@serrrfirat
serrrfirat merged commit b5ba749 into staging Apr 23, 2026
18 checks passed
@serrrfirat
serrrfirat deleted the fix/2808-stop-command-active-mission branch April 23, 2026 05:50
@henrypark133 henrypark133 mentioned this pull request Apr 29, 2026
This was referenced May 7, 2026
theredspoon pushed a commit to theredspoon/ironclaw that referenced this pull request Jun 21, 2026
…2814)

* fix(engine): enforce tool use for stop/pause/cancel commands (nearai#2808)

The LLM was narrating about calling mission_pause/mission_list instead of
actually executing them because neither the tool-intent nudge nor the
execution obligation recognized stop/pause/cancel as action commands.

- Add stop/pause/cancel/halt/disable to signals_tool_intent ACTION_VERBS
  so the nudge fires when the LLM says "I'll pause the mission"
- Add stop/pause/cancel phrases to signals_execution_intent EXEC_PHRASES
  so the obligation system forces tool calls for "stop it", "pause the X"
- Add bare imperative detection (startswith) for "stop", "stop pinging",
  "pause", "cancel" — avoids false positives like "I can't stop"
- Add 5 regression tests covering true positives and false negatives

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address review findings (iteration 1)

- Add missing "please halt " to EXEC_PHRASES for consistency with
  please stop/pause/cancel
- Strip trailing punctuation from bare commands so "Stop." and "cancel!"
  are detected
- Add 2 regression tests covering both fixes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(engine): address gemini-code-assist review — halt/disable consistency (nearai#2814)

- Add "halt it/that/this/the" and "disable it/that/this/the" to
  EXEC_PHRASES for consistency with signals_tool_intent
- Add "please disable " to polite execution phrases
- Add "disable" to BARE_COMMANDS and IMPERATIVE_STARTS
- Add regression test for halt/disable execution intent phrases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: low Changes to docs, tests, or low-risk modules size: M 50-199 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[QA] Stop command fails to stop active mission via chat

1 participant