Skip to content

feat: AgentCreateSchema accepts workspace / filesystemScope / fileAccessPolicy - #96

Closed
siglimumuni wants to merge 1 commit into
swarmclawai:mainfrom
siglimumuni:feat/agent-schema-workspace-fields
Closed

feat: AgentCreateSchema accepts workspace / filesystemScope / fileAccessPolicy#96
siglimumuni wants to merge 1 commit into
swarmclawai:mainfrom
siglimumuni:feat/agent-schema-workspace-fields

Conversation

@siglimumuni

Copy link
Copy Markdown
Contributor

Summary

Three fields defined on the `Agent` type and consumed at runtime — `workspace`, `filesystemScope`, `fileAccessPolicy` — are missing from the Zod `AgentCreateSchema`. `AgentUpdateSchema` derives from it via `.partial()`, so PUT /api/agents/:id silently drops these fields. The runtime behaviors they control (workspace-scoped file ops, fileAccessPolicy enforcement) are therefore unreachable via the public API.

How I found it

Tried to lock a worker agent down to a dedicated workspace via the API:

```
PUT /api/agents/
{
"workspace": "/Users/foo/agent-workspaces/hugo",
"filesystemScope": "workspace",
"fileAccessPolicy": { "blockedPaths": ["/Users/foo/.ssh/**", ...] }
}
```

Endpoint returned 200 with the agent record. But:

```
GET /api/agents/
→ workspace: null, filesystemScope: null, fileAccessPolicy: null
```

Confirmed in the route handler (app/api/agents/\[id\]/route.ts:20-29): `AgentUpdateSchema.safeParse(raw)` strips unknown keys, then the post-parse filter restricts the body to keys present in `parsed.data` — and the missing schema entries mean those keys are absent from `parsed.data` entirely.

End result: the only way to set these fields is to write directly to the `agents` table.

Fix

Add the three fields to `AgentCreateSchema` matching the types in `src/types/agent.ts`:

  • `workspace: string | null`
  • `filesystemScope: 'workspace' | 'machine' | null`
  • `fileAccessPolicy: { allowedPaths?: string[], blockedPaths?: string[] } | null`

No runtime behavior change — just unblocks these fields round-tripping through the API.

Files

  • `src/lib/validation/schemas.ts` — 12 lines

Test plan

  • Reviewed by inspection — schema-only change.
  • Applied locally; PUT now persists all three fields, GET returns them.

🤖 Generated with Claude Code

…teSchema

These three fields are defined on the Agent TYPE and consumed at runtime
(filesystemScope by file.ts, fileAccessPolicy by context.ts, workspace
by various callers) but were missing from the Zod validation schema. As
a result, PUT /api/agents/:id silently dropped them from the body — they
never reached storage, leaving the corresponding runtime behaviors
unreachable via the public API.

Concretely: setting workspace='/custom/dir' + filesystemScope='workspace'
+ fileAccessPolicy.blockedPaths via PUT /api/agents/:id appeared to
succeed (200 OK with the prior agent record back), but a follow-up GET
showed all three fields still null/unset. The only way to set them was
to write directly to the agents table.

Adds them to AgentCreateSchema (which AgentUpdateSchema inherits via
.partial()), matching the types in src/types/agent.ts. No runtime
behavior change beyond letting these fields round-trip through the API.

Files:
  - src/lib/validation/schemas.ts
@waydelyle

Copy link
Copy Markdown
Member

Cherry-picked and shipped in v1.9.33 with route-level persistence coverage for the workspace filesystem settings. Thanks for the fix.

@waydelyle waydelyle closed this May 18, 2026
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.

2 participants