The high-level create_agent utility accepts a _InputAgentState that types messages as list[AnyMessage | dict[str, Any]]. Because Python's list is invariant, a MessagesState with messages: list[AnyMessage] is not assignable, causing static type checkers to reject valid runtime code.
Origin Analysis
In libs/langchain_v1/langchain/agents/middleware/types.py, _InputAgentState defines messages as an invariant list containing a union of AnyMessage and dict[str, Any]. Since list is invariant, a list of only AnyMessage (as in MessagesState) is not recognized as a subtype, even though it is semantically valid.
1. Import create_agent and MessagesState.
2. Create an agent with create_agent(model='openai:gpt-4o-mini', system_prompt='You are a personalized assistant. Just say hi.').
3. Call agent.invoke(MessagesState(messages=[HumanMessage(content="What's your name?")])).
4. Observe the type error: Argument of type "MessagesState" cannot be assigned to parameter "input" of type "_InputAgentState | Command[Unknown] | None".
Edge Case Audit
This is a type-only change and does not affect runtime behavior. However, if downstream code relies on the concrete list type (e.g., using list-specific methods on the messages attribute), static analysis may now treat it as Sequence, which lacks methods like append. This is unlikely in read-only contexts but if such usage exists, additional casts or protocol adjustments may be needed. No rollback is required as the change is purely additive for type checking.