From 5e988b444bcb8f7483ae5cf864e5f08dbfd4c46c Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 12 Nov 2025 21:56:29 +0100 Subject: [PATCH] Remove event logging from session files - only save messages and state changes Session reconstruction only needs: - type: 'session' - session metadata - type: 'message' - conversation history - type: 'thinking_level_change' - thinking level changes - type: 'model_change' - model changes Events like agent_start/end, tool_execution_start/end are not needed for session reconstruction and only added bloat. This reduces session file size significantly and speeds up writes. --- packages/coding-agent/src/main.ts | 7 +------ packages/coding-agent/src/session-manager.ts | 18 +----------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/packages/coding-agent/src/main.ts b/packages/coding-agent/src/main.ts index 1cce7eb7..ec17d7d0 100644 --- a/packages/coding-agent/src/main.ts +++ b/packages/coding-agent/src/main.ts @@ -449,17 +449,12 @@ export async function main(args: string[]) { } } - // Subscribe to agent events to save messages and log events + // Subscribe to agent events to save messages agent.subscribe((event) => { // Save messages on completion if (event.type === "message_end") { sessionManager.saveMessage(event.message); } - - // Log all events except message_update (too verbose) - if (event.type !== "message_update") { - sessionManager.saveEvent(event); - } }); // Route to appropriate mode diff --git a/packages/coding-agent/src/session-manager.ts b/packages/coding-agent/src/session-manager.ts index ffbd40cc..ab96f444 100644 --- a/packages/coding-agent/src/session-manager.ts +++ b/packages/coding-agent/src/session-manager.ts @@ -1,4 +1,4 @@ -import type { AgentEvent, AgentState } from "@mariozechner/pi-agent"; +import type { AgentState } from "@mariozechner/pi-agent"; import { randomBytes } from "crypto"; import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync } from "fs"; import { homedir } from "os"; @@ -27,12 +27,6 @@ export interface SessionMessageEntry { message: any; // AppMessage from agent state } -export interface SessionEventEntry { - type: "event"; - timestamp: string; - event: AgentEvent; -} - export interface ThinkingLevelChangeEntry { type: "thinking_level_change"; timestamp: string; @@ -152,16 +146,6 @@ export class SessionManager { appendFileSync(this.sessionFile, JSON.stringify(entry) + "\n"); } - saveEvent(event: AgentEvent): void { - if (!this.enabled) return; - const entry: SessionEventEntry = { - type: "event", - timestamp: new Date().toISOString(), - event, - }; - appendFileSync(this.sessionFile, JSON.stringify(entry) + "\n"); - } - saveThinkingLevelChange(thinkingLevel: string): void { if (!this.enabled) return; const entry: ThinkingLevelChangeEntry = {