Let session creation (MCP / loops) set model, agent/variant, and permission settings #270
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman#270
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
When creating a session programmatically — via the MCP `new_session` tool, or from an agent loop's `spawn_child` / `spawn_worktree` action — the caller can only set the model (`provider/model` string). It cannot set:
These should all be settable at creation time so an orchestrating agent can, e.g., spin up a `plan` child on a high-reasoning model with a locked-down permission set.
Key finding
OpenCode's `POST /session` API accepts only `{ parentID?, title? }` — model/agent/variant are not create-time fields; they ride on the first prompt (`/session/:id/prompt`), and permission is applied via a separate `PATCH /session/:id` `{ permission: [...] }`.
The deep layers already support all of this. `platforms.SendMessageRequest` already has `Model`, `Agent`, `Reasoning` (`internal/platforms/operations.go:16-31`) and the opencode adapter already maps them (`internal/platforms/opencode/operations.go:253-274`). `platforms.SetPermissionRulesRequest` + `Adapter.SetPermissionRules` already exist (`operations.go:111-116`, adapter `operations.go:470-492`). Do NOT expand `CreateSessionRequest`.
The gap is purely in the caller-facing structs and tool schemas, plus one new post-create `SetPermissionRules` call in `SessionLauncher.Launch`.
Scope
Thread Agent + Reasoning through to the first message
Add per-session permission at creation
No changes needed
`platforms.CreateSessionRequest`, `SendMessageRequest`, `Adapter.SendMessage`, `Adapter.SetPermissionRules`, or the OpenCode API layer.
Notes