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.

@tylerslaton
Copy link
Contributor

Hi @wdoppenberg would you mind rebasing so we can get this reviewed?

@wdoppenberg wdoppenberg force-pushed the feature/python-generics branch from 4757153 to 99f5e68 Compare September 18, 2025 06:09
…nerics

# Conflicts:
#	python-sdk/ag_ui/core/events.py
#	typescript-sdk/apps/dojo/e2e/featurePages/AgenticChatPage.ts
#	typescript-sdk/apps/dojo/e2e/featurePages/SharedStatePage.ts
#	typescript-sdk/apps/dojo/e2e/featurePages/ToolBaseGenUIPage.ts
#	typescript-sdk/apps/dojo/e2e/tests/crewAITests/predictiveStateUpdatePage.spec.ts
#	typescript-sdk/apps/dojo/e2e/tests/langgraphFastAPITests/predictiveStateUpdatePage.spec.ts
#	typescript-sdk/apps/dojo/e2e/tests/langgraphTests/predictiveStateUpdatePage.spec.ts
#	typescript-sdk/apps/dojo/e2e/tests/pydanticAITests/predictiveStateUpdatePage.spec.ts
#	typescript-sdk/apps/dojo/e2e/tests/serverStarterAllFeaturesTests/predictiveStateUpdatePage.spec.ts
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.

2 participants