Implement #7: Advanced Agent Patterns#43
Merged
Conversation
Chapter 7 plus its examples/07-advanced-patterns/ samples: the autonomous
loop with a maxSteps budget and token tracking, extended thinking
(thinking: { type: 'adaptive' }) reading thinking blocks, a reflection
pass via a plain user turn, structured output via a forced tool, error
recovery (RateLimitError backoff + is_error results), and a coordinator
delegating subtasks to a helper subagent. Wired into the sidebar and
README.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
14 tasks
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.
Closes #7
Chapter 7 adds the advanced patterns on top of the Chapter 5/6 loop: a budgeted autonomous loop, extended thinking, self-critique, structured output, error recovery, and subagent orchestration. Authored single-pass; the cutoff-sensitive
thinkingshape was verified against the installed SDK and a live probe.Definition of done
chapters/07-advanced-patterns.md,<=120lines,<=4main-line H2s plus a closerbun run, imported via<<< @/examples/07-advanced-patterns/file.tsuser-turn gotcha and the thinking shape live in prose, not code comments); reader addressed as "you"; intro + sections open warm@anthropic-ai/sdksurface; ASCII punctuation only:::detailsasides, not main-line H2sREADME.mdand the.vitepress/config.tssidebar;bun x vitepress buildpassesthinkingparameter shape verified - see below24-66lines, above the issue's stated<=35(skill budget is<=100)thinkingshape verification (cutoff-sensitive)Checked against the installed
@anthropic-ai/sdk.d.tsand a live probe on the gateway:ThinkingConfigParam = { type: 'adaptive', display? } | { type: 'enabled', budget_tokens, display? } | { type: 'disabled' }ThinkingBlock = { signature: string; thinking: string; type: 'thinking' }thinking: { type: 'adaptive' }-> returned[thinking, text]blocks (2803 thinking chars, signature present);{ type: 'enabled', budget_tokens: 1024 }also works.adaptive(current form); an:::infocallout documents theenabled/budget_tokensform for models 4.6 and earlier.Verification (run live)
Chapter budget:
wc -l-> 69;grep -c '^## '-> 4.tsc --noEmitclean;vitepress buildpasses (all six snippets resolve). Each sample run:tool_use->end_turn), prints running token total, answers correctly.[thinking]block (the bat-and-ball riddle reasoning) printed separately from[answer].usercritique turn -> revised tagline.emit_resultreturnedlabel: positive, confidence: 0.95(the gateway honored forcing for this tool-eliciting prompt).notes.txt(ok) andconfig.txt(is_error-> missing); the model recovered and reported both.summarize_textcall dispatched to thesummarize()helper subagent (its owncreate), returning the one-sentence summary.Notes
extended-thinking.tsenablesthinking, keeping it clear of the forced-tool_choiceand thinking-block-preservation constraints that apply when thinking is combined with tools.<=35.Review flags
None.
🤖 Generated with Claude Code