feat(cookbook): migrate the project recipes to the v2 API#207
Merged
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
Un-shelve the 5
cookbook/projects/*recipes, which were frozen v1-shaped duringthe v2 cutover (they imported the removed
Options/create_cacheand used dicttools 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 check→ 414 passed (ruff format/lint, rumdl, mypy, pytest).tests/test_cookbook_contract.py→ 12 passed, includingtest_all_recipes_run_in_mock_mode(every recipe, now including the 5 projects)and the 5 project helper tests that were previously skipped.
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=...)).ResultEnvelopedict access →Output/OutputCollectionfacets.ToolDeclaration.pokedex-analystandtreasure-tailormove to theinteract()tool loop:Environment(tools=[...])→ readout.tool_calls→ToolResult(call_id=tc.id, ...)→interact(Input(continuation=..., tool_results=...)).Shared
cookbook/utils/runtime.pydrops theResultEnvelopealias;merged_usagenow sums
Output.usageinto aUsage, andprint_usageaccepts thatUsagedirectly. The
SHELVED_V2gate is lifted and the now-vestigial_shelved_project_recipedecorator removed so the project helper tests run again.