fix: resample empty provider responses like Grok Build to prevent premature session completion - #42
fix: resample empty provider responses like Grok Build to prevent premature session completion#42Blankeos wants to merge 1 commit into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
2023dcd to
3780c94
Compare
Deploying crabcode with
|
| Latest commit: |
ed6d8e5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7679fe77.crabcode.pages.dev |
| Branch Preview URL: | https://fix-grok-4-6-emptyresponselo.crabcode.pages.dev |
PR Review (updated)
PR: #42 Merge confidence: 4.5/5 (was 3.5/5) Suggested GitHub PR bodyGrok 4.6 (xAI Responses / cli-chat-proxy) was silently ending the session after a reasoning-only This matches Grok Build: classify those payloads as empty ( Also: parse What changed
1 commit: Checks run (read-only)
New tests that passed: Regressions?Covered path is fixed. Reasoning-only / no-visible-content Intentional behavior change: persistent empty completions fail after retries instead of idle-complete. Better than silent stop. Remaining risks (not blockers):
Migrations?No. Merge checklist
Confidence bumps
A 5/5 needs those two edges or a documented “won’t fix” on them. The original silent-finish bug is covered. |
…mature session completion Sessions on xAI/Grok would silently finish after reasoning-only or no-visible-content responses because `response.completed` lacks `end_turn` and phase metadata. The stream treated these as finished turns and stopped the agent loop. This change adds a resample loop in `stream_with_tools` that detects empty completions (no text, no tool calls) and retries the same request, matching Grok Build's `AttemptOutcome::Empty` behavior. Doom loop triggers are now parsed from `ResponseCompleted` payloads and used to inject recovery reminders when reasoning-only samples hit tail repetition. Hosted provider-tool steps and content-filter empties are not resampled. - Extract `doom_loop_triggers_from` and `summarize_response_output_types` in openai.rs - Log `response.completed` with status, end_turn, incomplete_reason, output_types, doom_loop - Add `doom_loop_triggers` field to `ChunkType::ResponseCompleted` - Add retryable patterns for "empty response", "reasoning_only", "no_visible_content" - Add `x-grok-exact-repetition-check` header to xAI build requests - Add tests: `resamples_reasoning_only_completed_response_like_grok_build`, `reasoning_only_with_thinking_doom_loop_resamples_with_reminder`, `resamples_no_visible_content_completed_response`, `empty_response_exhaustion_fails_instead_of_finish`, `content_filter_empty_does_not_resample`, `hosted_tool_only_completed_response_is_not_empty`
3780c94 to
ed6d8e5
Compare
Sessions on xAI/Grok would silently finish after reasoning-only or no-visible-content responses because
response.completedlacksend_turnand phase metadata. The stream treated these as finished turns and stopped the agent loop.This change adds a resample loop in
stream_with_toolsthat detects empty completions (no text, no tool calls) and retries the same request, matching Grok Build'sAttemptOutcome::Emptybehavior. Doom loop triggers are now parsed fromResponseCompletedpayloads and used to inject recovery reminders when reasoning-only samples hit tail repetition.doom_loop_triggers_fromandsummarize_response_output_typesin openai.rsresponse.completedwith status, end_turn, incomplete_reason, output_types, doom_loopdoom_loop_triggersfield toChunkType::ResponseCompletedx-grok-exact-repetition-checkheader to xAI build requestsresamples_reasoning_only_completed_response_like_grok_build,reasoning_only_with_thinking_doom_loop_resamples_with_reminder