Follow Discord
Sweep 06 Nov 2026 · 01:32Z Build v2.1.319 537 read Stable v2.1.311 Latest v2.1.319 Next v2.1.319 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.319, published an hour after 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+64added
Lines−0removed
From line 21 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits16to this page, all time

The whole hunk

from line 21, old and new numbered
/
lines
from line 21
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 completes quickly without running the full orchestration; leave it unset when running the example yourself.
2222 
2323<CodeGroup exclude="shell:cURL, shell:CLI">
24 <CodeGroupItem language="cURL">
25 Set the constants in code.
26 </CodeGroupItem>
27 
28 <CodeGroupItem language="CLI">
29 Set the constants in code.
30 </CodeGroupItem>
31 
2432 ```python Python
2533 import atexit
2634 import concurrent.futures
from line 286
278286The 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.
279287 
280288<CodeGroup exclude="shell:cURL, shell:CLI">
289 <CodeGroupItem language="cURL">
290 Define the reminders in code.
291 </CodeGroupItem>
292 
293 <CodeGroupItem language="CLI">
294 Define the reminders in code.
295 </CodeGroupItem>
296 
281297 ```python Python
282298 MODE_ENTER = (
283299 "Orchestration mode is on: optimize for the most exhaustive, correct answer rather than "
from line 391
375391The 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.
376392 
377393<CodeGroup exclude="shell:cURL, shell:CLI">
394 <CodeGroupItem language="cURL">
395 Define the tools in code.
396 </CodeGroupItem>
397 
398 <CodeGroupItem language="CLI">
399 Define the tools in code.
400 </CodeGroupItem>
401 
378402 ```python Python
379403 WORKFLOW_TOOL = {
380404 "name": "Workflow",
from line 896
872896The 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.
873897 
874898<CodeGroup exclude="shell:cURL, shell:CLI">
899 <CodeGroupItem language="cURL">
900 Run the requested command in code.
901 </CodeGroupItem>
902 
903 <CodeGroupItem language="CLI">
904 Run the requested command in code.
905 </CodeGroupItem>
906 
875907 ```python Python
876908 # Run bash where the example was launched. In DOC_TEST_MODE the docs harness
877909 # points it at a throwaway fixture directory instead, removed on exit.
from line 1443
14111443Each 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.
14121444 
14131445<CodeGroup exclude="shell:cURL, shell:CLI">
1446 <CodeGroupItem language="cURL">
1447 The full example needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
1448 </CodeGroupItem>
1449 
1450 <CodeGroupItem language="CLI">
1451 The full example needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
1452 </CodeGroupItem>
1453 
14141454 ```python Python
14151455 def run_subagent(model: str, prompt: str) -> str:
14161456 """One subagent: a small nested agent loop with the bash tool plus report_findings.
from line 1995
19551995A fan-out that spawns dozens of subagents is expensive to restart from the beginning. 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 completed are recomputed. The journal deduplicates across runs, not within a single fan-out wave; delete the journal file to start fresh.
19561996 
19571997<CodeGroup exclude="shell:cURL, shell:CLI">
1998 <CodeGroupItem language="cURL">
1999 Read and write the journal in code.
2000 </CodeGroupItem>
2001 
2002 <CodeGroupItem language="CLI">
2003 Read and write the journal in code.
2004 </CodeGroupItem>
2005 
19582006 ```python Python
19592007 _journal_lock = threading.Lock()
19602008 
from line 2294
22462294The 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 completes, a second wave reuses the same subagent path to attempt 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.
22472295 
22482296<CodeGroup exclude="shell:cURL, shell:CLI">
2297 <CodeGroupItem language="cURL">
2298 The full example needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
2299 </CodeGroupItem>
2300 
2301 <CodeGroupItem language="CLI">
2302 The full example needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
2303 </CodeGroupItem>
2304 
22492305 ```python Python
22502306 def normalize_subtasks(raw) -> list[str]:
22512307 """Accept the subtasks input in whatever shape the model emits: an array, the array
from line 3838
37823838</Warning>
37833839 
37843840<CodeGroup exclude="shell:cURL, shell:CLI">
3841 <CodeGroupItem language="cURL">
3842 The full example needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
3843 </CodeGroupItem>
3844 
3845 <CodeGroupItem language="CLI">
3846 The full example needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
3847 </CodeGroupItem>
3848 
37853849 ```python Python
37863850 if __name__ == "__main__":
37873851 task = (
Feedback