Skip to content

fix(workspaces): skip workspace provision command when reusing existing workspace (#8484) - #11091

Open
wakqasahmed wants to merge 2 commits into
paperclipai:masterfrom
wakqasahmed:fix/workspace-provision-on-reuse-8484
Open

fix(workspaces): skip workspace provision command when reusing existing workspace (#8484)#11091
wakqasahmed wants to merge 2 commits into
paperclipai:masterfrom
wakqasahmed:fix/workspace-provision-on-reuse-8484

Conversation

@wakqasahmed

Copy link
Copy Markdown

Fixes #8484

Summary

When an agent was assigned to an issue using an existing workspace, Paperclip executed the project's workspace provisionCommand on every run, even when reusing a previously provisioned workspace (isNew === false).

Fix

  1. Workspace Runtime Orchestrator (server/src/services/workspace-runtime.ts):
    • Added guard if (!input.created) return; in provisionExecutionWorktree so provisionCommand is executed strictly when input.created === true (new workspace setup) and skipped on workspace reuse.
    • Preserved created = true handling when missing worktrees are recreated via git worktree add.
  2. Environment Run Orchestrator (server/src/services/environment-run-orchestrator.ts):
    • Ensured remote provisionCommand execution is guarded by executionWorkspace.created === true || workspaceRealization.isNew === true.
  3. Unit Tests (server/src/__tests__/workspace-runtime.test.ts & server/src/__tests__/environment-run-orchestrator.test.ts):
    • Added test coverage verifying that provisionCommand executes on initial workspace creation, but is skipped when reusing an existing workspace.

@commitperclip

commitperclip Bot commented Aug 8, 2026

Copy link
Copy Markdown

Hey @wakqasahmed! Before this PR can be reviewed, a few things need attention:

Missing or incomplete:

  • Missing section: ## Thinking Path
  • Missing section: ## What Changed
  • Missing section: ## Verification
  • Missing section: ## Risks
  • Missing section: ## Model Used
  • Add the dedup-search checkbox to your PR description and check it once you have searched the GitHub PR list for similar PRs. See the PR template at .github/PULL_REQUEST_TEMPLATE.md and CONTRIBUTING.md → "Before You Start: Search First".

Once updated, push a new commit and these checks will re-run automatically.

— commitperclip

… and stale-worktree provisioning

Adversarial review of paperclipai#11091 found two real regressions in the "skip provision
on reuse" fix:

1. environment-run-orchestrator.ts gated the remote provision command on
   `executionWorkspace.created`, but that flag is hardcoded `false` for the
   `project_primary` (shared workspace) strategy — it's the project's
   long-lived primary checkout, not something created per run. That meant
   provisioning would silently never run again for any shared-workspace
   remote/sandbox environment, not even on the very first run. The
   `workspaceRealization.isNew`/`created` fields the gate also checked are
   never actually populated by any real driver (only by the added unit
   test's mock), so in production the gate reduced entirely to the always-
   false local flag. Fixed by only applying the reuse-skip to the
   `git_worktree` strategy, where "created" is a well-defined signal;
   `project_primary` keeps its prior always-provision behavior.

2. The pre-existing test "reprovisions an existing persisted git worktree
   before manual control starts it" encoded the old provision-on-every-reuse
   behavior the PR is fixing, and was left failing by the original change.
   Updated it to assert the new intended behavior: a reused worktree is not
   reprovisioned, so a manually removed marker file stays gone.

Also fixed a latent type error in the orchestrator test helper
(`makeRealizeInput`) that let the PR's own added test pass an
`executionWorkspace` override property `tsc` would have rejected, and added
a regression test locking in the shared-workspace fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

Workspaces always run the "provision" command (even on reuse)

1 participant