Skip to content

v1.3.156

Choose a tag to compare

@topcheer topcheer released this 16 Jul 15:44

ggcode v1.3.156

Highlights

Named subagents

Define and invoke reusable subagent roles with persistent per-workspace templates. The LLM can now create specialized agents (e.g. "code-reviewer", "test-writer") with custom system prompts, tool allowlists/denylists, MCP server bindings, and model overrides — then reuse them across sessions via use_namedagent.

Tools: create_namedagent, use_namedagent, list_namedagent, delete_namedagent.

Templates are stored under ~/.ggcode/subagents/<workspace-hash>/ and automatically injected into the system prompt on startup.

Session persistence — incremental append only

Session Save() was refactored to never rewrite the JSONL file. Messages are now persisted exclusively via incremental appends (AppendMessageToDisk). This eliminates a data-loss path where compaction would replace ses.Messages in memory, and a subsequent Save() call would overwrite pre-compaction history on disk.

Fixes and improvements

Session switch stale references (critical)

Fixed multiple bugs where /clear and /sessions switch left subsystems bound to the old session:

  • persistHandler/checkpointHandler wrote messages to the old session's JSONL file because r.model (a Bubble Tea value-type copy) always returned the initial session. Fixed via thread-safe currentSession pointer on REPL, updated atomically through sessionUpdateCallback.
  • Exit cleanup used stale r.model.session for CleanupIfEmpty and persistFullSessionMessages. Fixed by syncing finalModel after program.Run() returns.
  • RuntimeStatus reported stale permission_mode from the old session snapshot.
  • LAN Chat SetSessionID was only called at startup, not on /clear or /sessions switch. Messages and nick persistence went to the old session's store. Fixed by moving the call into Model.SetSession().
  • Checkpoint/undo was not cleared on session switch — /undo in a new session could revert the old session's file edits. Fixed by calling cpMgr.Clear() in switchToSession.
  • Sub-agent/swarm were not cancelled on /clear — running agents continued in the background and their results were routed to the new session. Fixed by adding a loading guard (consistent with /sessions resume) and CancelAll() for both sub-agents and swarm teammates.

Orphaned IM adapter bindings

When an empty session is deleted during exit cleanup, IM adapter bindings referencing that session's LastSessionID become orphaned — no new ggcode instance would auto-claim them. Fixed by adding ClearSessionBindings / ClearSessionBindingsGlobal to clear LastSessionID for all affected bindings, called from both TUI and desktop exit paths.

Upgrade notes

  • No breaking changes. All fixes are backward-compatible.
  • Session JSONL files from previous versions are fully compatible — the incremental append model is a superset of the old behavior.
  • Named subagent templates are created on-demand; existing workspaces without templates are unaffected.

Compare

Full changelog