You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
opencode web: child session created with ?directory= returns empty body on POST /session/{id}/message #12271
In opencode web mode, child sessions created via POST /session?directory=/path return HTTP 200 with Content-Length: 0 (empty body) on subsequent POST /session/{id}/message calls. Child sessions created without the directory query parameter work correctly.
Only variable changed is the directory parameter. Everything else (parent session, prompt body, auth) is identical:
POST /session → prompt ✅ body=1261 bytes
POST /session?directory=/home/user/project → prompt ❌ body=0 bytes
POST /session?directory=/home/user → prompt ❌ body=0 bytes
Impact
The oh-my-opencode plugin passes directory when creating subagent sessions to ensure subagents operate in the correct project directory. This bug causes delegate_task (and call_omo_agent, look_at) to fail 100% of the time in opencode web mode. TUI mode is unaffected (presumably uses in-process transport rather than HTTP).
Hi, I've been investigating this and I believe I found the root cause.
Root Cause
The server middleware (server.ts) resolves the Instance context from ?directory= query param or falls back to process.cwd() for every request. When a session is created via POST /session?directory=/path, the session stores directory=/path and projectID for that directory.
However, when POST /session/{id}/message is called without?directory=, the middleware defaults to process.cwd(), creating an Instance context for the wrong directory. Since Instance.state() (used by SessionPrompt, Agent, etc.) is scoped per-directory, the prompt processing runs under the wrong project context. Any error thrown is silently swallowed by Hono's stream() handler, resulting in HTTP 200 with an empty body.
Fix
The session route handlers that process prompts (message, prompt_async, command, shell, summarize) should re-enter the correct Instance context using the session's stored directory before processing:
constsession=awaitSession.get(sessionID)returnInstance.provide({directory: session.directory,asyncfn(){// ... process prompt under correct Instance context},})
This is safe because Instance.provide() caches instances by directory — if the correct instance already exists (which it will for sessions created under the current server's CWD), the cached instance is reused with zero overhead.
I have a working implementation with all 5 affected routes fixed. TypeScript compiles cleanly and all 1286 existing tests pass. Happy to open a PR if this approach looks right.
Activity
github-actions commentedon Feb 5, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
fix: resolve child session directory and add XDG-compliant skill paths (
majiayu000 commentedon Mar 13, 2026
Hi, I've been investigating this and I believe I found the root cause.
Root Cause
The server middleware (
server.ts) resolves theInstancecontext from?directory=query param or falls back toprocess.cwd()for every request. When a session is created viaPOST /session?directory=/path, the session storesdirectory=/pathandprojectIDfor that directory.However, when
POST /session/{id}/messageis called without?directory=, the middleware defaults toprocess.cwd(), creating anInstancecontext for the wrong directory. SinceInstance.state()(used bySessionPrompt,Agent, etc.) is scoped per-directory, the prompt processing runs under the wrong project context. Any error thrown is silently swallowed by Hono'sstream()handler, resulting in HTTP 200 with an empty body.Fix
The session route handlers that process prompts (
message,prompt_async,command,shell,summarize) should re-enter the correctInstancecontext using the session's storeddirectorybefore processing:This is safe because
Instance.provide()caches instances by directory — if the correct instance already exists (which it will for sessions created under the current server's CWD), the cached instance is reused with zero overhead.I have a working implementation with all 5 affected routes fixed. TypeScript compiles cleanly and all 1286 existing tests pass. Happy to open a PR if this approach looks right.
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.