WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a2380fe

Browse files
committed
docs: Add prominent warning about state_schema requirement for custom fields
- Fix TypedDict extension example: remove redefined messages field - Improve security: replace password field with user_id in example - Simplify example by removing unnecessary imports - Fix docstring formatting: remove extra blank lines in Example section
1 parent 5f52e65 commit a2380fe

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

libs/langchain_v1/langchain/agents/factory.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -630,14 +630,11 @@ def create_agent( # noqa: PLR0915
630630
Example:
631631
632632
```python
633-
from typing import Annotated
634633
from langchain.agents import AgentState, create_agent
635-
from langgraph.graph import add_messages
636634
637635
class MyState(AgentState):
638-
messages: Annotated[list, add_messages]
639636
authenticated: bool
640-
password: str
637+
user_id: str
641638
642639
agent = create_agent(
643640
model=model,
@@ -692,12 +689,10 @@ class MyState(AgentState):
692689
```python
693690
from langchain.agents import create_agent
694691
695-
696692
def check_weather(location: str) -> str:
697693
'''Return the weather forecast for the specified location.'''
698694
return f"It's always sunny in {location}"
699695
700-
701696
graph = create_agent(
702697
model="anthropic:claude-sonnet-4-5-20250929",
703698
tools=[check_weather],

0 commit comments

Comments
 (0)