Skip to content

fix(ai): let slow models use the time research leaves - #69

Merged
Programcode merged 2 commits into
t3code/live-model-e2efrom
t3code/ai-request-budget
Sep 24, 2026
Merged

Programcode merged 2 commits into
t3code/live-model-e2efrom
t3code/ai-request-budget

Conversation

@Programcode

@Programcode Programcode commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Why

The model matrix from #68 generates one case with every catalog model. Claude Opus 5 failed every time: research takes about 30 s, and Opus then needs about 65 to 68 s to write the case, but the ai function aborted each provider call at a fixed 60 s. Every Opus case generation in production returns 500 today. Two direct OpenRouter calls with the same prompt took 68.3 s and 68.7 s.

Claude Sonnet 5, the Pro default, took 55.9 s in the same run, so it fails intermittently under load too.

Change

supabase/functions/ai/index.ts only. Each request gets one 130 s budget (AbortSignal.any of the client's signal and AbortSignal.timeout). Research, the main call, and its JSON repair retry all share it. Supabase answers 504 when a function hasn't responded within 150 s on every plan, so 130 s leaves room for the 8 s post-generation source-usage check, logging, and saving. That check follows only the client's signal, so it cannot turn a finished case into a 500. Before this change, the worst case (30 s research + 60 s call + 60 s repair) could already reach 150 s.

Timeouts still surface as "The signal has been aborted", which the client already maps to its "Request timed out" message.

Evidence

Deploy

After merge this needs supabase functions deploy ai to reach production. Vercel doesn't deploy Edge Functions.

Not fixed here

DeepSeek V4 Flash is unreliable for case generation independent of the timeout. Today it timed out once, passed once at 53 s, and once returned empty content after 8 s.

Stacked on #68; retarget to main after #68 merges.

🤖 Generated with Claude Code

RetriggerConfidence Score: 5/5

No outstanding findings block merging.

Summary

The PR gives AI generation a shared 130-second work budget so slow models can use time left after research. The completed-case source-usage check no longer inherits that budget.

Reviews (2) · Last reviewed commit: "fix(ai): keep a finished case when the s..."

Copilot AI lite review requested due to automatic review settings September 24, 2026 12:02
@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
debate-navigator Ready Ready Preview Sep 24, 2026 12:22pm UTC

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 4e8a2129-8de3-4164-8fe2-b3ec5402ffee

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Essentials by visiting https://app.coderabbit.ai/settings/billing.

Comment @coderabbitai help to get the list of available commands.

Comment thread supabase/functions/ai/index.ts Resolved
@greptile-apps

This comment has been minimized.

Programcode and others added 2 commits September 24, 2026 12:20
Claude Opus 5 needs about 68 s to write a case, so every Opus case
generation hit the 60 s provider timeout and returned 500. Each call now
shares one 140 s request budget, which stays under Supabase's 150 s
response limit. Research, the main call, and its JSON repair retry all use
what is left. The model matrix reproduces the failure and proves the fix.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The post-generation Jev source-usage check shared the request budget, so a
model that finished near the deadline could lose its completed case to a
500. The check now follows only the client's signal and its own 8 s Jev
timeout, and the provider budget drops to 130 s to leave room for it
under Supabase's 150 s limit.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Programcode
Programcode force-pushed the t3code/ai-request-budget branch from 01903a9 to 3334dc2 Compare September 24, 2026 12:20
@Programcode
Programcode merged commit 3334dc2 into t3code/live-model-e2e Sep 24, 2026
11 checks passed

This branch was successfully deployed

1 active deployment
Preview — 3334dc21 Deployed Sep 24, 2026 by vercel[bot]
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