Skip to content

Fix/tool error as tool result#121

Merged
OhYee merged 1 commit into
mainfrom
fix/tool-error-as-tool-result
Jun 17, 2026
Merged

Fix/tool error as tool result#121
OhYee merged 1 commit into
mainfrom
fix/tool-error-as-tool-result

Conversation

@zoeshawwang

Copy link
Copy Markdown
Collaborator

Thank you for creating a pull request to contribute to Serverless Devs agentrun-sdk-python code! Before you open the request please answer the following questions to help it be more easily integrated. Please check the boxes "[ ]" with "[x]" when done too.
Please select one of the PR types below to complete


Fix bugs

Bug detail

The specific manifestation of the bug or the associated issue.

Pull request tasks

  • Add test cases for the changes
  • Passed the CI test

Update docs

Reason for update

Why do you need to update your documentation?

Pull request tasks

  • Update Chinese documentation
  • Update English documentation

Add contributor

Contributed content

  • Code
  • Document

Content detail

if content_type == 'code' || content_type == 'document':
    please tell us `PR url`,like: https://github.com/Serverless-Devs/agentrun-sdk-python/pull/1
else:
    please describe your contribution in detail

Others

Reason for update

Why do you need to update your documentation?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the LangGraph integration’s event conversion so that on_tool_error is emitted as a TOOL_RESULT event (instead of ERROR), aligning tool failures with the tool-result lifecycle and updating related integration tests. It also bumps the package version to 0.0.36.

Changes:

  • Convert LangGraph on_tool_error into EventType.TOOL_RESULT with data={"id": ..., "result": ...}.
  • Update integration tests to assert TOOL_RESULT semantics and field names (id/result).
  • Bump SDK version from 0.0.35 to 0.0.36.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
agentrun/integration/langgraph/agent_converter.py Changes tool error conversion to emit TOOL_RESULT rather than ERROR.
tests/unittests/integration/test_langgraph_events.py Updates expectations for tool-error events to be TOOL_RESULT with id/result.
tests/unittests/integration/test_langgraph_to_agent_event.py Mirrors the tool-error expectation changes for the agent-event conversion path.
pyproject.toml Bumps project version to 0.0.36.
agentrun/__init__.py Bumps __version__ to 0.0.36.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 919 to +923
yield AgentResult(
event=EventType.ERROR,
event=EventType.TOOL_RESULT,
data={
"message": (
"id": tool_call_id,
"result": (
Convert LangGraph tool failures into TOOL_RESULT events so downstream consumers treat them as tool outcomes instead of run-level errors.

Constraint: preserve existing non-tool error handling.
Rejected: keep emitting EventType.ERROR for on_tool_error | that escalates tool failures into run failures.
Confidence: high
Scope-risk: narrow
Directive: future tool-error handling should stay aligned with TOOL_RESULT unless the protocol contract changes.
Tested: uv run pytest -q tests/unittests/integration/test_langgraph_events.py tests/unittests/integration/test_langgraph_to_agent_event.py; git diff --check
Not-tested: full repository test suite

Change-Id: Ie7c4a6264afcbb7613b5382075978e82f9c7ef30
Co-developed-by: Codex <noreply@openai.com>
@zoeshawwang zoeshawwang force-pushed the fix/tool-error-as-tool-result branch from 8a45006 to 6c4e035 Compare June 17, 2026 07:18
@OhYee OhYee merged commit 4cfd484 into main Jun 17, 2026
0 of 6 checks passed
@OhYee OhYee deleted the fix/tool-error-as-tool-result branch June 17, 2026 09:52
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

Successfully merging this pull request may close these issues.

4 participants