When I tried to follow the How-to guide for [How to add semantic search to your agent's memory](https://langchain-ai.github.io/langgraph/how-tos/memory/semantic-search/#using-in-create_react_agent) using `create_react_agent`, I got this error message when my agent used the tool: ```python 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](https://langchain-ai.github.io/langgraph/how-tos/pass-run-time-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.
Setup
To setup requirements for building docs you can run:
poetry install --with test
Serving documentation locally
To run the documentation server locally you can run:
make serve-docs
Execute notebooks
If you would like to automatically execute all of the notebooks, to mimic the "Run notebooks" GHA, you can run:
python docs/_scripts/prepare_notebooks_for_ci.py
./docs/_scripts/execute_notebooks.sh
Note: if you want to run the notebooks without %pip install cells, you can run:
python docs/_scripts/prepare_notebooks_for_ci.py --comment-install-cells
./docs/_scripts/execute_notebooks.sh
prepare_notebooks_for_ci.py script will add VCR cassette context manager for each cell in the notebook, so that:
- when the notebook is run for the first time, cells with network requests will be recorded to a VCR cassette file
- when the notebook is run subsequently, the cells with network requests will be replayed from the cassettes
Note: this is currently limited only to the notebooks in docs/docs/how-tos
Adding new notebooks
If you are adding a notebook with API requests, it's recommended to record network requests so that they can be subsequently replayed. If this is not done, the notebook runner will make API requests every time the notebook is run, which can be costly and slow.
To record network requests, please make sure to first run prepare_notebooks_for_ci.py script.
Then, run
jupyter execute <path_to_notebook>
Once the notebook is executed, you should see the new VCR cassettes recorded in docs/cassettes directory and discard the updated notebook.
Updating existing notebooks
If you are updating an existing notebook, please make sure to remove any existing cassettes for the notebook in docs/cassettes directory (each cassette is prefixed with the notebook name), and then run the steps from the "Adding new notebooks" section above.
To delete cassettes for a notebook, you can run:
rm docs/cassettes/<notebook_name>*