Add: minimal tool-use agent loop notebook#688
Open
mnifzied-create wants to merge 1 commit into
Open
Conversation
A from-scratch teaching notebook for the core tool-use loop (call the model, run the tools it requests including several per turn, feed results back, repeat until end_turn) with the Anthropic SDK. Mock-verified; ruff + nbformat + registry/authors schemas pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What this adds
A from-scratch teaching notebook —
tool_use/minimal_agent_loop.ipynb— that implements the core tool-use agent loop by hand with the Anthropic SDK: call the model, run the tool(s) it requests (including several in one turn), feed the results back as a singletool_resultuser turn, and repeat untilstop_reasonis no longertool_use.Why
The existing
tool_use/notebooks show specific tools and full agents, andclaude_agent_sdk/covers higher-level agents — but there isn't a minimal, framework-free walkthrough of the loop itself, the concept every agent is built on. This fills that gap in ~30 readable lines, with markdown on the four details people most often get wrong: appending the assistant turn verbatim, onetool_resultper request matched bytool_use_id, all results in a single user message, and amax_turnssafety belt.Quality
claude-sonnet-4-6); code-cell outputs left empty for CI execution.end_turn).ruff check/ruff format --checkclean;nbformatvalid;registry.yaml+authors.yamlvalidate against the repo schemas.Happy to adjust placement, scope, or framing — thank you for considering it!