Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(evals): handle invalid JSON error if maxTokens too low (#5289)

Hassieb Pakzadb302e8eb9603
diff --git a/worker/src/queues/evalQueue.ts b/worker/src/queues/evalQueue.ts
index 8fe58efc6c..6676c429e8 100644
--- a/worker/src/queues/evalQueue.ts
+++ b/worker/src/queues/evalQueue.ts
@@ -115,6 +115,8 @@ export const evalJobExecutorQueueProcessor = async (
(e instanceof BaseError && e.message.includes("API key for provider")) || // api key not provided
(e instanceof ApiError && e.httpCode >= 400 && e.httpCode < 500) || // do not error and retry on 4xx errors. They are visible to the user in the UI but do not alert us.
(e instanceof ApiError && e.message.includes("TypeError")) || // Zod parsing the response failed. User should update prompt to consistently return expected output structure.
+ (e instanceof ApiError &&
+ e.message.includes("Error: Unterminated string in JSON at position")) || // When evaluator model is configured with too low max_tokens, the structured output response is invalid JSON
(e instanceof BaseError &&
e.message.includes(
"Please ensure the mapped data exists and consider extending the job delay.",