featherweight.models¶
models ¶
Typed contracts for agents: the definition, its input/output base classes, and the run result.
AgentInput ¶
Bases: BaseModel
Base for an agent's input. Agent-specific fields go on subclasses.
AgentOutput ¶
Bases: BaseModel
Base for an agent's structured output.
Subclasses add their task fields, which should be optional (or allow empty values) so that a model that needs to ask a question is not forced to invent an answer to pass validation.
AgentBase ¶
Bases: BaseModel
Static definition of an agent. Each agent is a subclass; the runner instantiates it. The subclass may be written in code or built from data when it is needed; either way it is complete and validated before it runs.
Pydantic v2 rejects overriding an inherited field with an unannotated attribute, so subclasses re-annotate the fields they override.
has_discovery
property
¶
has_discovery: bool
Whether any MCP server of the agent is found by search, so that the runner adds search_tools and
call_tool.
tool_names
property
¶
tool_names: list[str]
What the run log stores; tool objects are not serialisable.
system_prompt_hash
property
¶
system_prompt_hash: str
SHA-256 of the assembled system prompt; what the run log records.
background_entry ¶
background_entry(name: str) -> type | None
The agent or job class called name in background_jobs, or None.
check_output ¶
check_output(
agent_input: AgentInput, output: AgentOutput
) -> None
Check the output against the input, for rules the output schema alone cannot express.
Raise ValueError to reject the output: the runner counts that as a failed attempt and retries.
The default accepts everything.
subagent_instance ¶
subagent_instance(name: str) -> AgentBase | None
The allowed sub-agent called name, as a fresh instance, or None.
build_system_prompt ¶
build_system_prompt(
*, can_launch: bool = True, can_background: bool = True
) -> str
The prompt plus the conditional instructions derived from the two flags.
With sub-agents, and unless can_launch is False (the runner sets it where the depth limit leaves the agent
no launch tool), the prompt also lists the agents it may launch, by name and description. Their input
schemas are not in the prompt: the agent asks for them with get_agent_schema.
With background_jobs (and unless can_background is False) each agent is listed once, in a group: the ones to
launch and wait for, the ones to start in the background, and the ones that can be either.
AgentResult ¶
Bases: BaseModel, Generic[OutT]
What a run of an agent returns (AgentRunner.run). The runner's status is kept separate from the model's output.