Follow Discord
Sweep 22 Oct 2026 · 04:32Z Build v2.1.308 527 read Stable v2.1.308 Latest v2.1.308 Next v2.1.308 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

mid-conversation-effort-example changedbuild-with-claude/mid-conversation-effort-example

Nearest release: v2.1.281, published 5 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+8added
Lines−8removed
From line 20 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits11to this page, all time

The whole hunk

from line 20, old and new numbered
/
lines
from line 20
2020 
2121The example is a single file. The constants control the effort level, the fan-out shape, and how often the mode refresher is re-sent. `MAX_CONCURRENT` caps how many subagents run at the same time (the PHP port is sequential and ignores it); `MAX_TOTAL_SUBTASKS` caps how many the model may queue in a single Workflow call. Splitting the two lets the model plan a large backlog without launching it all at once. The `DOC_TEST_MODE` check caps the loops to a single turn when that environment variable is set, so the automated docs harness can validate that the file compiles and finishes quickly without running the full orchestration; leave it unset when running the example yourself.
2222 
23<CodeGroup>
23<CodeGroup exclude="shell:cURL, shell:CLI">
2424 ```python Python
2525 import atexit
2626 import concurrent.futures
from line 300
300300 
301301The reminders are short on purpose. They flip the mode and point at the tool description, where the heavyweight instructions live. The full text is sent once when the mode turns on, the refresher is re-sent only after several user turns, and the exit notice is sent once when the mode turns off.
302302 
303<CodeGroup>
303<CodeGroup exclude="shell:cURL, shell:CLI">
304304 ```python Python
305305 MODE_ENTER = (
306306 "Orchestration mode is on: optimize for the most exhaustive, correct answer rather than "
from line 400
400400 
401401The Workflow tool carries the real behavioral contract: the opt-in rule, the standing consent that applies while the mode is on, granularity guidance for sizing the fan-out, and the quality patterns the model can reach for (a verification wave, a completeness critic, multiphase sequencing). Subagents also get a `report_findings` tool so their results come back as structured JSON instead of prose, and the bash tool is the Anthropic-defined `bash_20250124` tool run locally.
402402 
403<CodeGroup>
403<CodeGroup exclude="shell:cURL, shell:CLI">
404404 ```python Python
405405 WORKFLOW_TOOL = {
406406 "name": "Workflow",
from line 886
886886 
887887The bash handler runs the requested command with a timeout, captures combined stdout and stderr, and truncates the result so a runaway command can't flood the context window. Commands run in the directory you launch the example from, so pointing it at a project means starting it there; when `DOC_TEST_MODE` is set, the harness instead gives bash a small throwaway fixture directory that is removed on exit. There is no sandbox here: the command runs with the permissions of the process that launched the example. For clarity this example runs each call in a fresh subshell rather than maintaining the persistent session the `bash_20250124` contract describes; a production agent should back the tool with a long-lived shell so that working directory, environment, and the `restart` action behave as documented.
888888 
889<CodeGroup>
889<CodeGroup exclude="shell:cURL, shell:CLI">
890890 ```python Python
891891 # Run bash where the example was launched. In DOC_TEST_MODE the docs harness
892892 # points it at a throwaway fixture directory instead, removed on exit.
from line 1433
14331433 
14341434Each workflow subtask becomes its own small agent loop with the bash tool, running at the same effort as the main loop. A per-request timeout bounds each API call so a dropped connection degrades one subagent instead of stalling the whole run.
14351435 
1436<CodeGroup>
1436<CodeGroup exclude="shell:cURL, shell:CLI">
14371437 ```python Python
14381438 def run_subagent(model: str, prompt: str) -> str:
14391439 """One subagent: a small nested agent loop with the bash tool plus report_findings.
from line 1977
19771977 
19781978A fan-out that spawns dozens of subagents is expensive to restart from scratch. A small content-addressed journal makes it idempotent: before dispatching a subagent, look up the SHA-256 of its prompt in a local JSON file, and return the recorded result if one exists. Interrupt the run, rerun it, and only the subtasks that never finished are recomputed. The journal deduplicates across runs, not within a single fan-out wave; delete the journal file to start fresh.
19791979 
1980<CodeGroup>
1980<CodeGroup exclude="shell:cURL, shell:CLI">
19811981 ```python Python
19821982 _journal_lock = threading.Lock()
19831983 
from line 2268
22682268 
22692269The fan-out accepts up to `MAX_TOTAL_SUBTASKS` prompts, runs them through the journal with at most `MAX_CONCURRENT` in flight (sequential in the PHP port), and isolates failures so one broken subagent degrades to an error string instead of ending the run. Once the first wave finishes, a second wave reuses the same subagent path to try to refute each result: every verifier re-derives the claims from the source, defaulting to refuted when uncertain. Both the original result and its verdict are returned to the orchestrator so it can weigh them together.
22702270 
2271<CodeGroup>
2271<CodeGroup exclude="shell:cURL, shell:CLI">
22722272 ```python Python
22732273 def normalize_subtasks(raw) -> list[str]:
22742274 """Accept the subtasks input in whatever shape the model emits: an array, the array
from line 3828
38283828 The bash tool in this example runs model-written commands directly on your machine with no sandbox, and the fan-out runs several of those agents in parallel. Run it in a directory and environment you are comfortable exposing, and add sandboxing before adapting it for anything beyond local experimentation.
38293829</Warning>
38303830 
3831<CodeGroup>
3831<CodeGroup exclude="shell:cURL, shell:CLI">
38323832 ```python Python
38333833 if __name__ == "__main__":
38343834 task = (
Feedback