Replies: 6 comments 4 replies
-
I have the same issue when I test with the original tool @eyurtsev ( {'event': 'on_tool_end', 'name': 'some_tool', 'run_id': 'da2748a4-d356-4c74-b653-419b968bf833', 'tags': [], 'metadata': {}, 'data': {'input': {'x': 5, 'y': 'hello'}, 'output': "{'x': 5, 'y': 'hello'}"}} |
Beta Was this translation helpful? Give feedback.
-
I've tried tracing this locally to understand where we are converting the return of the tool to a string, but I'm struggling to trace through all the async/concurrent library calls. I can see when the tool is called here, it's still in the expected type ( |
Beta Was this translation helpful? Give feedback.
-
Potentially a bug. I'm on mobile could you post on the RFC to link to this idea |
Beta Was this translation helpful? Give feedback.
-
OK not an issue with a vanilla tool. from langchain_core.tools import tool
from langchain_core.documents import Document
@tool
def get_docs(x: int):
"""Hello"""
return [Document(page_content='hello')]
async for event in get_docs.astream_events({"x": 5}, version='v1'):
print(event) {'event': 'on_tool_start', 'run_id': '95a96f6c-afa7-4cb7-b8a3-e61347929d44', 'name': 'get_docs', 'tags': [], 'metadata': {}, 'data': {'input': {'x': 5}}}
{'event': 'on_tool_stream', 'run_id': '95a96f6c-afa7-4cb7-b8a3-e61347929d44', 'tags': [], 'metadata': {}, 'name': 'get_docs', 'data': {'chunk': [Document(page_content='hello')]}}
{'event': 'on_tool_end', 'name': 'get_docs', 'run_id': '95a96f6c-afa7-4cb7-b8a3-e61347929d44', 'tags': [], 'metadata': {}, 'data': {'output': [Document(page_content='hello')]}} |
Beta Was this translation helpful? Give feedback.
-
Potentially an issue with agents -- recreated the issue with this notebook and a modified tool that returned dicts https://python.langchain.com/docs/modules/agents/how_to/streaming#custom-streaming-with-events |
Beta Was this translation helpful? Give feedback.
-
Confirmed issue: #18760 |
Beta Was this translation helpful? Give feedback.
-
Checked
Feature request
Currently tool output from the
on_tool_end
event, does not seem to match what the tool returns when invoked directly. In the following example, when the tool is invoked directly, we see alist[Documents]
returned. When the tool is invoked via theagent_executor.astream_events
, we see a string returned.TLDR: I'm trying to get the output of tool calls, not after they've been converted to a string, when using
astream_events
from anagent_executor
.minimal example
.ipynb
Motivation
If I'm trying to reliable find the out of of the tool, from the astream_events method. Having to dig through the many
on_chain_stream
events doesn't seem reliable, especially if an agent has multiple tools. Can we find a way to expose the output of the tool via the astream_events, as it is returned by the tool (i.elist[Documents]
NOTstr
type).Proposal (If applicable)
No response
Beta Was this translation helpful? Give feedback.
All reactions