Repository navigation
feat(advanced): return tool execution errors to the model - #1138
radu-mocanu wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Regression coverage must distinguish subagent recovery from parent recovery and verify interrupt/resume behavior with the new middleware.
2 open findings
What changed in this PR
Advanced agents now return recoverable tool errors to the model rather than faulting the run.
Changes:
- Adds shared error middleware for main agents and subagents while preserving startup and termination failures.
- Adds regression tests and updates middleware expectations.
- Bumps the package version to
0.18.31.
| File | Description |
|---|---|
uv.lock |
Updates the locked package version. |
tests/agent/advanced/test_tool_errors.py |
Tests tool-error recovery and fatal-error propagation. |
tests/agent/advanced/test_payload_handler_middleware.py |
Updates expected middleware composition. |
src/uipath_langchain/agent/advanced/agent.py |
Adds shared tool-error handling. |
pyproject.toml |
Bumps the package version. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
bc8bcdc to
f0d669f
Compare
|
| if isinstance(exc, AgentStartupError): | ||
| return None | ||
| if isinstance(exc, AgentRuntimeError) and exc.error_info.code.startswith( | ||
| "AGENT_RUNTIME.TERMINATION_" | ||
| ): | ||
| return None |
There was a problem hiding this comment.
nit: this would be done nicer using a marker type for termination errors. But it would require extracting the termination error codes out of AgentRuntimeError into a separate AgentTerminatingError type.
# exceptions.py
class RunTerminatingError(Exception):
"""Ends the agent run immediately."""
class AgentStartupError(UiPathBaseRuntimeError, RunTerminatingError): ...
class AgentTerminatingError(AgentRuntimeError, RunTerminatingError): ...def _tool_error_content(exc: Exception, request: ToolCallRequest) -> str | None:
return None if isinstance(exc, RunTerminatingError) else str(exc)



Summary
ToolMessageto the model instead of faulting the job, so the model can recoverAgentStartupErrorandAgentRuntimeErrortermination codes (AGENT_RUNTIME.TERMINATION_*, e.g. a rejected escalation) still end the runToolErrorMiddleware, no retries are addedWhy
a single transient tool failure faulted the whole advanced agent run, while the model could have retried or worked around it.