Skip to content

Conversation

wdoppenberg
Copy link

@wdoppenberg wdoppenberg commented Aug 15, 2025

This started with just adding generics for state or forwarded_props related attributes, but I also changed poetry in favour of uv. I realize this might be overreaching a little bit, so let me know if you want this rolled back.

Inspired by the generics used in pydantic-ai, now e.g. RunAgentInput is as follows:

class RunAgentInput(ConfiguredBaseModel, Generic[StateT, FwdPropsT]):
    """
    Input for running an agent.
    """

    thread_id: str
    run_id: str
    state: StateT
    messages: List[Message]
    tools: List[Tool]
    context: List[Context]
    forwarded_props: FwdPropsT

With generic types:

JSONValue = Union[str, int, float, bool, None, dict[str, Any], list[Any]]
StateT = TypeVar("StateT", default=JSONValue, contravariant=True)
FwdPropsT = TypeVar("FwdPropsT", default=JSONValue, contravariant=True)

This makes it integrate better with type checking in applications / libraries that use these types.

Please raise any worries or thoughts if you have them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant