FuncSchema in src/agents/function_schema.py captures the JSON schema and Pydantic model for a Python function's parameters, and is the data structure used to present a Python function to an LLM as a tool.[1] FuncSchema.takes_context marks whether the function's first argument is a RunContextWrapper; to_call_args skips that first parameter when building the positional args list.[1] FuncSchema.return_annotation stores the resolved return annotation including Annotated metadata, defaulting to inspect.Signature.empty when no annotation is present.[1] FuncSchema in src/agents/function_schema.py raises an error at schema-construction time when a variadic tool argument (e.g., *args) is annotated with a fixed-length tuple type (e.g., tuple[int, str]), preventing schema misrepresentation and runtime failures from malformed JSON Schema.
FuncSchema.strict_json_schema defaults to True; the SDK strongly recommends keeping it True because strict mode increases the likelihood of the LLM producing correctly-structured JSON input for the tool.[1]
FuncSchema.to_call_args reads parameter values from object.__getattribute__(data, "__dict__") before falling back to getattr, so that Pydantic properties like model_extra and model_fields_set cannot shadow tool parameters of the same name.[1] FuncSchema.to_call_args raises ModelBehaviorError when a **kwargs payload contains a key that also names a POSITIONAL_OR_KEYWORD or KEYWORD_ONLY parameter, because such a key would either replace a validated value or cause a Python "got multiple values for argument" error.[1] Positional-only parameters and *args are deliberately not reserved when checking **kwargs collisions in FuncSchema._raise_on_var_keyword_collisions: for def f(a, /, **kw), the call f(1, a=2) is legal and routes a=2 into kw.[1]
_detect_docstring_style in src/agents/function_schema.py heuristically scores a docstring for sphinx, numpy, and google styles using regex patterns; in a tie, priority is sphinx > numpy > google. When no patterns match, it defaults to "google".[1] The _GOOGLE_SECTION_HEADER_RE regex in src/agents/function_schema.py matches the aliases args, arguments, params, parameters (case-insensitive) as full-line Google parameter section headers, anchored at column 0.[1] _ensure_blank_line_before_google_sections in src/agents/function_schema.py inserts a blank line before a Google-style Args: (or alias) section header when one is missing, working around a griffe parser bug that silently drops parameter descriptions in that case. The original string object is returned unchanged when no insertion is needed.[1]
Sources