mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-14 13:22:37 +00:00
perf(claude): summarize only the subagent log lines kept after a restart
This commit is contained in:
@@ -113,7 +113,7 @@ function formatSubAgentActionLog(
|
||||
export function readClaudeSubagentActionLog(
|
||||
entries: readonly { type?: unknown; message?: { content?: unknown } }[],
|
||||
): string {
|
||||
const actionsById = new Map<string, { toolName: string; summary?: string }>();
|
||||
const callsById = new Map<string, { toolName: string; input: unknown }>();
|
||||
for (const entry of entries) {
|
||||
const content = entry.type === "assistant" ? entry.message?.content : undefined;
|
||||
if (!Array.isArray(content)) continue;
|
||||
@@ -121,13 +121,18 @@ export function readClaudeSubagentActionLog(
|
||||
if (!isClaudeContentChunk(block) || !isToolUseChunk(block)) continue;
|
||||
const toolName = readTrimmedString(block.name);
|
||||
if (!toolName) continue;
|
||||
const key = readTrimmedString(block.id) ?? `assistant:${toolName}:${actionsById.size}`;
|
||||
if (actionsById.has(key)) continue;
|
||||
const summary = deriveSubAgentActionSummary(toolName, block.input ?? null);
|
||||
actionsById.set(key, { toolName, ...(summary ? { summary } : {}) });
|
||||
const key = readTrimmedString(block.id) ?? `assistant:${toolName}:${callsById.size}`;
|
||||
if (callsById.has(key)) continue;
|
||||
callsById.set(key, { toolName, input: block.input ?? null });
|
||||
}
|
||||
}
|
||||
return formatSubAgentActionLog([...actionsById.values()].slice(-MAX_SUB_AGENT_LOG_ENTRIES));
|
||||
const actions = [...callsById.values()]
|
||||
.slice(-MAX_SUB_AGENT_LOG_ENTRIES)
|
||||
.map(({ toolName, input }) => ({
|
||||
toolName,
|
||||
summary: deriveSubAgentActionSummary(toolName, input),
|
||||
}));
|
||||
return formatSubAgentActionLog(actions);
|
||||
}
|
||||
|
||||
export class ClaudeSidechainTracker {
|
||||
|
||||
Reference in New Issue
Block a user