Skip to content

Stop the model from running away after launching a workflow - #268

Merged
agentforce314 merged 1 commit into
mainfrom
fix/workflow-launch-directive-stop
Jun 11, 2026
Merged

Stop the model from running away after launching a workflow#268
agentforce314 merged 1 commit into
mainfrom
fix/workflow-launch-directive-stop

Conversation

@agentforce314

Copy link
Copy Markdown
Owner

Bug

After /deep-research launches the Workflow tool (which returns a run_id immediately and runs in the background), the main assistant turn runs away — observed: Thinking… 2m+ · ↓150–170k tokens, on multiple models including a fast/smart one (deepseek-v4-pro via OpenRouter). The model says "let me wait for the results" and keeps generating instead of ending its turn.

Root cause

The /deep-research directive told the model to launch the workflow but said nothing about what to do after. With no instruction, the model improvises — "waiting" or writing the report itself — and generates until it nears the context limit. A background workflow returns immediately and delivers its result via a later notification, so the model should just confirm and stop.

Note: this commit (4ad2999) was authored against PR #267 but #267 merged at an earlier commit, so the fix never reached main. This PR lands it.

Fix

Spell out the async contract in the directive: the Workflow tool launches in the background and returns a run_id immediately; after it returns, confirm the run_id in one sentence and END YOUR TURN — do not wait, poll, re-call tools, or write the report yourself; the result arrives automatically when the run finishes.

Tests

tests/test_workflow_command_registration.py asserts the directive contains END YOUR TURN and mentions the background contract. 5 tests pass.

🤖 Generated with Claude Code

… turn)

The /deep-research directive said to call the Workflow tool but not what to do
after. The tool launches in the background and returns a run_id immediately, but
the model would then say "let me wait for the results" and generate endlessly
(observed: a 2-minute, 150k-token main turn going nowhere).

Spell out the async contract in the directive: after the tool returns, confirm
the run_id in one sentence and END the turn — do not wait, poll, re-call tools,
or write the report; the result arrives via notification when the run finishes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@agentforce314
agentforce314 merged commit cb02ec1 into main Jun 11, 2026
singlaamitesh pushed a commit to singlaamitesh/clawcodex that referenced this pull request Jul 7, 2026
…launch-directive-stop

Stop the model from running away after launching a workflow
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.

1 participant