Solution skill
Diagnose: custom agent state rejected by create_agent in v1
Complete solution
Shows how to fix diagnose: custom agent state rejected by create_agent in v1. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
create\_agent rejects your custom state schema, or state updates behave unexpectedly. If tools need to write it, return state updates from the tool (see the agent-with-memory workflow).
Steps
- v1 narrowed custom state to TypedDict only, defined via
state_schemaor middleware. Pydantic models and other schema styles from older patterns are not accepted.
from langchain.agents import create_agent, AgentState
class CustomState(AgentState):
user_name: str
agent = create_agent(model="...", tools=[...], state_schema=CustomState)- 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).
When to use
You are seeing this: Look at your state definition. Use this skill when you run into "Diagnose: custom agent state rejected by create_agent in v1".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
v1 narrowed custom state to TypedDict only, defined via state\_schema or middleware.
Evidence
Diagnostic procedure grounded in the official v1 migration guide (custom state), verified 2026-09-26. Migration guide: docsgchain.com/oss/python/migrate/langchain-v1
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
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>