Skip to content

feat(cookbook): migrate the project recipes to the v2 API#207

Merged
seanbrar merged 1 commit into
mainfrom
feat/cookbook-v2-migration
Jun 16, 2026
Merged

feat(cookbook): migrate the project recipes to the v2 API#207
seanbrar merged 1 commit into
mainfrom
feat/cookbook-v2-migration

Conversation

@seanbrar

Copy link
Copy Markdown
Owner

Summary

Un-shelve the 5 cookbook/projects/* recipes, which were frozen v1-shaped during
the v2 cutover (they imported the removed Options/create_cache and used dict
tools and envelope mutation). They now use the v2 surface throughout, so the
clone-and-run teaching artifacts work again.

Related issue

None

Test plan

  • just check414 passed (ruff format/lint, rumdl, mypy, pytest).
  • tests/test_cookbook_contract.py12 passed, including
    test_all_recipes_run_in_mock_mode (every recipe, now including the 5 projects)
    and the 5 project helper tests that were previously skipped.
  • Both tool-loop recipes reviewed by hand for the interact() continuation pattern.

Notes

What changed per recipe:

  • Options(...) → first-class kwargs (output= / tools= / tool_choice= /
    environment=).
  • create_cache(...)prepare_environment() /
    Environment(cache=CachePolicy(ttl_seconds=...)).
  • ResultEnvelope dict access → Output / OutputCollection facets.
  • dict tool definitions → ToolDeclaration.
  • pokedex-analyst and treasure-tailor move to the interact() tool loop:
    Environment(tools=[...]) → read out.tool_calls
    ToolResult(call_id=tc.id, ...)interact(Input(continuation=..., tool_results=...)).

Shared cookbook/utils/runtime.py drops the ResultEnvelope alias; merged_usage
now sums Output.usage into a Usage, and print_usage accepts that Usage
directly. The SHELVED_V2 gate is lifted and the now-vestigial
_shelved_project_recipe decorator removed so the project helper tests run again.

Un-shelve the 5 cookbook/projects/* recipes, which were frozen v1-shaped during
the v2 cutover. They now use the v2 surface throughout: Options(...) → first-class
kwargs (output=/tools=/tool_choice=/environment=), create_cache(...) →
prepare_environment()/Environment(cache=CachePolicy(...)), ResultEnvelope dict
access → Output/OutputCollection facets, and dict tools → ToolDeclaration. The two
tool recipes (pokedex-analyst, treasure-tailor) move to the interact() loop:
Environment(tools=[...]) → read out.tool_calls → ToolResult(call_id=...) →
interact(Input(continuation=..., tool_results=...)).

Shared cookbook/utils/runtime.py drops the ResultEnvelope alias and merged_usage
now sums Output.usage into a Usage; print_usage accepts that Usage directly.

Lift the SHELVED_V2 gate and remove the now-vestigial _shelved_project_recipe
decorator so the 5 project helper tests run again. All recipes run clean in mock
mode; the 12 cookbook contract tests pass.
@seanbrar seanbrar merged commit 67eebe4 into main Jun 16, 2026
6 of 8 checks passed
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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