Stop the model from running away after launching a workflow - #268
Merged
Conversation
… 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>
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
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.
Bug
After
/deep-researchlaunches the Workflow tool (which returns arun_idimmediately 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-researchdirective 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.Fix
Spell out the async contract in the directive: the Workflow tool launches in the background and returns a
run_idimmediately; 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.pyasserts the directive containsEND YOUR TURNand mentions the background contract. 5 tests pass.🤖 Generated with Claude Code