mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Operators can reset an agent's runtime session with `POST /agents/:id/runtime-state/reset-session` > - A `taskKey` scopes the reset to one task. No key resets all task state. > - The schema accepted a whitespace-only `taskKey`, and the route changed it to `null` > - So a blank key took the full-reset path, and the activity entry recorded `taskKey: null` > - This pull request makes the schema trim the key and reject a blank key with a 400 > - The benefit is that a scoped reset request can never become a full reset by accident ## Linked Issues or Issue Description Fixes #19080 Refs #19005 (the parent issue that #19080 was split out of) I searched open and closed PRs for `19080`, `reset-session` and `resetAgentSessionSchema`. I found no related PR. ## What Changed - `resetAgentSessionSchema.taskKey` is now `z.string().trim().min(1).optional().nullable()`. A blank or whitespace-only key fails validation with a 400. An omitted key or `null` still requests the full reset. - The route uses the parsed `taskKey` directly. The schema already trims it, so the route no longer has its own trim-and-null step. - Added tests in `packages/shared/src/validators/agent.test.ts` for omitted, `null`, trimmed and blank keys. ## Verification - `pnpm exec vitest run packages/shared/src/validators/agent.test.ts`: 16 tests pass. - `pnpm exec vitest run cli/src/__tests__/agent-lifecycle.test.ts`: 4 tests pass. The CLI parses its payload with the same schema. - `pnpm --filter @paperclipai/shared typecheck` passes. - I ran the server `tsc` locally. It reported no errors in `server/src/routes/agents.ts`. My local Windows setup cannot build `@paperclipai/paperclip-runner`, so the full server typecheck depends on CI. ## Risks - Low risk. A client that sends `taskKey: ""` or a whitespace-only key now gets a 400 instead of a full reset. The board UI sends `null` or an issue id, and the CLI omits the key when `--task-key` is not set. Neither caller sends a blank key. ## Model Used - Claude Opus 5.5 (Anthropic, model ID `claude-opus-5-5`), used through Claude Code with tool use (shell, file editing). It assisted with code reading, the change, tests and this description. I reviewed the change. ## 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