Skip to content

ai: Fix provider compatibility for email translation - #3142

Open
gentlemandev wants to merge 1 commit into
mainfrom
fix/translate-schema-provider-compatibility
Open

ai: Fix provider compatibility for email translation#3142
gentlemandev wants to merge 1 commit into
mainfrom
fix/translate-schema-provider-compatibility

Conversation

@gentlemandev

@gentlemandev gentlemandev commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes translation requests that failed before generation when providers rejected array-length JSON Schema constraints. Also makes formatting and blank-entry behavior reliable.

  • validate translation counts after generation instead of emitting unsupported minItems/maxItems
  • normalize whitespace-only entries and strengthen line-structure preservation
  • add Gemini 3.1 Flash Lite eval coverage for translation quality and instruction resistance

Tests:

  • 15 targeted unit tests passed
  • Gemini 3.1 Flash Lite failed-case rerun passed
  • authenticated POST endpoint returned 200 with ordered translations and normalized blank entries

Review in cubic

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
inbox-zero Ignored Ignored Preview Aug 3, 2026 9:07am

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/web/utils/ai/translate-email.ts">

<violation number="1" location="apps/web/utils/ai/translate-email.ts:59">
P2: A model response with the wrong number of translations now fails immediately without the LLM retry or fallback model path. Keeping the count check inside a retryable validation path, or converting the mismatch into the wrapper's recognized validation error, would preserve recovery while avoiding provider-side `minItems`/`maxItems` constraints.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

system,
prompt,
schema: translationSchema(texts.length),
schema: z.object({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: A model response with the wrong number of translations now fails immediately without the LLM retry or fallback model path. Keeping the count check inside a retryable validation path, or converting the mismatch into the wrapper's recognized validation error, would preserve recovery while avoiding provider-side minItems/maxItems constraints.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/utils/ai/translate-email.ts, line 59:

<comment>A model response with the wrong number of translations now fails immediately without the LLM retry or fallback model path. Keeping the count check inside a retryable validation path, or converting the mismatch into the wrapper's recognized validation error, would preserve recovery while avoiding provider-side `minItems`/`maxItems` constraints.</comment>

<file context>
@@ -56,7 +56,13 @@ ${formatTextsForPrompt(truncatedTexts)}`;
     system,
     prompt,
-    schema: translationSchema(texts.length),
+    schema: z.object({
+      translations: z
+        .array(z.string())
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants