feat(advanced): download tool-produced attachments into the workspace - #1105
Draft
robert-ursu wants to merge 2 commits into
Draft
robert-ursu wants to merge 2 commits into
robert-ursu wants to merge 2 commits into
Conversation
An advanced agent only had a file on disk when its ticket arrived through the input schema or the chat window. A ticket a tool returned mid-run, such as a process tool's output file, a batch transform result or a child agent's output, stayed as JSON in the tool message, so the agent had no path to open. The standard agent's job-attachment wrapper covers this but runs only in UiPathToolNode; on this path tools run through deepagents' tool node. ToolAttachmentsMiddleware wraps every tool call, finds JobAttachment-shaped objects in the result, downloads them to <workspace>/<ID>_<name>, the layout input attachments use, and writes a FilePath onto each ticket. It is installed for a FilesystemBackend on the main agent and on every subagent, which share the workspace. Content-block results and Command results are handled; error results and create_output_file results pass through, and a failed download leaves the ticket without a path rather than failing the call. Tracks PC-5029. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QQVAR7BZ5CZbRMMZcb9RGf
CI type-checks the tests too. Narrow the content block and the Command update before indexing, and type the failing-download set as a frozenset. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QQVAR7BZ5CZbRMMZcb9RGf
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
ToolAttachmentsMiddleware, awrap_tool_call/awrap_tool_callhook that finds JobAttachment tickets in a tool result, downloads them to<workspace>/<ID>_<name>(the layout input attachments already use) and writes aFilePathonto each ticket in the tool messagecreate_advanced_agentfor aFilesystemBackend, on the main agent and on every subagent, which share the workspaceCommandresults (a subagent'staskanswer); error results andcreate_output_fileresults pass through untouchedWhy
An advanced agent only had a file on disk when the ticket arrived through the input schema or the chat window. A ticket a tool returned mid-run (a process tool's output file, a batch transform result, a child agent's output) stayed as JSON, and the meta prompt promised a
FilePaththat was not there. The standard agent's job-attachment wrapper covers this, but it runs only inUiPathToolNode; on this path tools run through deepagents' tool node.Tracks PC-5029.
Design notes for review
IDand a non-emptyFullName) rather than schema-driven, so MCP tools, the code interpreter and a child agent's free-form output are covered too. A ticket's ownMetadatais not searched.FilePathinstead of failing the tool call, mirroringresolve_message_attachments; the agent still holds a reference it can hand to other tools. A staleFilePathon such a ticket is dropped.create_output_fileis skipped: the agent wrote and named that file itself, so the ticket points back at a copy of what is already in the workspace.wrap_tool_calldownloads throughasyncio.runwhen no loop is running and otherwise leaves the result alone with a warning.Follow-ups, deliberately not in this PR
WorkspaceHydrator.link_attachmentalready exists for this..uipath-workspace/snapshot files. Needs a small uipath-runtime API.Test plan
tests/agent/advanced/test_tool_attachments.py: detection, string and content-block rewrite,Commandrewrite, skip rules, file already present, failed download, sync path, and two end-to-end runs on a real deep agent (main agent and general-purpose subagent)tests/agent/advanced,tests/agent/attachmentsand the circular import test green; ruff and mypy cleanread_fileon the returnedFilePathCompanion prompt change: UiPath/uipath-agents-python#762
🤖 Generated with Claude Code
https://claude.ai/code/session_01QQVAR7BZ5CZbRMMZcb9RGf