chore(py): Add Tool type, update generate call signature, remove dynamic-tools#5063
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors tool handling within the Genkit AI package, introducing a dedicated Tool class and updating various interfaces to support a Sequence[str | Tool] type for tools. It also removes the dynamic_tool method and its associated sample code. Several critical issues were identified in the review: the resolve_tool function is imported but not defined in the provided changes, and there are multiple instances where a TypedDict (PromptGenerateOptions) is incorrectly accessed using dot notation, which will lead to runtime errors. Furthermore, the newly added unwrap_wrapped_scalar_tool_input_if_needed helper is currently unused and should be integrated into the tool execution wrapper to correctly handle wrapped payloads from model providers like Gemini.
Tool type, update generate call signature, remove dynamic-tools
Summary
define_interrupt(followup PR). Normally input_schema is inferred from the tool function, but indefine_interrupt, the Interrupt tool fn is Any (since it needs to be dynamic), while allowing the user to provide an input schema to constrain the model when it chooses to call the interrupt tool.