v1.3.156
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-safecurrentSessionpointer on REPL, updated atomically throughsessionUpdateCallback. - Exit cleanup used stale
r.model.sessionforCleanupIfEmptyandpersistFullSessionMessages. Fixed by syncingfinalModelafterprogram.Run()returns. - RuntimeStatus reported stale
permission_modefrom the old session snapshot. - LAN Chat
SetSessionIDwas only called at startup, not on/clearor/sessionsswitch. Messages and nick persistence went to the old session's store. Fixed by moving the call intoModel.SetSession(). - Checkpoint/undo was not cleared on session switch —
/undoin a new session could revert the old session's file edits. Fixed by callingcpMgr.Clear()inswitchToSession. - 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 aloadingguard (consistent with/sessionsresume) andCancelAll()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.