Skip to content

fix: replace legacy clawdbot -c RPC with gateway agent calls#402

Closed
HonzysClawdbot wants to merge 3 commits intobuilderz-labs:mainfrom
HonzysClawdbot:fix/sessions-spawn-clawdbot-c-401
Closed

fix: replace legacy clawdbot -c RPC with gateway agent calls#402
HonzysClawdbot wants to merge 3 commits intobuilderz-labs:mainfrom
HonzysClawdbot:fix/sessions-spawn-clawdbot-c-401

Conversation

@HonzysClawdbot
Copy link
Contributor

Problem

Spawning an agent fails with:

Command failed (clawdbot -c sessions_spawn(...)): error: unknown option '-c'

The clawdbot binary no longer exists and openclaw doesn't support the -c flag.

Solution

Added runGatewayToolCall() helper in src/lib/command.ts that invokes agent tools via openclaw gateway call agent --expect-final. Replaced all runClawdbot(['-c', rpcFn]) calls across:

  • POST /api/spawnsessions_spawn
  • POST /api/sessionssession_setThinking/setVerbose/setReasoning/setLabel
  • DELETE /api/sessionssession_delete
  • POST /api/sessions/[id]/controlsessions_kill/sessions_send
  • GET /api/status — removed clawdbot --version fallback

Closes #401

…essions (builderz-labs#395)

When assigning a task to an agent, users can now optionally select an
existing session to dispatch the task to instead of creating a new one.

Changes:
- task-dispatch.ts: When target_session is set in task metadata, use
  gateway chat.send to dispatch to that specific session instead of
  creating a new one via call agent
- task-board-panel.tsx: Add session selector dropdown in both Create
  and Edit task modals that appears when an agent is selected and has
  active sessions
- store/index.ts: Add agent and channel fields to Session interface

Closes builderz-labs#395
The gateways table is created lazily by the gateways API (ensureTable).
The health route was querying it directly without CREATE IF NOT EXISTS,
causing SqliteError: no such table: gateways in fresh databases (E2E tests,
Docker first-boot).

Add ensureGatewaysTable() inline to mirror the pattern in route.ts.
…z-labs#401)

The `clawdbot` binary no longer exists and `openclaw` does not support
the `-c` flag.  All `runClawdbot(['-c', rpcFn])` calls now go through
a new `runGatewayToolCall()` helper that invokes tools via
`openclaw gateway call agent --expect-final`.

Affected routes:
- POST /api/spawn — sessions_spawn
- POST /api/sessions — session_setThinking/setVerbose/setReasoning/setLabel
- DELETE /api/sessions — session_delete
- POST /api/sessions/[id]/control — sessions_kill/sessions_send
- GET /api/status — removed clawdbot --version fallback

Closes builderz-labs#401
@HonzysClawdbot HonzysClawdbot requested a review from 0xNyk as a code owner March 15, 2026 21:41
@0xNyk
Copy link
Member

0xNyk commented Mar 16, 2026

Review

The migration from clawdbot -c to callOpenClawGateway is the right direction. Quality gate passes. However, two issues need attention:

Must fix

  1. chat.send is fire-and-forget but task is marked complete — In task-dispatch.ts, the chat.send path for session control operations (sessions_spawn, sessions_prune, gateway_restart) returns immediately. The calling code then marks the task as done based on the placeholder response text, not the actual operation result. The task should stay in_progress until the operation completes, or use a synchronous RPC method instead.

  2. ensureGatewaysTable in POST handlerCREATE TABLE IF NOT EXISTS runs on every health check request. This adds unnecessary SQLite lock contention. Should be in the migration layer.

Note (non-blocking)

  1. Timeout unitscallOpenClawGateway passes timeout as milliseconds to --timeout. Verify openclaw CLI interprets this as ms (not seconds).

@0xNyk
Copy link
Member

0xNyk commented Mar 16, 2026

Superseded by #407 which was merged. The clawdbot CLI→gateway RPC migration is complete.

@0xNyk 0xNyk closed this Mar 16, 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.

[Bug] sessions_spawn API has changed

2 participants