Repository navigation
Description
Summary
Every inline/headless swarm-spawned agent has its memory tool silently and unconditionally forced into isolated test-mode storage, so spawned workers can never read or durably write real project/global memory, regardless of any fix to #491 or #720. This is a distinct bug from those two (different root cause, different fix shape) found while investigating the follow-up the maintainer requested on #720 (verifying the swarm-spawn path).
Root cause
create_headless_session in crates/jcode-app-core/src/server/headless.rs unconditionally calls:
let registry = Registry::new(provider.clone()).await;
registry.enable_memory_test_mode().await;enable_memory_test_mode (crates/jcode-app-core/src/tool/mod.rs) replaces the registry's memory tool with MemoryTool::new_test(), which sets MemoryManager { test_mode: true, .. }. With test_mode: true, project_memory_path() (crates/jcode-base/src/memory.rs) always resolves to ~/.jcode/memory/test/, completely ignoring ctx.working_dir — this is presumably by design for the debug/test harness path, but create_headless_session is also the production code path for real swarm-spawned agents:
// crates/jcode-app-core/src/server/comm_session.rs:654-680
let (new_session_id, is_headless_fallback) = match visible_spawn {
Ok((new_session_id, true)) => Ok((new_session_id, false)),
Ok((_, false)) | Err(_) => {
...
create_headless_session(
sessions, global_session_id, provider_template, &cmd,
swarm_members, swarms_by_id, swarm_coordinators, swarm_plans,
soft_interrupt_queues, coordinator_is_canary, spawn_model.clone(),
spawn_provider_key.clone(), spawn_route_api_method.clone(),
spawn_effort.clone(), Some(Arc::clone(mcp_pool)),
Some(req_session_id.to_string()),
)
.await
...This is reached whenever a visible (windowed) spawn isn't used or falls back, i.e. the default agents.swarm_spawn_mode = "inline" config, and likely headless mode too. There is no parameter distinguishing "this is a debug-socket admin create_session command" (debug_session_admin.rs, where isolated test storage is presumably intentional) from "this is a real swarm-spawned worker" (comm_session.rs, where it should use real memory scoped to the spawn's working dir).
Reproduce
-
In an interactive session at directory D, write a project-scoped memory via the memory tool: action=remember, content="probe", scope="project". Confirm it's durably written to ~/.jcode/memory/projects/<hash-of-D>.json.
-
From the same session, spawn a swarm agent in the same directory (swarm spawn, inline/headless mode, the default). From the spawned agent, run memory action=search query="probe" and memory action=list scope="all". Both return empty, despite the store containing the entry and ctx.working_dir correctly matching the parent session's directory (confirmed via swarm status).
-
~/.jcode/memory/test/ (not projects/<hash>.json) is where the spawned agent's writes/reads actually land, because test_mode: true short-circuits project_memory_path() before ctx.working_dir/with_project_dir is ever consulted.
Suggested fix
Thread an explicit flag (e.g. is_debug_admin_session: bool) through create_headless_session's callers so:
- debug_session_admin.rs (debug socket create_session admin commands) continues to opt into enable_memory_test_mode().
- comm_session.rs's real swarm-spawn call site does not, and instead lets the spawned agent's real MemoryTool (scoped by ctx.working_dir, per the memory tool silently drops all project-scoped memories (remember acks, list/search return empty) #491/jcode memory CLI subcommand (list/search/export/import/stats) ignores working dir, project scope always empty (regression class of #491) #720 fix) operate normally.
Related
- memory tool silently drops all project-scoped memories (remember acks, list/search return empty) #491 fixed the in-agent memory tool's project-dir scoping (unscoped MemoryManager::new() in MemoryTool::new()).
- jcode memory CLI subcommand (list/search/export/import/stats) ignores working dir, project scope always empty (regression class of #491) #720 is the same defect class, recurring in the jcode memory CLI subcommand.
- This issue is neither of those: it's test-mode storage being force-enabled for a production code path, not a scoping omission. Found while verifying the swarm-spawn path per the maintainer's request on jcode memory CLI subcommand (list/search/export/import/stats) ignores working dir, project scope always empty (regression class of #491) #720.
Environment
- macOS (aarch64), jcode v0.64.2 (6c6fbba) / master, agents.swarm_spawn_mode = "inline" (default).
Activity
fix(swarm): spawned workers keep real memory instead of test storage (f…
1jehuang commentedon Aug 2, 2026
Confirmed and fixed. Thanks for taking the #720 follow-up seriously enough to find a genuinely separate bug.
Verified the root cause exactly as you describe. What makes it especially clear is that
enable_memory_test_mode's own doc comment says "Called when session is marked as debug", yetcreate_headless_sessioncalled it unconditionally, and that same function is the production path for real swarm workers. The comment describes the intended contract; the code had quietly stopped honouring it.Fix follows your suggestion: isolation is now an explicit parameter, set by each caller.
debug_session_admin.rs(debug-socket admin sessions):true, isolation is the point there.comm_session.rs(real swarm spawns, i.e. the default inline mode and headless):false, so workers keep real project/global memory scoped to their working directory.Confirmed those are the only two callers, so the change is fully enumerated rather than a guess.
You are right that this is distinct from #491 and #720: those fix working-dir scoping in paths that never reach this override, so neither would have helped here. #720 remains open and is a real bug on its own.
Commit:
3e8550913, shipping in #727.--- — Jcode agent (automated triage), on behalf of @1jehuang
test(memory): pin that test mode ignores the project dir (refs #729)
1jehuang commentedon Aug 2, 2026
Follow-up: added a test that pins the invariant behind this bug, so the severity of the override stays visible.
The test asserts that a
MemoryManagerin test mode cannot see real project memory even when handed the correct project directory, and that a non-test manager on that same directory does see it. That isolates the cause to test mode itself rather than to a bad path, which is the precise mechanism you identified:project_memory_path()short-circuits before the directory is ever consulted.That test passes, and the full memory suite is green at 82 tests.
Together with the fix, the failure you reported can no longer happen silently: enabling test mode on a production path would now have to be an explicit decision at the call site, and its consequence is documented by a test rather than buried in a function whose doc comment said "called when session is marked as debug" while being called unconditionally.
Commit:
3e8550913(fix),f0df4784f(invariant test).--- — Jcode agent (automated triage), on behalf of @1jehuang
refactor(swarm): make the headless memory scope a named choice (refs #…
1jehuang commentedon Aug 2, 2026
One more hardening pass on this, prompted by your point that the two call sites needed to be distinguishable.
The isolation flag is no longer a bare
bool. A boolean at a call site is one typo away from silently reintroducing exactly this bug, and the original defect had that shape: an unconditional call whose intent lived only in a comment on the function being called. The call sites now state their intent:So picking the wrong one is hard to do by accident and obvious in review, and the enum's own docs record why real swarm workers must never get throwaway storage.
Combined with the invariant test from the previous comment, the failure you found is now guarded at three levels: the call sites name their choice, the enum documents the consequence, and a test proves test mode cannot see real project memory even with the correct working directory.
Commits:
3e8550913(fix),f0df4784f(invariant test),d3303bad6(named choice).--- — Jcode agent (automated triage), on behalf of @1jehuang
test(memory): behavioral proof that a swarm worker sees spawner memor…
Merge upstream (451 commits) while keeping our fork's feature work
11 remaining items
refactor(swarm): make the headless memory scope a named choice (refs 1…
test(memory): behavioral proof that a swarm worker sees spawner memor…
fix(swarm): spawned workers keep real memory instead of test storage (f…
test(memory): pin that test mode ignores the project dir (refs 1jehua…
refactor(swarm): make the headless memory scope a named choice (refs 1…
test(memory): behavioral proof that a swarm worker sees spawner memor…
fix(swarm): spawned workers keep real memory instead of test storage (f…
test(memory): pin that test mode ignores the project dir (refs 1jehua…
refactor(swarm): make the headless memory scope a named choice (refs 1…
test(memory): behavioral proof that a swarm worker sees spawner memor…
fix(swarm): spawned workers keep real memory instead of test storage (f…
test(memory): pin that test mode ignores the project dir (refs 1jehua…
refactor(swarm): make the headless memory scope a named choice (refs 1…
test(memory): behavioral proof that a swarm worker sees spawner memor…
Triage batch: fixes for 1jehuang#712, 1jehuang#715, 1jehuang#719, 1je…