Skip to content

Add: minimal tool-use agent loop notebook#688

Open
mnifzied-create wants to merge 1 commit into
anthropics:mainfrom
mnifzied-create:add-minimal-agent-loop
Open

Add: minimal tool-use agent loop notebook#688
mnifzied-create wants to merge 1 commit into
anthropics:mainfrom
mnifzied-create:add-minimal-agent-loop

Conversation

@mnifzied-create

Copy link
Copy Markdown

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 single tool_result user turn, and repeat until stop_reason is no longer tool_use.

Why

The existing tool_use/ notebooks show specific tools and full agents, and claude_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, one tool_result per request matched by tool_use_id, all results in a single user message, and a max_turns safety belt.

Quality

  • Current model id (claude-sonnet-4-6); code-cell outputs left empty for CI execution.
  • Loop logic mock-verified end-to-end (multiple tool_use blocks in one turn, correct id matching, clean termination on end_turn).
  • ruff check / ruff format --check clean; nbformat valid; registry.yaml + authors.yaml validate against the repo schemas.

Happy to adjust placement, scope, or framing — thank you for considering it!

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant