Merge pull request #1191 from moktamd/fix/redact-prompt-from-error-logs

security: stop logging user prompt content on container errors
This commit is contained in:
gavrielc
2026-03-19 21:03:16 +02:00
committed by GitHub
2 changed files with 18 additions and 4 deletions

View File

@@ -503,10 +503,24 @@ export async function runContainerAgent(
const isError = code !== 0; const isError = code !== 0;
if (isVerbose || isError) { if (isVerbose || isError) {
// On error, log input metadata only — not the full prompt.
// Full input is only included at verbose level to avoid
// persisting user conversation content on every non-zero exit.
if (isVerbose) {
logLines.push( logLines.push(
`=== Input ===`, `=== Input ===`,
JSON.stringify(input, null, 2), JSON.stringify(input, null, 2),
``, ``,
);
} else {
logLines.push(
`=== Input Summary ===`,
`Prompt length: ${input.prompt.length} chars`,
`Session ID: ${input.sessionId || 'new'}`,
``,
);
}
logLines.push(
`=== Container Args ===`, `=== Container Args ===`,
containerArgs.join(' '), containerArgs.join(' '),
``, ``,

View File

@@ -221,7 +221,7 @@ async function processGroupMessages(chatJid: string): Promise<boolean> {
: JSON.stringify(result.result); : JSON.stringify(result.result);
// Strip <internal>...</internal> blocks — agent uses these for internal reasoning // Strip <internal>...</internal> blocks — agent uses these for internal reasoning
const text = raw.replace(/<internal>[\s\S]*?<\/internal>/g, '').trim(); const text = raw.replace(/<internal>[\s\S]*?<\/internal>/g, '').trim();
logger.info({ group: group.name }, `Agent output: ${raw.slice(0, 200)}`); logger.info({ group: group.name }, `Agent output: ${raw.length} chars`);
if (text) { if (text) {
await channel.sendMessage(chatJid, text); await channel.sendMessage(chatJid, text);
outputSentToUser = true; outputSentToUser = true;