Repository navigation
fix(daemon): bind Omnigent sessions to a runner host_id - #20
Conversation
The daemon's Omnigent create-session payload omitted host_id, so the
backend never bound/launched a runner for the session and every turn
failed with runner_unavailable ("No runner bound for session").
Mirror the CLI provider: resolve a host_id before POST /v1/sessions.
settings.omnigent.hostId wins; otherwise GET /v1/hosts and auto-pick the
first online host (first host if none report status). Fail closed with a
clear error when zero hosts are registered, instead of creating a session
guaranteed to fail at turn time.
- omnigent-provider.mjs: pure parseOmnigentHosts / chooseOmnigentHost /
buildOmnigentSessionBody helpers (SDK-free, unit-testable)
- chat-jobs.mjs: resolveOmnigentHostId + include host_id in the body
- omnigent-settings.mjs: optional hostId field (+ CODESURF_OMNIGENT_HOST_ID)
- tests: host parse/pick + host_id-in-payload + settings coverage
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR adds three pure helper exports to ChangesOmnigent Host Resolution
Sequence Diagram(s)sequenceDiagram
participant runOmnigentJob
participant resolveOmnigentHostId
participant OmnigentAPI
participant buildOmnigentSessionBody
runOmnigentJob->>resolveOmnigentHostId: settings, baseUrl, apiKey, signal
resolveOmnigentHostId->>OmnigentAPI: GET /v1/hosts
OmnigentAPI-->>resolveOmnigentHostId: hosts payload
resolveOmnigentHostId->>resolveOmnigentHostId: parseOmnigentHosts → chooseOmnigentHost
resolveOmnigentHostId-->>runOmnigentJob: hostId (throws if none)
runOmnigentJob->>buildOmnigentSessionBody: agentId, hostId, title, workspace
buildOmnigentSessionBody-->>runOmnigentJob: POST body with host_id
runOmnigentJob->>OmnigentAPI: POST /v1/sessions
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes Omnigent session creation in the daemon by ensuring sessions are bound to a runner host_id, preventing runner_unavailable errors (“No runner bound for session”) on every routed turn.
Changes:
- Add runner host resolution (
settings.omnigent.hostIdoverride, otherwise auto-pick fromGET /v1/hosts, fail closed on zero hosts). - Include
host_idin the daemon’sPOST /v1/sessionspayload via a pure helper (buildOmnigentSessionBody). - Extend daemon Omnigent settings resolution + tests to cover
hostIdand host parsing/selection logic.
Reviewed changes
Copilot reviewed 1 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/codesurf-daemon/test/omnigent.test.mjs | Adds unit tests covering host parsing/selection and asserting host_id inclusion in the create-session body. |
| packages/codesurf-daemon/bin/omnigent-settings.mjs | Adds optional hostId setting resolution with env override CODESURF_OMNIGENT_HOST_ID. |
| packages/codesurf-daemon/bin/omnigent-provider.mjs | Introduces pure helpers parseOmnigentHosts, chooseOmnigentHost, and buildOmnigentSessionBody for testable session/host logic. |
| packages/codesurf-daemon/bin/chat-jobs.mjs | Resolves host_id during session creation and uses the new helper to build the create-session request payload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Backends/CLIs report ONLINE/Online/online; chooseOmnigentHost compared status === 'online' case-sensitively, so an uppercase ONLINE host was missed and a stale first (offline) host was wrongly picked. Normalize to lowercase before comparing. (cross-review blocking fix on PR #20)
Problem
When the desktop/daemon routes an Omnigent chat turn, every turn fails with backend error
runner_unavailable/ "No runner bound for session".Root cause: the daemon created the Omnigent session without a
host_id. With nohost_id, the Omnigent backend never binds/launches a runner for the session, so turns can't execute. The daemon create-session payload was{ agent_id, title, workspace }—host_idappeared nowhere. The CLI provider already does this correctly; this PR mirrors that proven pattern into the daemon.Fix
host_idbefore create (chat-jobs.mjsresolveOmnigentHostId): usesettings.omnigent.hostIdwhen configured; otherwiseGET /v1/hostsfrom the same base URL and auto-pick the first host with statusonline(falling back to the first host if none report status).host_idin thePOST /v1/sessionsbody alongside{ agent_id, title, workspace }.hostIdsetting added to the daemon omnigent settings resolver (omnigent-settings.mjs), mirroringagentId, with env overrideCODESURF_OMNIGENT_HOST_ID. Default blank → auto-pick./v1/hostsreturns no hosts, throw a clear error explaining no runner host is registered — rather than silently creating a session that will fail withrunner_unavailable.Strictly daemon-side and minimal; no changes outside the create-session / host-resolution path + the settings schema.
Implementation notes
omnigent-provider.mjs(parseOmnigentHosts,chooseOmnigentHost,buildOmnigentSessionBody) so the create-session body is unit-testable without importing the Claude SDK thatchat-jobs.mjspulls in — mirrors the existingbuildCodexExecArgspattern in the same file.host_idresolution happens only inside theif (!sessionId)branch (session creation). Resumed turns already have a runner bound.Gates
npm test(packages/codesurf-daemon): 14/14 pass — includes new tests provinghost_idis in the create-session payload and that an online host is auto-picked from/v1/hosts.npm run typecheck(repo): 16 pre-existing errors on baselineorigin/main, none in the files touched here. All changed files are.mjs(not TS-compiled), so this introduces zero new type errors.Assumptions
CODESURF_OMNIGENT_HOST_IDmirrors the existingCODESURF_OMNIGENT_AGENT_ID.onlinehost, else first host. Host id read fromhost_id(preferred) orid.Summary by CodeRabbit
New Features
hostIdsupport viaCODESURF_OMNIGENT_HOST_IDand settings (to control which host sessions are created on).Bug Fixes