-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Part of #974
Background
Claude Code assigns each sub-agent invocation a unique ID and stores the full conversation transcript. A subsequent call can resume from an existing transcript, preserving tool results, intermediate reasoning, and multi-turn history. This is essential for long-running background agents that may be interrupted, and for audit/replay.
Current state in Zeph
SubAgentManager tracks status (running, completed, failed) per agent instance via a HashMap<AgentId, AgentHandle>. No transcript is persisted to disk. When an agent completes or the process exits, all context is lost.
Implementation
-
Transcript model: define
AgentTranscript { id: AgentId, name: String, started_at: DateTime<Utc>, messages: Vec<Message>, status: AgentStatus }. Serialize to JSON. -
Storage: persist transcripts under
{data_dir}/zeph/agents/transcripts/{id}.jsonusing async write after each turn. Usetokio::fsfor non-blocking I/O. -
AgentId generation: use
uuid::Uuid::new_v4()— already a workspace dep. -
Resume API: add
SubAgentManager::resume(id: AgentId) -> Result<AgentHandle>that loads transcript and injects it as initial conversation history into the new LLM session. -
CLI flag:
--resume <agent-id>for theagent runsubcommand. -
Transcript listing:
SubAgentManager::list_transcripts() -> Vec<TranscriptMeta>for TUI/CLI display. -
TTL cleanup: transcripts older than
transcript_ttl_days(config, default 30) are deleted on startup.
Acceptance criteria
- Each sub-agent run is assigned a stable
AgentId(UUID v4). - Transcript is written to disk after each turn (not just at completion).
-
SubAgentManager::resume(id)successfully restores message history. -
--resume <id>CLI flag works end-to-end. - Transcripts older than TTL are pruned at startup.
- Unit tests: write transcript, read it back, verify message count.
-
cargo nextest run -p zeph-corepasses.
Technical notes
- Use
serde_jsonfor transcript serialization (already a dep). data_dirresolution:dirs::data_dir()+"zeph", configurable viaZEPH_DATA_DIRenv ordata_dirconfig key.- Keep transcript writes non-blocking: spawn a
tokio::task::spawnper write, do not await in hot path. - The
Messagetype is already defined inzeph-llm; reference it fromzeph-corevia the existing dependency.