Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: use InjectedStore in semantic search guide #2995

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

jsambuo
Copy link
Contributor

@jsambuo jsambuo commented Jan 11, 2025

When I tried to follow the How-to guide for How to add semantic search to your agent's memory using create_react_agent, I got this error message when my agent used the tool:

1 validation error for upsert_memory
store
  Field required [type=missing, input_value={'content': '@jimmy works...ny.', 'memory_id': None}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/missingTraceback (most recent call last):

  File "/usr/local/lib/python3.9/site-packages/langchain_core/tools/base.py", line 688, in run
    tool_args, tool_kwargs = self._to_args_and_kwargs(tool_input, tool_call_id)

  File "/usr/local/lib/python3.9/site-packages/langchain_core/tools/base.py", line 611, in _to_args_and_kwargs
    tool_input = self._parse_input(tool_input, tool_call_id)

  File "/usr/local/lib/python3.9/site-packages/langchain_core/tools/base.py", line 532, in _parse_input
    result = input_args.model_validate(tool_input)

  File "/usr/local/lib/python3.9/site-packages/pydantic/main.py", line 627, in model_validate
    return cls.__pydantic_validator__.validate_python(

pydantic_core._pydantic_core.ValidationError: 1 validation error for upsert_memory
store
  Field required [type=missing, input_value={'content': '@jimmy works...ny.', 'memory_id': None}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/missing

I believe it’s because the graph did not inject the store into the tool if we use InjectedToolArg.

When looking at the guide for How to pass runtime values to tools, it suggests to use InjectedStore with create_react_agent. After changing my code to use InjectedStore, my agent was able to save to the store.

When trying the tutorial for `How to add semantic search to your agent's memory`, I got a `1 validation error for upsert_memory` error. After changing my code to use `InjectedStore`, my agent was able to save to the store.
@vbarda vbarda merged commit d7199e5 into langchain-ai:main Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants