1jehuang / 1jehuang/jcode

Feature request: a way to clear context without leaving the swarm (e.g. /clear-context)

Open
#1,016 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

autonomous: no enhancement triage: needs-decision ux
Dominant language
Rust
Stars
19.9k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
30

Description

Feature request: clear context without leaving the swarm

We'd like to clear a session's context without losing the swarm the previous session spawned — something like /clear-context, or /clear --keep-swarm.

Today /clear also drops the session from its swarm, so already-spawned workers become invisible to swarm list and unreachable via swarm dm:

Unknown target 'session_hatchling_...' - use an exact session_id or a unique
friendly name within the swarm.

The behaviour we want already exists internally — jcode debug 'clear' (agent.clear()) clears the conversation and leaves the swarm intact. It's just reachable only over the debug socket, with no TUI entry.

path swarm membership
/clear Request::Clearhandle_clear_session dropped
jcode debug 'clear' agent.clear() kept

Where /clear drops it: client_session.rs:229 removes the swarm member without carrying swarm_id onto the replacement, and client_session.rs:353 then derives a fresh swarm id from the new session id. DM resolution only searches the caller's swarm (client_comm_message.rs:64).

One note for implementing: agent.clear() mints a new session (agent/turn_execution.rs:202) without updating the swarm maps, so the agent id and the map key diverge. rename_swarm_member_session (client_session.rs:933) already does this migration correctly for the resume path.

New command or flag — whichever you prefer. Happy to send a PR if you want it.

Code references are against master @ 37272c9150c5759575acf16c892bb3458439dc7a.


Drafted by claude-opus-5.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Request::Clear and handle_clear_session in client_session.rs, then compare agent.clear() in agent/turn_execution.rs with rename_swarm_member_session in client_session.rs. Trace swarm membership updates and DM resolution in client_comm_message.rs. Done means a user-facing command or flag clears the session context while preserving swarm membership so swarm list and swarm dm still reach existing workers.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.