Skip to content

fix: keep the output file tool off subagents and its errors recoverable - #1070

Open
radu-mocanu wants to merge 1 commit into
mainfrom
fix/output-file-subagents-and-errors
Open

fix: keep the output file tool off subagents and its errors recoverable#1070
radu-mocanu wants to merge 1 commit into
mainfrom
fix/output-file-subagents-and-errors

Conversation

@radu-mocanu

Copy link
Copy Markdown
Collaborator

Summary

  • create_output_file now reaches the main agent only, not the general-purpose subagent, so the attachment reference cannot be lost across the task boundary
  • a wrong file_path, a missing source, two sources, or a traversal attempt come back to the agent as errors it can correct, instead of faulting the run
  • the argument descriptions now say that content uploads directly and leaves no workspace file, so a file created that way is not referenceable by path

Why

Fixes a run observed on the local robot. An advanced agent delegated the report to a subagent, which published it with create_output_file and returned a text summary. Subagents run with their own context, so the reference never reached the main agent, which is the only one that fills the typed output. The main agent regenerated the report from that summary (17k chars against the subagent's 23k), published a second attachment, then referenced the file by path and killed the run with AGENT_RUNTIME.UNEXPECTED_ERROR.

The path mistake was invited by the old description, which told the agent to pass the path of anything it "had already written to a file" - which is what it believed after using content.

Copilot AI lite review requested due to automatic review settings September 7, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The updated tool behavior introduces a schema/behavior mismatch (error-only outputs vs required file) and an avoidable import-time coupling in the advanced agent module.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adjusts how the internal create_output_file tool is exposed and how it fails, to prevent output-file attachment references from being lost when work is delegated to deepagents subagents, and to make common agent mistakes recoverable instead of faulting the run.

Changes:

  • Withhold create_output_file from the general-purpose subagent and make it available to the main agent only (via middleware partitioning).
  • Make create_output_file return model-correctable error payloads for invalid inputs / missing workspace files / traversal attempts instead of raising.
  • Bump package version to 0.17.4 and update tests accordingly.
File summaries
File Description
src/uipath_langchain/agent/advanced/agent.py Partitions tools so create_output_file is main-agent-only via middleware.
src/uipath_langchain/agent/tools/internal_tools/output_file_tool.py Updates tool argument descriptions and converts several failure modes into agent-correctable error returns.
tests/agent/advanced/test_create_advanced_agent_graph.py Adds regression coverage ensuring the output-file tool is withheld from subagents.
tests/agent/tools/internal_tools/test_output_file_tool.py Updates coverage to assert error payloads are returned for invalid calls instead of exceptions.
pyproject.toml Version bump to 0.17.4.
uv.lock Lockfile update for the version bump.
Review details
  • Files reviewed: 5/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +79 to +81
class _OutputFileRejected(Exception):
"""A model-correctable rejection, reported to the agent rather than raised."""

Comment on lines +46 to +48
from uipath_langchain.agent.tools.internal_tools.output_file_tool import (
OUTPUT_FILE_TOOL_NAME,
)
@radu-mocanu
radu-mocanu force-pushed the fix/output-file-subagents-and-errors branch 2 times, most recently from 05001bd to 2a6eade Compare September 7, 2026 17:16
An advanced agent delegated the report to a subagent, which published it with
create_output_file and returned a text summary. Subagents run with their own
context, so the reference never reached the main agent, which is the only one
that fills the typed output. The main agent regenerated the report from that
summary, published a second attachment, then referenced the file by path and
faulted the run.

Three changes, one per link in that chain.

The tool now travels as main-agent-only middleware. create_deep_agent hands its
tools list to the general-purpose subagent as well, and excluded_tools on the
harness profile strips from the main agent too, so neither seam worked;
middleware tools are collected per agent and deepagents gives caller middleware
to the main agent alone.

A mistake the agent can correct now comes back as an error rather than raising.
A wrong path, a missing source, two sources, or a traversal attempt each cost a
turn instead of the job.

The tool says what it does: it creates an Orchestrator attachment, not a file on
disk. It previously opened with "Create a file", and told the agent to pass the
path of anything it "had already written to a file" - which is what it believed
after using content. Describing the tool accurately removes the need to warn
about the consequence.
@radu-mocanu
radu-mocanu force-pushed the fix/output-file-subagents-and-errors branch from 2a6eade to 72cf0bf Compare September 7, 2026 17:20
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

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.

2 participants