Field
Field declares one thing an operation or a lookup takes
from the caller. Declare it as a class attribute on an Operation subclass; the
attribute name is the tool argument’s name. Field is a frozen dataclass.
A field whose value is missing, None, an empty string, or the text "not said"
(the NOT_SAID constant, any case) counts as not given: values.<name> is None.
Parameters
kind
The value’s type: str, int, float, bool, a Literal, list[...],
dict[str, ...], a TypedDict, or a JSON schema dict. Any other type raises
TypeError when the schema is built.
description
What it is, in the caller’s terms. The model reads it.
required
Whether the operation needs it.
ask
The question for the caller when it’s missing. With ask, a required field the model
sends empty, null, or as "not said" is asked for before prepare() runs, so the
model isn’t pushed to invent a value. A field with a fixed choice of values gets
"not said" as an extra option.
Methods
schema() returns the field’s JSON schema, with its description.