Skip to content

Commit f68e522

Browse files
authored
fix(agentStudio): thread depth error message (#2881)
1 parent e763344 commit f68e522

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

packages/docsearch-react/src/utils/__tests__/ai.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ describe('isThreadDepthError', () => {
1919
expect(isThreadDepthError(new Error('prefix AI-217 suffix'))).toBe(true);
2020
});
2121

22-
it('detects thread depth phrasing without code', () => {
23-
expect(isThreadDepthError(new Error('Thread depth exceeded'))).toBe(true);
24-
expect(isThreadDepthError(new Error('thread depth limit reached'))).toBe(true);
22+
it('detects conversation depth phrasing without code', () => {
23+
expect(
24+
isThreadDepthError(new Error("You've hit the max conversation depth (4 messages), start a new conversation.")),
25+
).toBe(true);
26+
expect(isThreadDepthError(new Error('Maximum conversation depth reached.'))).toBe(true);
2527
});
2628

2729
it('detects AI-217 in JSON-shaped error bodies', () => {
@@ -68,10 +70,10 @@ describe('filterExchangesForThreadDepthError', () => {
6870
describe('getThreadDepthErrorUserFacingMessage', () => {
6971
it('returns nested message from JSON-shaped thread depth errors', () => {
7072
const body = JSON.stringify({
71-
message: 'Conversation has reached its maximum thread depth of 3 messages. Please start a new conversation.',
73+
message: "You've hit the max conversation depth (4 messages), start a new conversation.",
7274
});
7375
expect(getThreadDepthErrorUserFacingMessage(new Error(body))).toBe(
74-
'Conversation has reached its maximum thread depth of 3 messages. Please start a new conversation.',
76+
"You've hit the max conversation depth (4 messages), start a new conversation.",
7577
);
7678
});
7779

packages/docsearch-react/src/utils/ai.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function messageLooksLikeThreadDepth(message: string): boolean {
145145
}
146146

147147
/**
148-
* Whether the error is thread depth exceeded (AI-217), including JSON-shaped Agent Studio payloads.
148+
* Whether the error is conversation depth exceeded (AI-217), including JSON-shaped Agent Studio payloads.
149149
*/
150150
export function isThreadDepthError(error?: Error): boolean {
151151
if (!error) return false;

packages/docsearch-react/src/utils/askAiBlockingMatchers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function extractAiErrorCodeFromMessage(message: string): string | undefin
5252

5353
/** Plain-text / stringified JSON heuristic; JSON-shaped payloads still use `isThreadDepthError` in `ai.ts`. */
5454
export function matchesThreadDepthLimitError(normalizedMessage: string): boolean {
55-
return normalizedMessage.includes('ai-217') || /thread\s+depth/.test(normalizedMessage);
55+
return normalizedMessage.includes('ai-217') || /conversation\s+depth/i.test(normalizedMessage);
5656
}
5757

5858
/** API copy for domain allowlisting — starting a new conversation does not resolve it. */
@@ -223,7 +223,7 @@ export function resolveAgentStudioPromptBlocking(error: Error): {
223223

224224
/**
225225
* Plain-text matchers over `Error.message.toLowerCase()` (callers pass `error.message.toLowerCase()`).
226-
* Thread depth: first entry mirrors common plain cases; JSON-shaped payloads still need `isThreadDepthError` in `ai.ts`.
226+
* Conversation depth / AI-217: first entry mirrors common plain cases; JSON-shaped payloads still need `isThreadDepthError` in `ai.ts`.
227227
*
228228
* Blocking UX and “Start new conversation” visibility are driven by `agentStudioPromptBlockingMatchers`.
229229
*/

0 commit comments

Comments
 (0)