Skip to content

feat: stopPatterns option — explicit stop lines count as awaiting the user - #43

Merged
Mte90 merged 1 commit into
Mte90:masterfrom
ChakraFusion:feat/stop-patterns
Oct 8, 2026
Merged

Mte90 merged 1 commit into
Mte90:masterfrom
ChakraFusion:feat/stop-patterns

Conversation

@ChakraFusion

Copy link
Copy Markdown
Contributor

Problem

Some agent setups end every turn with an explicit protocol line, e.g. STOP: NEEDS_DECISION <question> or STOP: BLOCKED <reason>, and keep the todo for that decision open until the user answers. The open-todos nudge then fires a few seconds later, and the agent tends to answer its own question instead of waiting.

In one such setup, 63 of 73 deliberate stop lines had open todos, so the plugin would have nudged after almost every one of them.

Change

A new opt-in option, stopPatterns (array of regex strings, default []):

  • When the newest assistant message's visible text matches a pattern, hasPendingUserInput() returns true.
  • Every idle nudge then stands down, exactly as it already does for an open question tool call. That covers idle and periodic open-todos nudges, the tool-text scan, action-intent callbacks and the task_complete visible nudge.
  • A newer user message clears the gate as usual.
  • Reasoning parts are ignored, and invalid regexes are skipped.
  • With the default (no patterns), behaviour is unchanged.

Example:

"stopPatterns": ["STOP:\\s*(BLOCKED|NEEDS_DECISION)\\b"]

The two helpers are module-internal (not exported), so the bundled dist still exports only plugin-shaped values (the existing regression test stays green).

Tests

src/index.stop-patterns.test.ts:

  • a turn ending in a stop line with open todos is not nudged;
  • the same turn is nudged without the option (unchanged default);
  • a silent turn end is still nudged with the option set;
  • a stop line inside reasoning does not hold back the nudge;
  • an invalid pattern is skipped.

Full suite: 599 pass, 0 fail (bun test, bun 1.2.23). README: new row in the options table, and a third gate under "User-input awareness".

🤖 Generated with Claude Code

… user

Agent setups that end a turn with a protocol line such as
"STOP: NEEDS_DECISION <question>" or "STOP: BLOCKED <reason>" usually keep
the todo for that decision open. The open-todos nudge then fires and the
agent may answer its own question instead of waiting for the user.

New opt-in option `stopPatterns` (regex strings, default none): when the
newest assistant message's visible text matches one, hasPendingUserInput()
returns true, so every idle nudge stands down exactly as for an open
question tool. A newer user message clears it. Default behaviour unchanged.

Tests: src/index.stop-patterns.test.ts (stop line not nudged, same turn
nudged without the option, silent turn end still nudged, reasoning text
ignored, invalid pattern skipped). Full suite: 599 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mte90
Mte90 merged commit 8ac6a83 into Mte90:master Oct 8, 2026
1 check passed
@Mte90

Mte90 commented Oct 8, 2026

Copy link
Copy Markdown
Owner

We have already Done patterns but not stop and it makes sense

famewolf added a commit to famewolf/opencode-auto-resume that referenced this pull request Oct 15, 2026
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