Python SDK v0.6.0 Release Notes
This release bumps the Genkit Python SDK to version 0.6.0.
New Features
- Dynamic Tools: Add support for dynamically defined tools (#5214). This is extremely helpful in cases where tools need to be defined dynamically through a closure, such as user-specific tools.
- Tool Restarts: When a flow is interrupted, there is a path now for app developers to restart the interrupted tool with some updated input, and continue the generate loop (#5069). With this new SDK feature you can easily support tools that need approval before executing.
- Add interrupt metadata, so when you run your interrupt flow locally, you can see a transparent trace that shows tool with a special interrupt callout in Dev UI (#5260).
Existing API Changes
-
Breaking change:
ctx.Interrupt()usage changed toraise Interrupt.
Previously, to interrupt the execution flow from within a tool and hand control back to the user, the recommended pattern was to define your tool function with an optionalctxargument, and callctx.Interrupt()from within that tool. We changed the pattern such that you now callraise Interruptto break out of the regular execution flow, like any normal Python exception. -
Breaking change: When executing prompts, options have been flattened into standard Python keyword arguments. In your Genkit code, if you invoke prompts with custom configuration defined in code, you will need to migrate your usage code such that
configis named as an explicit kwarg.
# OLD (v0.5.2):
response = await my_prompt(input_data, {'config': {'temperature': 0.7}})
# NEW (v0.6.0):
response = await my_prompt(input_data, config={'temperature': 0.7})- Non-breaking change: Decorator @ai.tool returns a Tool wrapper instead of the raw function.
In v0.5.2, decorating a function with @ai.tool registered the action behind the scenes, but returned the original raw Python function. In v0.6.0, decorating a function with @ai.tool now returns a wrapper instance of the Tool class. This change shouldn't require any migration on your end for typical Genkit usage.
Bug Fixes & Refactoring
- Code Execution: Fix code execution serialization issue for googleai plugin (#5326).
- Async Safety: Make plugin init state loop-local to fix cross-loop Task error (#5262).
- Telemetry: Fix double generate span in model runner (#5113).
- Validation: Enforce object root JSON Schema for tool inputs at
define_tool(#5059) and parallelize tool calls in generate loop (#5054). - Dependencies & Configuration: Fix pyproject.toml on
fastapiplugin (#5030) and bumpmistunedependency (#5289). - Repository URL Migration: Update repository URLs and references from
firebase/genkittogenkit-ai/genkit(#5155). - Samples: Update samples to use
gemini-*latest(#5328). - Reflection Server v2: Implement reflection server v2 support (#5186). Hidden behind flag.
- Expose ActionRunContext in Dev UI correctly.: Before it was propagating correctly but not showing up in the Dev UI, now it is (#5364).
- Observability & Spans: Unify span creation through
run_in_new_span+ hand-writeSpanMetadata(#5311).