Repository navigation
Description
Summary
jcode acp advertises loadSession: true and sessionCapabilities.resume in its
initialize response, but session/resume always fails when it is the first
stateful request on a connection:
Client must Subscribe with a working_dir before sending stateful requests (code=-32603)
Impact
Any ACP client that resumes a session (a second task in the same conversation
thread, "continue", IDE reconnect, etc.) cannot work. The first task on a fresh
session/new succeeds; the next one that tries session/resume fails.
We hit this from a client that keeps one conversation per issue and resumes the
session for every follow-up task: the first task passes, every subsequent task in
the thread fails.
Root cause
The jcode daemon requires the first request on a connection to be
Subscribe { working_dir: <absolute path> }; any stateful request before that is
rejected. See
crates/jcode-app-core/src/server/client_lifecycle.rs:
fn initial_subscribe_working_dir(request: &Request) -> Result<String, String> {
match request {
Request::Subscribe { working_dir, .. } => {
required_subscribe_working_dir(working_dir.as_deref()).map(str::to_string)
}
_ => Err(
"Client must Subscribe with a working_dir before sending stateful requests".to_string(),
),
}
}In src/cli/acp.rs, create_new_session correctly subscribes first:
session
.send(&Request::Subscribe {
id: subscribe_id,
working_dir: Some(cwd.display().to_string()),
selfdev: None,
target_session_id: None,
client_instance_id: Some("acp".to_string()),
client_has_local_history: false,
allow_session_takeover: false,
terminal_env: crate::terminal_launch::snapshot_client_terminal_env(),
})
.await?;but attach_existing_session (used by session/resume and session/load) sends a
bare Request::ResumeSession as the opening request:
let resume_id = 1;
session
.send(&Request::ResumeSession {
id: resume_id,
session_id: target_session_id.clone(),
client_instance_id: Some("acp".to_string()),
client_has_local_history: false,
allow_session_takeover: false,
})
.await?;That is the first thing the server sees on this connection, so it returns the
-32603 error above.
Suggested fix
Subscribe with target_session_id before (or instead of) the bare
ResumeSession. The server already handles resume inside Subscribe when
target_session_id is set: client_lifecycle.rs calls handle_resume_session
and then handle_subscribe, emitting History + Done. This is the same shape
create_new_session uses, so attach_existing_session should do:
session
.send(&Request::Subscribe {
id: resume_id,
working_dir: Some(cwd.display().to_string()),
selfdev: None,
target_session_id: Some(target_session_id.clone()),
client_instance_id: Some("acp".to_string()),
client_has_local_history: false,
allow_session_takeover: false,
terminal_env: crate::terminal_launch::snapshot_client_terminal_env(),
})
.await?;The _cwd parameter of attach_existing_session should also be used (rename to
cwd) instead of being ignored, since the working directory is now required.
Steps to reproduce
jcode acp --provider <provider> --model <model> --tool-profile full- Send over stdin:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1,"clientInfo":{"name":"t","version":"1"},"clientCapabilities":{}}} {"jsonrpc":"2.0","id":2,"method":"session/new","params":{"cwd":"/tmp"}} - Capture the returned
sessionId, run asession/prompt, then send:{"jsonrpc":"2.0","id":3,"method":"session/resume","params":{"sessionId":"<captured>","cwd":"/tmp"}} - Observe:
{"id":3,"jsonrpc":"2.0","error":{"code":-32603,"message":"Client must Subscribe with a working_dir before sending stateful requests"}}
Environment
- jcode v0.67.1 (also present on master
src/cli/acp.rs) - Linux x86_64
- ACP protocolVersion 1
Activity
maxivillus commentedon Aug 4, 2026
Related:
session/set_modelis also unimplementedThe ACP handler in
src/cli/acp.rsonly implementsinitialize,session/new,session/load,session/resume,session/prompt,session/cancel,session/close, and_-prefixed extensions. A client that callssession/set_model(e.g. to switch models per task, as Multica does from theagent card) gets
Method not found. The daemon protocol already supports thisvia
Request::SetModel { id, model }(withServerEvent::ModelChanged), so theACP layer could forward it directly.
While here: accepting a reasoning-effort override (env var such as
JCODE_REASONING_EFFORTmapped toRequest::SetReasoningEffort, which thedaemon already supports) would let ACP clients control DeepSeek/OpenAI thinking
mode. Happy to open these as separate issues or extend this PR.
1jehuang commentedon Aug 4, 2026
The root cause is confirmed: ACP opened a fresh daemon connection with
ResumeSession, but the daemon requiresSubscribewith an absolute working directory as the first stateful request. PR #781 changes the attach path to subscribe with the request cwd and target session ID. The targeted ACP test build passes.--- — Jcode agent (automated triage), on behalf of @1jehuang
fix: subscribe before ACP session attach (fixes 1jehuang#779)
fix: subscribe before ACP session attach (fixes 1jehuang#779)
fix: subscribe before ACP session attach (fixes 1jehuang#779)
fix: subscribe before ACP session attach (fixes 1jehuang#779)
fix: subscribe before ACP session attach (fixes 1jehuang#779)
fix: subscribe before ACP session attach (fixes 1jehuang#779)
fix: subscribe before ACP session attach (fixes 1jehuang#779)