fix(agentStudio): thread depth error message (#2881)
This commit is contained in:
parent
e7633444f0
commit
f68e52251c
3 changed files with 10 additions and 8 deletions
|
|
@ -19,9 +19,11 @@ describe('isThreadDepthError', () => {
|
|||
expect(isThreadDepthError(new Error('prefix AI-217 suffix'))).toBe(true);
|
||||
});
|
||||
|
||||
it('detects thread depth phrasing without code', () => {
|
||||
expect(isThreadDepthError(new Error('Thread depth exceeded'))).toBe(true);
|
||||
expect(isThreadDepthError(new Error('thread depth limit reached'))).toBe(true);
|
||||
it('detects conversation depth phrasing without code', () => {
|
||||
expect(
|
||||
isThreadDepthError(new Error("You've hit the max conversation depth (4 messages), start a new conversation.")),
|
||||
).toBe(true);
|
||||
expect(isThreadDepthError(new Error('Maximum conversation depth reached.'))).toBe(true);
|
||||
});
|
||||
|
||||
it('detects AI-217 in JSON-shaped error bodies', () => {
|
||||
|
|
@ -68,10 +70,10 @@ describe('filterExchangesForThreadDepthError', () => {
|
|||
describe('getThreadDepthErrorUserFacingMessage', () => {
|
||||
it('returns nested message from JSON-shaped thread depth errors', () => {
|
||||
const body = JSON.stringify({
|
||||
message: 'Conversation has reached its maximum thread depth of 3 messages. Please start a new conversation.',
|
||||
message: "You've hit the max conversation depth (4 messages), start a new conversation.",
|
||||
});
|
||||
expect(getThreadDepthErrorUserFacingMessage(new Error(body))).toBe(
|
||||
'Conversation has reached its maximum thread depth of 3 messages. Please start a new conversation.',
|
||||
"You've hit the max conversation depth (4 messages), start a new conversation.",
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ function messageLooksLikeThreadDepth(message: string): boolean {
|
|||
}
|
||||
|
||||
/**
|
||||
* Whether the error is thread depth exceeded (AI-217), including JSON-shaped Agent Studio payloads.
|
||||
* Whether the error is conversation depth exceeded (AI-217), including JSON-shaped Agent Studio payloads.
|
||||
*/
|
||||
export function isThreadDepthError(error?: Error): boolean {
|
||||
if (!error) return false;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export function extractAiErrorCodeFromMessage(message: string): string | undefin
|
|||
|
||||
/** Plain-text / stringified JSON heuristic; JSON-shaped payloads still use `isThreadDepthError` in `ai.ts`. */
|
||||
export function matchesThreadDepthLimitError(normalizedMessage: string): boolean {
|
||||
return normalizedMessage.includes('ai-217') || /thread\s+depth/.test(normalizedMessage);
|
||||
return normalizedMessage.includes('ai-217') || /conversation\s+depth/i.test(normalizedMessage);
|
||||
}
|
||||
|
||||
/** API copy for domain allowlisting — starting a new conversation does not resolve it. */
|
||||
|
|
@ -223,7 +223,7 @@ export function resolveAgentStudioPromptBlocking(error: Error): {
|
|||
|
||||
/**
|
||||
* Plain-text matchers over `Error.message.toLowerCase()` (callers pass `error.message.toLowerCase()`).
|
||||
* Thread depth: first entry mirrors common plain cases; JSON-shaped payloads still need `isThreadDepthError` in `ai.ts`.
|
||||
* Conversation depth / AI-217: first entry mirrors common plain cases; JSON-shaped payloads still need `isThreadDepthError` in `ai.ts`.
|
||||
*
|
||||
* Blocking UX and “Start new conversation” visibility are driven by `agentStudioPromptBlockingMatchers`.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue