mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-04 04:29:01 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - A new agent can use a plugin environment that requires an agent. A lifecycle plugin prepares that environment before the agent can work. > - The setup flow creates a draft agent first, so that this preparation can start before the person finishes setup. > - Each change to the draft's harness, model, or sign-in started preparation again. The hire also started it again. > - Verification cannot start until the last preparation is complete. So the early preparation did not decrease the wait after the hire. > - This pull request keeps the preparation when the agent stays on the same environment driver. > - The benefit is that a person who finishes setup waits only for verification. ## Linked Issues or Issue Description I searched the open and closed issues and pull requests. I did not find a duplicate. **What happened?** Create an agent in setup on a plugin environment that declares `requiresAgent: true`. The draft is prepared. Then choose a harness, sign in, and hire the agent. Each of these three steps starts `preparing` again. The agent page shows preparation after the hire, although the environment was ready before the person signed in. **Expected behavior** A change to the harness, model, credentials, or instructions does not change the environment. It must not start preparation again. The hire must go directly to verification. If preparation is in progress, the hire must join it. **Steps to reproduce** 1. Install a lifecycle plugin with an environment driver that declares `requiresAgent: true`. 2. Make that environment the instance default. 3. Create a setup draft and wait until `lifecycleState` is `verifying`. 4. Save a different model on the draft. `lifecycleState` goes back to `preparing`. 5. Hire the draft. `lifecycleState` goes back to `preparing` again. **Paperclip version or commit** `7e025ae65f` **Deployment mode** Self-hosted server with a plugin environment that requires an agent. ## What Changed - A configuration change restarts `preparing` only when the agent moves to an environment that needs setup. The existing environment and driver check makes this decision. - A prepared setup draft stays prepared when its harness, model, credentials, or runtime configuration change. - The hire of a prepared draft goes directly to `verifying` with a new operation. - The hire of a draft that is still `preparing` keeps the operation and its version. Verification starts when that operation is complete. - A hire that moves to an environment that needs setup starts `preparing` again, as before. - A save that changes an environment to another driver of the same plugin now also refuses `preparing` agents, the same as `ready` and `verifying` ones. - A change to instructions alone does not restart verification. The hire writes the managed instruction files immediately after it commits, and verification does not read them. - The hire clears an old lifecycle error on the draft. - These behaviors do not change: - a draft that no longer needs preparation goes to `pausing` - a hire that needs approval, a hire with a hold, and a company hold - an edit to other execution configuration during verification - an edit during `resuming` - `doc/AGENT-LIFECYCLE.md` describes the new rules. ## Verification - `npx vitest run src/modules/agent-lifecycle`: 224 passed. Four new tests cover a prepared draft, a hire from a prepared draft, a hire during preparation, and an instruction change. Three of them failed before the change. The fourth could not run because a test before it left the fixture blocked. - `npx vitest run` on the hire, lifecycle delivery, agent secret, pending approval, secret binding, managed plugin environment, and plugin task tests: all passed. - `npx vitest run` on the two Dot onboarding files: 25 passed. - `pnpm --filter @paperclipai/server typecheck`: passed. - Not done: a live test with a plugin environment. Three existing tests used an agent in `preparing` to test that a configuration change fences verification. They now use `verifying`. ## Risks - A lifecycle plugin that reads the agent's harness or model during `preparing` is not called again when they change. The lifecycle request does not carry them. Verification still tests the final configuration. - A prepared environment can be lost between preparation and hire. Verification then fails and retries, and a pause and resume prepares it again. Before this change, the hire prepared it again. - An edit during `preparing` does not cancel the attempt in progress. A plugin must not fail because the agent's configuration changed during its call. - No migration. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code, with extended thinking, tool use and code execution. ## 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 - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>