Files
Long Chen 28e68c52d6 agents: Agent[Deps, State, Output] from deps_type, state_type and output_type
Agent took deps_type and state_type but nothing read them: the
framework loads state with the door's type, and a type checker could
not use them because Agent was not generic. run() took Any and returned
RunResult[Any], so a wrong state or deps object and a typo on a
structured output all passed the type checker.

Agent is now generic, the three parameters read from those arguments
and Any when one is left out, so a bare Agent annotation and a subclass
keep working. run(), stream(), @agent.instructions and
@agent.output_validator carry the types, and agent.run(state=ctx.state)
checks the door's state type against the agent's.

tests/type_checks/agent_generics.py pins this: each expected error has
a type: ignore[code], and scripts/check_types.py checks the package, so
it fails both when a check is lost and when a new error appears.
2026-10-14 14:44:21 +08:00
..