From 107aff850c552a8aa543dd27f4c36083c3095e4d Mon Sep 17 00:00:00 2001 From: Dan Shapiro Date: Sun, 22 Feb 2026 12:22:07 -0800 Subject: [PATCH] fix: pass assistantName to container agent instead of hardcoding 'Andy' The container agent-runner had 'Andy' hardcoded as the sender name in archived conversation transcripts. This ignored the configurable ASSISTANT_NAME setting, so users who changed their assistant's name (via .env or config) would still see 'Andy' in transcripts. - Add assistantName field to ContainerInput interface (both host and container copies) - Pass ASSISTANT_NAME from config through to container in index.ts and task-scheduler.ts - Thread assistantName through createPreCompactHook and formatTranscriptMarkdown in the agent-runner - Use 'AssistantNameMissing' as fallback instead of 'Andy' so a missing name is visible rather than silently wrong Co-Authored-By: Claude Opus 4.6 --- container/agent-runner/src/index.ts | 11 ++++++----- src/container-runner.ts | 1 + src/index.ts | 1 + src/task-scheduler.ts | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/container/agent-runner/src/index.ts b/container/agent-runner/src/index.ts index 9579796..05f73dd 100644 --- a/container/agent-runner/src/index.ts +++ b/container/agent-runner/src/index.ts @@ -26,6 +26,7 @@ interface ContainerInput { chatJid: string; isMain: boolean; isScheduledTask?: boolean; + assistantName?: string; secrets?: Record; } @@ -142,7 +143,7 @@ function getSessionSummary(sessionId: string, transcriptPath: string): string | /** * Archive the full transcript to conversations/ before compaction. */ -function createPreCompactHook(): HookCallback { +function createPreCompactHook(assistantName?: string): HookCallback { return async (input, _toolUseId, _context) => { const preCompact = input as PreCompactHookInput; const transcriptPath = preCompact.transcript_path; @@ -172,7 +173,7 @@ function createPreCompactHook(): HookCallback { const filename = `${date}-${name}.md`; const filePath = path.join(conversationsDir, filename); - const markdown = formatTranscriptMarkdown(messages, summary); + const markdown = formatTranscriptMarkdown(messages, summary, assistantName); fs.writeFileSync(filePath, markdown); log(`Archived conversation to ${filePath}`); @@ -252,7 +253,7 @@ function parseTranscript(content: string): ParsedMessage[] { return messages; } -function formatTranscriptMarkdown(messages: ParsedMessage[], title?: string | null): string { +function formatTranscriptMarkdown(messages: ParsedMessage[], title?: string | null, assistantName?: string): string { const now = new Date(); const formatDateTime = (d: Date) => d.toLocaleString('en-US', { month: 'short', @@ -271,7 +272,7 @@ function formatTranscriptMarkdown(messages: ParsedMessage[], title?: string | nu lines.push(''); for (const msg of messages) { - const sender = msg.role === 'user' ? 'User' : 'Andy'; + const sender = msg.role === 'user' ? 'User' : (assistantName || 'AssistantNameMissing'); const content = msg.content.length > 2000 ? msg.content.slice(0, 2000) + '...' : msg.content; @@ -449,7 +450,7 @@ async function runQuery( }, }, hooks: { - PreCompact: [{ hooks: [createPreCompactHook()] }], + PreCompact: [{ hooks: [createPreCompactHook(containerInput.assistantName)] }], PreToolUse: [{ matcher: 'Bash', hooks: [createSanitizeBashHook()] }], }, } diff --git a/src/container-runner.ts b/src/container-runner.ts index 6f66708..ae46a0a 100644 --- a/src/container-runner.ts +++ b/src/container-runner.ts @@ -42,6 +42,7 @@ export interface ContainerInput { chatJid: string; isMain: boolean; isScheduledTask?: boolean; + assistantName?: string; secrets?: Record; } diff --git a/src/index.ts b/src/index.ts index 375f9ce..23422dc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -270,6 +270,7 @@ async function runAgent( groupFolder: group.folder, chatJid, isMain, + assistantName: ASSISTANT_NAME, }, (proc, containerName) => queue.registerProcess(chatJid, proc, containerName, group.folder), wrappedOnOutput, diff --git a/src/task-scheduler.ts b/src/task-scheduler.ts index 0579a8c..01e5336 100644 --- a/src/task-scheduler.ts +++ b/src/task-scheduler.ts @@ -4,6 +4,7 @@ import fs from 'fs'; import path from 'path'; import { + ASSISTANT_NAME, GROUPS_DIR, IDLE_TIMEOUT, MAIN_GROUP_FOLDER, @@ -113,6 +114,7 @@ async function runTask( chatJid: task.chat_jid, isMain, isScheduledTask: true, + assistantName: ASSISTANT_NAME, }, (proc, containerName) => deps.onProcess(task.chat_jid, proc, containerName, task.group_folder), async (streamedOutput: ContainerOutput) => {