Child sessions created via SDK don't execute prompts (v1.1.15+) #5898

Closed
opened 2026-02-16 17:58:07 -05:00 by yindo · 0 comments
Owner

Originally created by @Gladdonilli on GitHub (Jan 14, 2026).

Originally assigned to: @thdxr on GitHub.

Description

Child sessions created via the SDK's session.create() and session.prompt() accept prompts successfully but never execute them. The server returns a successful response, but no request is ever sent to the AI provider.

Environment

  • OpenCode version: 1.1.20
  • OS: Windows 11
  • Plugin: oh-my-opencode (uses SDK to spawn background agents)

Steps to Reproduce

  1. Create a child session via SDK:
const createResult = await client.session.create({
  body: { parentID: parentSessionID, title: "Background task" },
  query: { directory: projectDir },
})
  1. Send a prompt to the child session:
await client.session.prompt({
  path: { id: sessionID },
  body: {
    agent: "explore",
    model: { providerID: "anthropic", modelID: "claude-sonnet-4" },
    parts: [{ type: "text", text: "Find all TypeScript files" }],
  },
})
  1. Poll for messages - session stays empty forever

Expected Behavior

The child session should execute the prompt and return AI responses.

Actual Behavior

  • Session creates successfully
  • Prompt returns HTTP 200 with hasError: false, hasData: true
  • But dataPartsCount: 0 - no messages ever appear
  • No request reaches the AI provider
  • Session stays "busy" indefinitely

Debug Evidence

From oh-my-opencode debug logs:

{"type":"spawn_prompt_sent","sessionId":"ses_xxx","agent":"explore","model":{"providerID":"antigravity-claude","modelID":"claude-opus-4-5-thinking"},"promptLength":465}
{"type":"prompt_response","hasError":false,"hasData":true,"dataPartsCount":0}
// Then endless polling with no new messages...
{"type":"polling_tick","elapsedMs":120000}

Regression

This worked in v1.1.14 and broke sometime between v1.1.14 and v1.1.20.

Suspicious changes in v1.1.15:

  • Commit 1954c12: Added basicAuth middleware, changed SDK to use Server.App().fetch() directly
  • Commit f0912ee: Renamed OPENCODE_PASSWORD to OPENCODE_SERVER_PASSWORD

Hypothesis

The v1.1.15 server changes may have broken how external SDK calls (going through HTTP with auth) trigger agent execution. Internal SDK calls (using Server.App().fetch() directly) may work, but external HTTP calls don't properly initialize the agent loop.

Workaround Attempted

We're already passing proper Basic Auth headers via custom fetch wrapper:

const client = createOpencodeClient({
  baseUrl: serverUrl,
  fetch: createAuthenticatedFetch(), // Adds Authorization header
  bodySerializer: JSON.stringify,
})

Auth is working (session creates successfully), but prompts don't execute.

Impact

This breaks all plugins that use background/child sessions, including:

  • oh-my-opencode's background agent system
  • Any plugin spawning subagents via SDK

cc @thdxr

Originally created by @Gladdonilli on GitHub (Jan 14, 2026). Originally assigned to: @thdxr on GitHub. ## Description Child sessions created via the SDK's `session.create()` and `session.prompt()` accept prompts successfully but never execute them. The server returns a successful response, but no request is ever sent to the AI provider. ## Environment - OpenCode version: 1.1.20 - OS: Windows 11 - Plugin: oh-my-opencode (uses SDK to spawn background agents) ## Steps to Reproduce 1. Create a child session via SDK: ```typescript const createResult = await client.session.create({ body: { parentID: parentSessionID, title: "Background task" }, query: { directory: projectDir }, }) ``` 2. Send a prompt to the child session: ```typescript await client.session.prompt({ path: { id: sessionID }, body: { agent: "explore", model: { providerID: "anthropic", modelID: "claude-sonnet-4" }, parts: [{ type: "text", text: "Find all TypeScript files" }], }, }) ``` 3. Poll for messages - session stays empty forever ## Expected Behavior The child session should execute the prompt and return AI responses. ## Actual Behavior - Session creates successfully ✅ - Prompt returns HTTP 200 with `hasError: false, hasData: true` ✅ - **But `dataPartsCount: 0`** - no messages ever appear - No request reaches the AI provider - Session stays "busy" indefinitely ## Debug Evidence From oh-my-opencode debug logs: ```json {"type":"spawn_prompt_sent","sessionId":"ses_xxx","agent":"explore","model":{"providerID":"antigravity-claude","modelID":"claude-opus-4-5-thinking"},"promptLength":465} {"type":"prompt_response","hasError":false,"hasData":true,"dataPartsCount":0} // Then endless polling with no new messages... {"type":"polling_tick","elapsedMs":120000} ``` ## Regression This worked in **v1.1.14** and broke sometime between v1.1.14 and v1.1.20. Suspicious changes in v1.1.15: - Commit `1954c12`: Added `basicAuth` middleware, changed SDK to use `Server.App().fetch()` directly - Commit `f0912ee`: Renamed `OPENCODE_PASSWORD` to `OPENCODE_SERVER_PASSWORD` ## Hypothesis The v1.1.15 server changes may have broken how external SDK calls (going through HTTP with auth) trigger agent execution. Internal SDK calls (using `Server.App().fetch()` directly) may work, but external HTTP calls don't properly initialize the agent loop. ## Workaround Attempted We're already passing proper Basic Auth headers via custom fetch wrapper: ```typescript const client = createOpencodeClient({ baseUrl: serverUrl, fetch: createAuthenticatedFetch(), // Adds Authorization header bodySerializer: JSON.stringify, }) ``` Auth is working (session creates successfully), but prompts don't execute. ## Impact This breaks all plugins that use background/child sessions, including: - oh-my-opencode's background agent system - Any plugin spawning subagents via SDK cc @thdxr
yindo added the windows label 2026-02-16 17:58:07 -05:00
yindo closed this issue 2026-02-16 17:58:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#5898