Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(agent-providers): a turn the provider rejected fails loud in the room

raullopez-sandboxd8cbdb19f06c
diff --git a/console/packages/agent-providers/src/claude/claude-adapter.test.ts b/console/packages/agent-providers/src/claude/claude-adapter.test.ts
index eae030c8b..2e563e3a2 100644
--- a/console/packages/agent-providers/src/claude/claude-adapter.test.ts
+++ b/console/packages/agent-providers/src/claude/claude-adapter.test.ts
@@ -722,6 +722,28 @@ describe('ClaudeAdapter turn attribution', () => {
expect(recorder.ofType('runtime.error')[0]?.message).toBe('Reached the turn limit');
});
+ it('reports a success result with is_error as an error turn with the error text', async () => {
+ const { sdk, adapter, recorder } = await startSession();
+ await adapter.sendTurn({ sessionId: SESSION, turnId: 'turn-1', text: 'large request' });
+ const query = sdk.latest();
+ const [sent] = await query.waitForSent(1);
+ query.emit(
+ resultMessage([String(sent?.uuid)], {
+ subtype: 'success',
+ is_error: true,
+ result: 'API Error: 400 ... The message size (30296644 bytes) exceeds 30.000MB limit.',
+ })
+ );
+ const done = await recorder.waitFor('turn.completed', () => true, 1_000);
+ expect(done.outcome).toBe('error');
+ expect(done.message).toBe(
+ 'API Error: 400 ... The message size (30296644 bytes) exceeds 30.000MB limit.'
+ );
+ expect(recorder.ofType('runtime.error')[0]?.message).toBe(
+ 'API Error: 400 ... The message size (30296644 bytes) exceeds 30.000MB limit.'
+ );
+ });
+
it('ignores a result for sends this adapter never made', async () => {
const { sdk, adapter, recorder } = await startSession();
await adapter.sendTurn({ sessionId: SESSION, turnId: 'turn-1', text: 'go' });
diff --git a/console/packages/agent-providers/src/claude/claude-mapping.ts b/console/packages/agent-providers/src/claude/claude-mapping.ts
index 23722a94e..c89792c0e 100644
--- a/console/packages/agent-providers/src/claude/claude-mapping.ts
+++ b/console/packages/agent-providers/src/claude/claude-mapping.ts
@@ -156,12 +156,14 @@ export function outcomeForResult(result: SDKResultMessage): TurnOutcome {
if (terminal === 'aborted_streaming' || terminal === 'aborted_tools') return 'interrupted';
const errors = resultErrors(result).join(' ').toLowerCase();
if (errors.includes('interrupt') || errors.includes('request was aborted')) return 'interrupted';
- if (result.subtype === 'success') return 'completed';
+ if (result.subtype === 'success' && !result.is_error) return 'completed';
return 'error';
}
/** `[ede_diagnostic] …` entries are CLI-internal telemetry and must not be shown. */
export function resultMessageText(result: SDKResultMessage): string | undefined {
+ if (result.subtype === 'success' && result.is_error && result.result.trim())
+ return result.result.trim();
return resultErrors(result).find((error) => !error.startsWith('[ede_diagnostic]'));
}
diff --git a/console/packages/agent-providers/src/host/session-host.test.ts b/console/packages/agent-providers/src/host/session-host.test.ts
index acf4663cf..9a9dcbf31 100644
--- a/console/packages/agent-providers/src/host/session-host.test.ts
+++ b/console/packages/agent-providers/src/host/session-host.test.ts
@@ -1479,6 +1479,18 @@ it('says only that a turn failed, and why; nothing for one that finished or was
);
});
+it('adds a !reset hint when the provider refuses the request for size', () => {
+ const hint = '\n\nUse !reset to start a fresh session, then send your message again.';
+ const tooLarge = 'API Error: 400 The message size (30296644 bytes) exceeds 30.000MB limit.';
+ expect(unpostedReply('error', tooLarge)).toBe(
+ `I finished without replying. The turn failed: ${tooLarge}${hint}`
+ );
+ expect(unpostedReply('error', 'Prompt is too long')).toContain(hint);
+ expect(unpostedReply('error', 'Other error')).toBe(
+ 'I finished without replying. The turn failed: Other error'
+ );
+});
+
/**
* One turn, as the provider reports it, with or without its reasoning; what
* the host records and publishes for it, with the per-event noise removed.
diff --git a/console/packages/agent-providers/src/host/session-host.ts b/console/packages/agent-providers/src/host/session-host.ts
index dfc9dc573..492b89c5d 100644
--- a/console/packages/agent-providers/src/host/session-host.ts
+++ b/console/packages/agent-providers/src/host/session-host.ts
@@ -1394,9 +1394,15 @@ export class HostedSession {
export function unpostedReply(outcome: TurnOutcome, detail: string | null): string | null {
if (outcome !== 'error') return null;
const reason = detail?.trim() ? `: ${cap(detail.trim(), 1000)}` : '.';
- return `I finished without replying. The turn failed${reason}`;
+ const message = `I finished without replying. The turn failed${reason}`;
+ return REQUEST_TOO_LARGE.test(detail ?? '')
+ ? `${message}\n\nUse !reset to start a fresh session, then send your message again.`
+ : message;
}
+const REQUEST_TOO_LARGE =
+ /exceeds [\d.]+ ?MB limit|request_too_large|request too large|prompt is too long/i;
+
/** What the host posts for a turn whose every post to the room was refused. */
export function postFailedReply(reason: string): string {
return `I couldn't post my reply here: ${cap(reason.trim(), 1000)}`;