fix(core): Make scoped workspace path errors actionable for agents - #37887
fix(core): Make scoped workspace path errors actionable for agents#37887bjorger wants to merge 2 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
PR review overviewBased on ownership of the 14 changed files in this PR:
|
There was a problem hiding this comment.
No issues found across 6 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Improves error messages and tool schema descriptions for scoped workspace tools to guide agents to use paths under the workspace root. The scope check itself is unchanged, making this a bounded, clearly beneficial UX improvement backed by updated tests.
Re-trigger cubic
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Instance AI Workflow EvalImportant This eval does not re-run on new commits. To test your latest push, re-run it against the PR head: gh workflow run ci-instance-ai-evals.yml -f pr=37887…or use the Run workflow button and set pr = Tip 🟢 All 25 units green over 3 runs; 5 flaky — see Failures below. Gate: pass@k = 100% (every unit passes at least once across k runs) — 93.3% pass (70/75 trials over 25 units · k=3) pass@3 100.0% · pass^3 85.9% · LangSmith experiment Failures (5)
Per-test-case results (8)
Workflow checksScored over 24 successful build(s). N/A = check did not apply to that workflow. Error = check could not be measured (e.g. judge timeout).
All workflow checks (4 failing of 35 checks)
|
…riptions Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
0 issues found across 8 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Improves scoped workspace tool error messages and schema descriptions to guide agents to paths under the workspace root, without changing scope enforcement. Bounded UX improvement backed by updated tests.
Re-trigger cubic
Summary
When an agent passes a path outside its scoped workspace root (for example
/tmp/ids.txt), the workspace tools reject the call withPath escapes workspace root: /tmp/ids.txt. The message does not name the root and does not say how to fix the call. The system prompt only saysFilesystem access is scoped to <root>.and the tool schemas only sayPath to the file to write. The model has no way to self-correct, and the user sees an opaque tool error in the agent preview.This PR mirrors the guidance that Instance AI already gives its model, inside the shared
@n8n/agentsscoped workspace:scoped-workspace.ts): the error now names the offending path, the workspace root, and the remedy:Path "/tmp/ids.txt" is outside the workspace root "/home/user/workspace". Use a path relative to the workspace root, e.g. "tmp/output.txt".The tool runtime returns this text to the model, so the model can retry with a path under the root on the next turn.
ScopedFilesystem.getInstructions): the text appended to the system prompt now explains that paths resolve against the root, that absolute paths must stay under the root, and that<root>/tmpis the place for scratch files.workspace_read_file,workspace_write_file,workspace_str_replace_file): thepathparameter now says it is relative to the workspace root and that absolute paths must be under it.The scope check itself does not change. Instance AI shares
createScopedWorkspaceand only inherits the new error text; it keeps its own prompt guidance. The four existing test assertions that matched the old message prefix now match the new message.How to test
N8N_AGENTS_AI_SANDBOX_ENABLED=trueplus a configured sandbox provider).helloto/tmp/hello.txt."<root>/tmpdirectly. If the agent still calls the tool with/tmp/hello.txt, the tool error names the workspace root and the agent retries with a path under the root and succeeds.cd packages/@n8n/agents && pnpm test src/workspace/__tests__/scoped-workspace.test.ts src/__tests__/workspace/scoped-workspace.test.tsRelated Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/AGENT-691
Review / Merge checklist
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)🤖 PR Summary generated by AI
Made with Cursor