fix: keep the output file tool off subagents and its errors recoverable - #1070
fix: keep the output file tool off subagents and its errors recoverable#1070radu-mocanu wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 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_filefrom the general-purpose subagent and make it available to the main agent only (via middleware partitioning). - Make
create_output_filereturn model-correctable error payloads for invalid inputs / missing workspace files / traversal attempts instead of raising. - Bump package version to
0.17.4and 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.
| class _OutputFileRejected(Exception): | ||
| """A model-correctable rejection, reported to the agent rather than raised.""" | ||
|
|
| from uipath_langchain.agent.tools.internal_tools.output_file_tool import ( | ||
| OUTPUT_FILE_TOOL_NAME, | ||
| ) |
05001bd to
2a6eade
Compare
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.
2a6eade to
72cf0bf
Compare
|



Summary
create_output_filenow reaches the main agent only, not the general-purpose subagent, so the attachment reference cannot be lost across thetaskboundaryfile_path, a missing source, two sources, or a traversal attempt come back to the agent as errors it can correct, instead of faulting the runcontentuploads directly and leaves no workspace file, so a file created that way is not referenceable by pathWhy
Fixes a run observed on the local robot. An advanced agent delegated the report to a subagent, which published it with
create_output_fileand 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 withAGENT_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.