mirror of
https://github.com/livekit/agents.git
synced 2026-12-04 05:08:55 +00:00
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.