{"record":{"id":"6d40bab28e0bb079","repo":"langchain-ai/langgraph","slug":"async-model-callable-provided-but-agent-invoked-sy","errorCode":null,"errorMessage":"Async model callable provided but agent invoked synchronously. Use agent.ainvoke() or agent.astream(), or provide a sync model callable.","messagePattern":"Async model callable provided but agent invoked synchronously\\. Use agent\\.ainvoke\\(\\) or agent\\.astream\\(\\), or provide a sync model callable\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py","lineNumber":670,"sourceCode":"        # we're passing messages under `messages` key, as this is expected by the prompt\n        if isinstance(state_schema, type) and issubclass(state_schema, BaseModel):\n            state.messages = messages  # type: ignore\n        else:\n            state[\"messages\"] = messages  # type: ignore\n\n        return state\n\n    # Define the function that calls the model\n    def call_model(\n        state: StateSchema, runtime: Runtime[ContextT], config: RunnableConfig\n    ) -> StateSchema:\n        if is_async_dynamic_model:\n            msg = (\n                \"Async model callable provided but agent invoked synchronously. \"\n                \"Use agent.ainvoke() or agent.astream(), or \"\n                \"provide a sync model callable.\"\n            )\n            raise RuntimeError(msg)\n\n        model_input = _get_model_input_state(state)\n\n        if is_dynamic_model:\n            # Resolve dynamic model at runtime and apply prompt\n            dynamic_model = _resolve_model(state, runtime)\n            response = cast(AIMessage, dynamic_model.invoke(model_input, config))  # type: ignore[arg-type]\n        else:\n            response = cast(AIMessage, static_model.invoke(model_input, config))  # type: ignore[union-attr]\n\n        # add agent name to the AIMessage\n        response.name = name\n\n        if _are_more_steps_needed(state, response):\n            return {\n                \"messages\": [\n                    AIMessage(\n                        id=response.id,","sourceCodeStart":652,"sourceCodeEnd":688,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py#L652-L688","documentation":"Error \"Async model callable provided but agent invoked synchronously. Use agent.ainvoke() or agent.astream(), or provide a sync model callable.\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py:670 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}