Files
PaperClipAI/server
Devin FoleyandPaperclip f5f60cfcb2 fix(server): name why agent files could not be excluded from task Git staging (#21499)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Before a remote run starts, Paperclip prepares the agent's files in
the sandbox and keeps the reserved runtime directory out of task Git
staging
> - A short program in the sandbox writes the Git exclusion. When it
failed, the run error said only "Could not exclude agent files from task
Git staging"
> - The error dropped the exit code, the timeout state and the program
output. Many staging runs failed with this message, and none of them
showed the cause
> - This pull request adds a closed reason code to the error
> - The benefit is that the next failures show what to fix, without
leaking sandbox paths or user names

## Linked Issues or Issue Description

**What happened?**
Many staging runs failed in the preparing stage with "Could not exclude
agent files from task Git staging". The error had no cause.

**Steps to reproduce**
1. Start a remote run where the Git exclusion program fails (for
example, it times out, Node is missing, or the exclusion file is
unsafe).
2. Read the run error.

**Expected behavior**
The error names why the exclusion failed.

**Actual behavior**
The error gives no reason, so the failure cannot be diagnosed.

## What Changed

- `agent-instruction-files.ts`: add
`instructionGitExcludeFailureReason`. It maps the result to a closed
reason: `timed_out`, `unsafe_directory`, `unsafe_file`, a Node error
code such as `enoent` or `eacces`, `node_unavailable`, `signal_<name>`,
`exit_<code>` or `unknown`.
- `agent-directory-working-copies.ts`: append `(reason=<code>)` to the
existing error message.
- The reason never copies sandbox output, paths or user names.
- Tests: run the real exclusion program against failing fixtures and
check the reason.

## Verification

- `pnpm vitest run
server/src/__tests__/agent-instruction-git-exclusion.test.ts`: 16/16
pass.
- Working copy suite: 136/136 pass.
- These local results are from the earlier master base. The rebase onto
the current master had no conflicts. CI verifies the current head.

## Risks

- Low. The change adds a suffix to one error message. It does not change
when the error is thrown.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution
in Claude Code.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-17 13:56:09 -08:00
..