airflow.providers.common.ai.utils.tool_definition¶
Version-tolerant helpers for building pydantic-ai ToolDefinition objects.
Functions¶
|
Return |
|
Mark a tool as a code-execution surface whose |
|
Build an argument validator from the schema advertised to the model. |
Module Contents¶
- airflow.providers.common.ai.utils.tool_definition.return_schema_kwargs(schema)[source]¶
Return
{"return_schema": schema}when pydantic-ai supports the field, else{}.return_schemalets CodeMode (the Monty sandbox) render a typed function signature for a tool (-> str) instead of-> Any, which helps the model write correct code. It has no effect outside code mode.
- airflow.providers.common.ai.utils.tool_definition.code_arg_kwargs(arg_name, language)[source]¶
Mark a tool as a code-execution surface whose
arg_nameargument holds code.Two consumers read this metadata. Instrumentation renders the argument as code in traces, tagged with
language. More importantly, CodeMode uses it to decide which tools stay native: a tool that itself executes code must not be folded intorun_code, because the model would then have to write a script whose argument is a second script quoted as a string. Without the marker, a sandbox tool is folded in and the generated orchestration runs in-process on the worker – the opposite of what a sandbox tool is for.Returns
{}when the installed pydantic-ai predatesToolDefinition.metadata, matchingreturn_schema_kwargs().