Skip to content

Conversation

@cbornet
Copy link
Collaborator

@cbornet cbornet commented Dec 12, 2025

CompiledStateGraph's StateT and OutputT are useless for the caller of create_agent.
So we can replace them by Any and this make mypy able to correctly infer the typing.

NB: it would be nice to change the signature of CompiledStateGraph to a Generic[ContextT, InputT] in LangGraph since it does not use StateT and OutputT.

@github-actions github-actions bot added langchain `langchain` package issues & PRs infra PRs made that include chores, devops, repo meta changes labels Dec 12, 2025
@cbornet cbornet force-pushed the simplify-create_agent branch from a33913e to 1b1d5fe Compare December 12, 2025 13:12
@sydney-runkle
Copy link
Collaborator

sydney-runkle commented Dec 12, 2025

NB: it would be nice to change the signature of CompiledStateGraph to a Generic[ContextT, InputT] in LangGraph since it does not use StateT and OutputT.

I don't think this makes sense, we do use OutputT on invocation results, and StateT is helpful when defining node functions...

edit - I see what you mean re caller of create_agent, but not for OutputT...

@cbornet cbornet force-pushed the simplify-create_agent branch from d9a255b to 91ba781 Compare December 12, 2025 17:50
@cbornet cbornet force-pushed the simplify-create_agent branch from 91ba781 to f8037a0 Compare December 12, 2025 17:54
@sydney-runkle
Copy link
Collaborator

Should we go ahead and make the input and output types public here?

@sydney-runkle sydney-runkle self-assigned this Dec 12, 2025
@sydney-runkle sydney-runkle added the waiting-on-author Issue or PR is paused, waiting to hear from author in order to proceed label Dec 12, 2025
@cbornet
Copy link
Collaborator Author

cbornet commented Dec 13, 2025

Should we go ahead and make the input and output types public here?

Done. This also removed 2 ruff warnings 😃

) -> CompiledStateGraph[
AgentState[ResponseT], ContextT, _InputAgentState, _OutputAgentState[ResponseT]
]:
) -> CompiledStateGraph[Any, ContextT, InputAgentState, Any]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
) -> CompiledStateGraph[Any, ContextT, InputAgentState, Any]:
) -> CompiledStateGraph[AgentState[ResponseT], ContextT, InputAgentState, OutputAgentState[ResponseT]]

Does this hurt?

Copy link
Collaborator Author

@cbornet cbornet Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this hurt?

Yes, because if we do that, mypy can't infer the type of the create_agent call and the caller has to define it explicitly. It's the goal of this PR to remove these types so that mypy can do the inference.
Those generics (StateT and OutputT) are not used anyway in CompiledStateGraph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra PRs made that include chores, devops, repo meta changes langchain `langchain` package issues & PRs waiting-on-author Issue or PR is paused, waiting to hear from author in order to proceed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants