Skip to content

fix: fall back to upstream when compaction summary generation fails#392

Merged
BYK merged 1 commit into
mainfrom
fix/compaction-fallback
May 19, 2026
Merged

fix: fall back to upstream when compaction summary generation fails#392
BYK merged 1 commit into
mainfrom
fix/compaction-fallback

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 19, 2026

Summary

When the worker model is unavailable (429 rate limits, auth errors, etc.), the gateway now gracefully falls back to forwarding the compaction request to the upstream API instead of returning a bogus error string to the client.

Problem

generateCompactionSummary() returned "(Compaction failed — no summary generated.)" when llm.prompt() returned null (worker model 429, 401, or network failure). This string was wrapped in a synthetic 200 OK response and displayed to the user as their compacted conversation content.

Sentry: LOREAI-GATEWAY-4 — 1,758 events of Worker upstream exhausted 3 retries: 429 Too Many Requests, last seen today.

Changes

  • generateCompactionSummary() now returns string | null — returns null on failure with a warning log instead of a bogus error string
  • handleCompaction() checks for null and falls back to handlePassthrough(req, config), forwarding the original compaction request to the upstream API so the client still gets a proper response
  • handleCompactEndpoint() (Pi plugin's explicit /v1/compact) returns a proper 502 JSON error instead of a null summary
  • Updated compaction test to verify the upstream fallback path

@BYK BYK self-assigned this May 19, 2026
@BYK BYK force-pushed the fix/compaction-fallback branch from 8f6ff7e to 7044cd5 Compare May 19, 2026 15:27
When the worker model is unavailable (429 rate limits, auth errors, etc.),
generateCompactionSummary() now returns null instead of a bogus error string.
handleCompaction() detects null and falls back to forwarding the original
compaction request to the upstream API via handlePassthrough(), so the client
still gets a proper compaction response.

Also handles the explicit /v1/compact endpoint (Pi plugin) with a proper
502 error response instead of returning null as the summary text.

Fixes LOREAI-GATEWAY-4 (1758 events of worker 429 failures producing
"(Compaction failed — no summary generated.)" in Claude Code).
@BYK BYK force-pushed the fix/compaction-fallback branch from 7044cd5 to fd8f0b8 Compare May 19, 2026 15:28
@BYK BYK merged commit 0cbe44e into main May 19, 2026
10 checks passed
@BYK BYK deleted the fix/compaction-fallback branch May 19, 2026 15:31
This was referenced May 21, 2026
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.

1 participant