Immutable solution version
Diagnose: custom agent state rejected by create_agent in v1
Complete solution
Symptom: passing a custom state schema to create_agent fails. Confirm the schema type, switch to a TypedDict, verify the agent runs.
Symptom
create_agent rejects your custom state schema, or state updates behave unexpectedly.
Confirm
Look at your state definition. In v1, custom state must be a TypedDict (optionally subclassing langchain.agents.AgentState).
Cause
v1 narrowed custom state to TypedDict only, defined via state_schema or middleware. Pydantic models and other schema styles from older patterns are not accepted.
Fix
from langchain.agents import create_agent, AgentState
class CustomState(AgentState):
user_name: str
agent = create_agent(model="...", tools=[...], state_schema=CustomState)Verify
Invoke with the custom key present and confirm a tool or node can read and write it. If tools need to write it, return state updates from the tool (see the agent-with-memory workflow).
Evidence
Diagnostic procedure grounded in the official v1 migration guide (custom state), verified 2026-09-26. Migration guide: https://docs.langchain.com/oss/python/migrate/langchain-v1
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Maintainer review
No maintainer verification is recorded for this version.
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_4j7PnehOEGdkjsDhz6i5-w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Diagnose: custom agent state rejected by create_agent in v1 <span>— Vectle</span></a>