langchain
4065106c - fix(langchain): add types to human_in_the_loop middleware (#34137)

Commit
38 days ago
fix(langchain): add types to human_in_the_loop middleware (#34137) The `HumanInTheLoopMiddleware` is missing a type annotation for the context schema. Without the fix in this PR, the following code does not type check: ``` graph = create_agent( "gpt-5", tools=[send_email_tool, read_email_tool], middleware=[ HumanInTheLoopMiddleware( interrupt_on={ # Require approval or rejection for sending emails "send_email_tool": { "allowed_decisions": ["approve", "reject"], }, # Auto-approve reading emails "read_email_tool": False, } ), ], context_schema=ContextSchema, ) ``` ``` Argument of type "list[HumanInTheLoopMiddleware]" cannot be assigned to parameter "middleware" of type "Sequence[AgentMiddleware[StateT_co@create_agent, ContextT@create_agent]]" in function "create_agent" "HumanInTheLoopMiddleware" is not assignable to "AgentMiddleware[AgentState[Unknown], ContextSchema | None]" Type parameter "ContextT@AgentMiddleware" is invariant, but "None" is not the same as "ContextSchema | None" ```
Author
Parents
Loading