Repository navigation
feat(daemon): add infer daemon stop and move the session commands to infer sessions - #1968
Merged
Merged
Conversation
… infer sessions The daemon is the process that hosts sessions, not the place to act on them, yet infer daemon carried workspaces, run, stop and teleport. So infer daemon stop stopped one session, and nothing stopped the daemon itself. infer daemon now starts and stops the process. infer daemon stop sends SIGTERM to the pid the pid file's lock vouches for, waits for the daemon to shut down, and kills it if it still runs after a minute. A pid file no daemon holds is left alone, since its pid may name another process by now. With no daemon running it says so and exits 0. infer daemon takes no arguments, so a leftover infer daemon run fails instead of starting a daemon. The session commands move unchanged to infer sessions workspaces, run, stop and teleport, which take a <session-id>. infer daemon workspaces, run, stop <id> and teleport are gone, and the docs and examples use the new commands. A stop ends everything the daemon runs gracefully. Session workers already ended their turn and cleaned up. A scheduled, heartbeat or A2A run and a subagent were killed on cancel, skipping their own shutdown of MCP servers, browser and background shells, and the scheduler left a running job behind after 30 seconds. Such a run now gets SIGTERM and 25 seconds before a kill, and the scheduler cancels its jobs on stop. Windows has no SIGTERM, so there the daemon is killed and its one-shot runs outlive it. Verified in tmux against the tokenless mock: with a chat session worker, a room member holding a call for approval and a stalled heartbeat run, infer daemon stop returned in 0.13s, every child logged its own shutdown, and no infer process was left.
This was referenced Nov 24, 2026
edenreich
added a commit
that referenced
this pull request
Nov 24, 2026
## Summary Closes #1969. Stacked on #1968, so its base is `feat/daemon-stop`. Merge #1968 first, and GitHub moves this PR onto `main`. A workspace is a place sessions run, a concept of its own, yet #1968 put its listing under `infer sessions` beside the commands that act on one session. Workspaces now get their own command group: ```bash infer workspaces list # every workspace in daemon.yaml and whether it is reachable infer sessions run|stop|teleport <session-id> # what infer sessions keeps infer daemon stop # what infer daemon keeps, besides starting it ``` - **`infer workspaces list`** prints what `infer sessions workspaces` printed: each workspace's name, compute, kind, protocol, whether it is reachable, and its details. It asks the running daemon over its binding, as before. - **`infer sessions`** keeps `run`, `stop` and `teleport`. - The command and its test move from `cmd/sessions` to `cmd/workspaces` unchanged, apart from the `list` subcommand taking no arguments. - The docs, the examples' Taskfiles and READMEs, and the chat's error hint (`check it with: infer workspaces list`) use the new command. `docs/commands-reference.md` gets an `infer workspaces` section after `infer sessions`. ## Verification - **In tmux against the tokenless mock**, with an isolated `HOME` and binding port: - `infer workspaces list` printed `Edens-MBP - local agui true storage=jsonl version=dev` under its header - `infer sessions --help` lists `run`, `stop` and `teleport` only - `infer daemon stop` stopped the daemon - `TestPrintWorkspacesListsTheProtocol` now runs in `cmd/workspaces`, and `TestCommandTopology` lists `workspaces`. - `go test -race ./cmd/...`, `golangci-lint`, the import check, markdownlint, and the pre-commit gate. - **Not run:** the Kubernetes teleport examples whose Taskfiles now call `infer workspaces list`, which need a cluster. The edit there is the command name only. ## Cross-repo impact - inference-gateway/docs#1307 updates the CLI page, `cli.md`, for this PR and #1968: `infer workspaces list` replaces `infer daemon workspaces` there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The daemon is the process that hosts sessions, not the place to act on them. Yet
infer daemoncarriedworkspaces,run,stopandteleport, soinfer daemon stopstopped one session, and nothing stopped the daemon itself. Cleaning up a daemon meant reading~/.infer/run/daemon.pidand killing it by hand, which is how a daemon from a stale build kept running members in the wrong mode during testing of #1963.Now
infer daemonstarts and stops the process, the session commands live underinfer sessions, and a stop ends everything the daemon runs gracefully.infer daemon stop~/.infer/run/daemon.pid. It sends SIGTERM, waits for the daemon's own shutdown, and kills it if it still runs after a minute.no infer daemon is runningand exits 0.infer daemontakes no arguments, so a leftoverinfer daemon run <id>fails instead of starting a daemon.infer sessionsworkspaces,run,stopandteleportmove fromcmd/daemontocmd/sessionsunchanged, apart from naming their argument<session-id>. The command tree now mirrors the bounded contexts: the daemon hosts the sessions context, it does not own its verbs.Everything the daemon runs shuts down gracefully
interrupt, closes its stdin, and the worker ends its turn and cleans up.agentheadless.Runstarted them withexec.CommandContext, whose cancel is a SIGKILL, so a run never got to stop its MCP servers, browser and background shells.process.TerminateOnCancelnow sends SIGTERM and gives the run 25 seconds before a kill.infer headlessalready shuts down on SIGTERM.context.Background(), so a stop waited 30 seconds and then let the job run on for up to 30 minutes after the daemon exited. The scheduler now cancels its jobs on stop and waits for them.infer daemon stopkills the daemon. Its session workers still clean up as their stdin closes, but one-shot runs outlive it. This is marked as ashortcut:ondaemon.Stop, to be replaced by a stop frame over the binding once windows needs one.infer daemon workspaces,run,stop <id>andteleportare gone. Useinfer sessions workspaces,run,stopandteleport. There are no deprecated aliases, since keeping them underinfer daemonwould keep the daemon tied to the session verbs. The docs, the examples' Taskfiles and READMEs, and the chat's error hint use the new commands.Verification
INFER_GATEWAY_MOCK, an isolatedHOMEand binding port), with three children of the daemon running: a chat session worker, a room member holding aWritecall for approval, and a heartbeat run whose mock turn stalls forever.infer daemon stopprintedstopped the infer daemon (pid 98322)and returned in 0.13s, with no infer process left.stopping background shell service,stopping job supervisor,shutting down agent containers), the heartbeat run included, the member's pending approval moving toCancelled, thenheartbeat service stoppedanddaemon stopped.infer daemon stopprintedno infer daemon is running.TestStopStopsOnlyTheDaemonHoldingThePidFile: no pid file, a pid file no daemon holds (its process is not signalled), and the daemon holding it (stopped, its pid returned).TestStopKillsAProcessThatIgnoresTheRequestOnceGracePasses: a process that traps SIGTERM is killed once the grace passes, not before.TestACancelledRunShutsDownOnItsOwnBeforeAnyKill: a cancelled run gets to run its SIGTERM handler. It fails without the change (lines = ["ready"], killed before the handler ran).TestCommandTopologylistssessions.go test -raceforcmd/...,internal/daemon,internal/platform/process,internal/agent/headlessandinternal/scheduler/..., plus the pre-commit gate.infer sessions, which need a cluster. The edit there is the command name only.Cross-repo impact
cli.md:infer daemon stop, the session commands underinfer sessions, and the workspace listing asinfer workspaces list, which refactor(cli): list workspaces with infer workspaces list #1970 moves there frominfer sessions workspaces.infer daemon teleport.