Session tools: create_session, delete_session #156
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lz/agent-nexus#156
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?
"Open a session on the auth bug" — the capability most of the value rides on. Depends on #154. Scope:
nexus:write.create_session(workspace, name, initial_message?)Wraps
createSession, which takes nomasterKey— verified — so no vault work.initial_messageis a launch argument, not a nudge.claudeaccepts the prompt as a positional argument, so it appends inbuildLaunchCommandand becomes the session's first turn. Notmux send-keys, no window resolution, no race against startup.Trap, hit during the original probe: several claude flags are variadic —
--channels <servers...>,--dangerously-load-development-channels <servers...>— and silently swallow a trailing positional prompt. The session died withInput must be provided either through stdin or as a prompt argument. Audit argument order incomposeLaunchand pin it with a test: the nexus plugin's--plugin-diris unconditional andextraClaudeArgsare appended after it, so the positional has to land after all of them.Second trap from the same probe: piping claude's stdout (e.g.
| tee) flips it into--printmode.Session names are validated against
git check-ref-format --branchvianexus/src/lib/git-ref.ts— reuse it rather than re-deriving. Slashes are allowed (feature/login).Serialize creates per workspace.
createSessionshells out togit -C /workspace worktree addwith no serialization, and concurrent adds contend onindex.lock. The retry-once path is scoped to each session's own name, so the failure mode is flakiness rather than data loss — but two simultaneous creates can both land in it, and a tool makes rapid succession easy in a way the UI did not.The optimistic
status: 'creating'row is inserted before the slow worktree and tmux work, so the tool returns promptly and the client polls rather than blocking.delete_sessionWraps
deleteSession, which hard-deletes so theUNIQUE(worker_id, name)slot frees for re-creation. NomasterKey.Watch for
createSessionrefuses aremovingrow — surface that as a clear tool error rather than a generic failure.Both tools must reject a
kind='workspace_shell'row, or offer it deliberately: the workspace shell is at most one per worker, reuses the entrypoint's boot tmux window, and has its ownPOST/DELETE /api/workers/:id/sessions/workspaceendpoints. Deleting it through the generic path is not the same operation.Done when
Claude can open a named session in a chosen workspace with a first instruction that actually runs as its opening turn, and close it again — plus a test that fails if a variadic flag is ever appended after the positional prompt.