Back to catalog / Agent workflows
Validate a note tool call before saving
Use Pydantic models to reject malformed note and author fields before a persistence adapter receives them.
Goal
Use Pydantic models to reject malformed note and author fields before a persistence adapter receives them.
Steps
- Define
Author,Note, andSaveNoteResponsemodels; constrain priority to 1–5 and validate the email field. [source01] - Parse the
save_notetool input intoNotebefore calling the storage adapter; convert validation failures into a bounded tool error. [source01] - Test valid, missing-author, malformed-email, and out-of-range-priority calls; only the valid case reaches persistence. [source01]
How to verify
Send one valid note and three invalid payloads; confirm only the valid call reaches the persistence adapter and the other three return bounded validation errors.
Troubleshooting
If a malformed note is saved, move Pydantic parsing ahead of the adapter call; inspect the rejected field and ensure the error response contains no raw traceback.
Permissions
Prerequisites
- Python 3.10+, Anthropic API key, Pydantic, and an isolated test storage adapter.
Permissions
- Use approved test or anonymized data only; scope credentials to each workflow, and require explicit approval for external writes.
Limitations
Model output may be incomplete or wrong; API and beta behavior can change, so verify against the pinned source and current service behavior.
Pinned upstream source
- Repository
- anthropics/anthropic-cookbook
- File path
- tool_use/tool_use_with_pydantic.ipynb
- Pinned commit
9c1e493ddd2b82df399d2a61b9c806c539e18be6- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT
Main topic
Turn ecommerce campaign materials into a reviewable weekly brief