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

create_react_agent with store #2875

Open
4 tasks done
hwchase17 opened this issue Dec 25, 2024 · 1 comment
Open
4 tasks done

create_react_agent with store #2875

hwchase17 opened this issue Dec 25, 2024 · 1 comment

Comments

@hwchase17
Copy link
Contributor

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

def _prep_messages(state, config, store):
            # For store usage
            _prompt = None
            if store is not None:
                namespace = (config['configurable'][configurable_by],)
                result = store.get(namespace, "info")
                if "data" in result:
                    _prompt = result["data"]

            if _prompt is None:
                _prompt = system_prompt
            _system_message = SystemMessage(content=_prompt)
            return [_system_message] + state["messages"]

Error Message and Stack Trace (if applicable)

asyncio.exceptions.InvalidStateError: Synchronous calls to BatchedStore detected in the main event loop. This can lead to deadlocks or performance issues. Please use the asynchronous interface for main thread operations. Specifically, replace `store.get(...)` with `await store.aget(...)

Description

I'm trying to use store with create_react_agent. But it wont let me pass in a function that uses store in sync manner. and if i change to async function, create_react_agent doesn't accept it

System Info

(multi-agent-testing) ➜ multi-agent-testing git:(main) ✗ python -m
langchain_core.sys_info

System Information

OS: Darwin
OS Version: Darwin Kernel Version 22.3.0: Thu Jan 5 20:50:36 PST 2023; root:xnu-8792.81.2~2/RELEASE_ARM64_T6020
Python Version: 3.11.7 (main, Nov 16 2024, 15:15:25) [Clang 14.0.0 (clang-1400.0.29.202)]

Package Information

langchain_core: 0.3.28
langchain: 0.3.8
langchain_community: 0.3.8
langsmith: 0.1.146
langchain_anthropic: 0.3.0
langchain_openai: 0.2.9
langchain_text_splitters: 0.3.2
langgraph_api: 0.0.14
langgraph_cli: 0.1.65
langgraph_license: Installed. No version info available.
langgraph_sdk: 0.1.48
langgraph_storage: Installed. No version info available.

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.11.7
anthropic: 0.39.0
async-timeout: Installed. No version info available.
click: 8.1.8
cryptography: 43.0.3
dataclasses-json: 0.6.7
defusedxml: 0.7.1
httpx: 0.27.2
httpx-sse: 0.4.0
jsonpatch: 1.33
jsonschema-rs: 0.25.1
langgraph: 0.2.60
langgraph-checkpoint: 2.0.9
numpy: 1.26.4
openai: 1.55.1
orjson: 3.10.12
packaging: 24.2
pydantic: 2.10.2
pydantic-settings: 2.6.1
pyjwt: 2.10.1
python-dotenv: 1.0.1
PyYAML: 6.0.2
requests: 2.32.3
requests-toolbelt: 1.0.0
SQLAlchemy: 2.0.35
sse-starlette: 2.1.3
starlette: 0.42.0
structlog: 24.4.0
tenacity: 8.5.0
tiktoken: 0.8.0
typing-extensions: 4.12.2
uvicorn: 0.34.0
watchfiles: 1.0.3

@hwchase17
Copy link
Contributor Author

this happened when trying to use it in the studio

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

No branches or pull requests

1 participant