Skip to content

langchain 1.0.0: add tool_call_id to on_tool_error event's data #33597

@781574155

Description

@781574155

Checked other resources

  • This is a feature request, not a bug report or usage question.
  • I added a clear and descriptive title that summarizes the feature request.
  • I used the GitHub search to find a similar feature request and didn't find it.
  • I checked the LangChain documentation and API reference to see if this feature already exists.
  • This is not related to the langchain-community package.

Feature Description

import asyncio

from langchain.agents import create_agent
from langchain_core.tools import tool

from tanqi.llm.llm import main_model


# Create an intentionally error-prone tool
@tool
def error_prone_tool(input: str) -> str:
    """A tool that always raises an error for demonstration purposes."""
    return 1 / 0


# Set up the agent
model = main_model
tools = [error_prone_tool]
agent = create_agent(model, tools)


async def demonstrate_issue():
    # Stream events to show missing tool_error event
    async for event in agent.astream_events(
        {"messages": "Please demonstrate a tool error"},
        version="v2",
    ):
        if event["event"] == "on_tool_error":
            print(event)


if __name__ == "__main__":
    asyncio.run(demonstrate_issue())

Use Case

It can help

Proposed Solution

No response

Alternatives Considered

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestrequest for an enhancement / additional functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions