-
Notifications
You must be signed in to change notification settings - Fork 19.9k
Description
Checked other resources
- This is a bug, not a usage question.
- I added a clear and descriptive title that summarizes this issue.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangChain rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
- This is not related to the langchain-community package.
- I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
- I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.
Example Code
import os
from langchain.agents import create_agent
from langgraph.checkpoint.memory import InMemorySaver
from langchain_core.messages import HumanMessage
from langchain_ollama import ChatOllama
import logging
logger = logging.getLogger(__name__)
__config = {"configurable": {"thread_id": "1"} }
__agent = create_agent(
tools=[],
model=ChatOllama(
temperature=temperature,
base_url=os.getenv("LLM_URL"),
stream=True,
),
system_prompt="You are a good agent",
checkpointer=InMemorySaver(),
)
async def chat(self, input: str):
async for token, metadata in __agent.astream(
input={"messages": [HumanMessage(content=input)]},
config=__config,
stream_mode="messages",
):
logger.info("--------------------------------")
logger.info(f"token: {token}")
logger.info(f"metadata: {metadata}")
logger.info("--------------------------------")
if metadata["langgraph_node"] == "model":
if token.content_blocks and token.content_blocks[0]["type"] == "text":
yield token.content_blocks[0]["text"]
elif token.content_blocks and token.content_blocks[0]["type"] == "tool_call_chunk" and token.content_blocks[0]["name"]:
logger.info(f"calling tool: {token.content_blocks[0]['name']}")
elif metadata["langgraph_node"] == "tool":
logger.info(f"tool result: {token.content_blocks[0]['text']}")Error Message and Stack Trace (if applicable)
No response
Description
In python 3.10 the agent.astream function is not sending each token but send only the full message.
I am developing with a development PC with 3.10, however I tested the same code with python 3.12 on the same development pc and it is working perfectly.
However I can not upgrade python since I have to use a Jetson Orin with python 3.10 pre-installed.
System Info
System Information
OS: Darwin
OS Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:35:32 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6020
Python Version: 3.10.0 (default, Oct 17 2021, 11:56:26) [Clang 13.0.0 ]
Package Information
langchain_core: 1.0.4
langchain: 1.0.5
langchain_community: 0.4.1
langsmith: 0.4.39
langchain_classic: 1.0.0
langchain_ollama: 1.0.0
langchain_openai: 1.0.1
langchain_text_splitters: 1.0.0
langgraph_sdk: 0.2.9
Optional packages not installed
langserve
Other Dependencies
aiohttp: 3.13.2
async-timeout: 4.0.3
dataclasses-json: 0.6.7
httpx: 0.28.1
httpx-sse: 0.4.3
jsonpatch: 1.33
langgraph: 1.0.2
numpy: 2.2.6
ollama: 0.6.0
openai: 2.6.1
orjson: 3.11.4
packaging: 25.0
pydantic: 2.12.3
pydantic-settings: 2.11.0
PyYAML: 6.0.3
pyyaml: 6.0.3
requests: 2.32.5
requests-toolbelt: 1.0.0
SQLAlchemy: 2.0.44
sqlalchemy: 2.0.44
tenacity: 9.1.2
tiktoken: 0.12.0
typing-extensions: 4.15.0
zstandard: 0.25.0