fix(api): support status query on company agent list#4450
fix(api): support status query on company agent list#4450starlein wants to merge 1 commit intopaperclipai:masterfrom
Conversation
Greptile SummaryThis PR adds validated Confidence Score: 5/5Safe to merge — logic is correct and well-tested; two minor P2 follow-ups are non-blocking. All findings are P2: one stale doc line and one defensive note about the implicit includeTerminated: false default. Neither blocks correctness of the new behaviour. Tests are thorough and the route change is well-scoped. docs/api/agents.md — line 16 contradicts the new status-filter feature and should be updated before consumers rely on it. Important Files Changed
|
|
|
||
| const statusFilter = new Set(requestedStatuses); | ||
| const includeTerminated = statusFilter.has("terminated"); | ||
| const result = await svc.list(companyId, { includeTerminated }); |
There was a problem hiding this comment.
includeTerminated always passed even with no status filter
The original call was svc.list(companyId) (no second argument). Now every request — including ones with no status param — calls svc.list(companyId, { includeTerminated: false }). If the service method's default behaviour when the option is omitted differs from { includeTerminated: false } (e.g. it previously returned terminated agents by default), this silently changes the unfiltered list response for all existing callers. Worth a quick verification against the AgentService.list signature to confirm includeTerminated defaults to false.
Prompt To Fix With AI
This is a comment left during a code review.
Path: server/src/routes/agents.ts
Line: 1162
Comment:
**`includeTerminated` always passed even with no status filter**
The original call was `svc.list(companyId)` (no second argument). Now every request — including ones with no `status` param — calls `svc.list(companyId, { includeTerminated: false })`. If the service method's default behaviour when the option is omitted differs from `{ includeTerminated: false }` (e.g. it previously returned terminated agents by default), this silently changes the unfiltered list response for all existing callers. Worth a quick verification against the `AgentService.list` signature to confirm `includeTerminated` defaults to `false`.
How can I resolve this? If you propose a fix, please make it concise.
Thinking Path
What Changed
statusquery param onGET /api/companies/:companyId/agents.status=idle,running) and repeated params.AGENT_STATUSES; invalid/empty status filters now return clear 400 errors.terminatedis requested, the route now loads withincludeTerminated: trueand then applies status filtering.server/src/__tests__/agent-permissions-routes.test.tsfor:Verification
pnpm --filter @paperclipai/server typecheckpnpm --filter @paperclipai/server exec vitest run src/__tests__/agent-permissions-routes.test.tsRisks
?status=now fail fast with 400 instead of silently returning an unfiltered list.Model Used
gpt-5.3-codexvia Hermes Agent (tool-assisted code editing, tests, git/gh workflow).Checklist