Files
EJClaw/src/message-turn-controller-failure-text.test.ts
Codex b3c5a4b41b Show the error reason after the generic failure message
When an agent turn fails, users only saw "요청을 완료하지 못했습니다. 다시
시도해 주세요." with no clue why. Capture the failure reason (explicit
error field, or provider-error text like "API Error: 529 Overloaded"
classified by detectClaudeProviderFailureMessage) in the turn controller
and append it to the failure message ("...\n\n오류 내용: <reason>",
secret-redacted + length-capped). Update the paired-room loop filter to
startsWith so a failure-with-reason is still recognized and not
re-injected into prompt history. Unit-tested.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-08-24 17:10:18 +09:00

44 lines
1.6 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { appendErrorDetailToFailureText } from './message-turn-controller.js';
const BASE = '요청을 완료하지 못했습니다. 다시 시도해 주세요.';
describe('appendErrorDetailToFailureText', () => {
it('returns the base text unchanged when there is no detail', () => {
expect(appendErrorDetailToFailureText(BASE, null)).toBe(BASE);
expect(appendErrorDetailToFailureText(BASE, undefined)).toBe(BASE);
expect(appendErrorDetailToFailureText(BASE, ' ')).toBe(BASE);
});
it('appends the error reason so the user sees what went wrong', () => {
const out = appendErrorDetailToFailureText(
BASE,
'API Error: 529 Overloaded. This is a server-side issue.',
);
expect(out.startsWith(BASE)).toBe(true);
expect(out).toContain('오류 내용:');
expect(out).toContain('API Error: 529 Overloaded');
});
it('collapses whitespace and caps very long detail', () => {
const long = 'API Error: ' + 'x'.repeat(500);
const out = appendErrorDetailToFailureText(BASE, long);
expect(out).toContain('…');
// base + "\n\n오류 내용: " + 300 chars + "…"
expect(out.length).toBeLessThan(BASE.length + 340);
expect(appendErrorDetailToFailureText(BASE, 'a\n\n b\t c')).toContain(
'오류 내용: a b c',
);
});
it('redacts secrets embedded in the error detail', () => {
const out = appendErrorDetailToFailureText(
BASE,
'auth failed with key sk-ant-api03-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
);
expect(out).not.toContain('sk-ant-api03-ABCDEFGHIJKLMNOPQRSTUVWXYZ');
expect(out).toContain('[REDACTED]');
});
});