Skip to content

fix(context): accept blank provider responses#98

Merged
omarluq merged 1 commit into
mainfrom
fix/blank-provider-responses
Jun 8, 2026
Merged

fix(context): accept blank provider responses#98
omarluq merged 1 commit into
mainfrom
fix/blank-provider-responses

Conversation

@omarluq

@omarluq omarluq commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • treat successful blank provider outputs as valid assistant responses
  • stop retrying generic empty-response parser results
  • add coverage for blank OpenAI/Anthropic responses and runtime persistence

Tests

  • go test ./internal/assistant
  • golangci-lint run ./internal/assistant
  • task ci

@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.37%. Comparing base (b13db37) to head (f62bcd4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
+ Coverage   70.34%   70.37%   +0.02%     
==========================================
  Files         224      223       -1     
  Lines       20060    20057       -3     
==========================================
+ Hits        14112    14115       +3     
+ Misses       4752     4748       -4     
+ Partials     1196     1194       -2     
Flag Coverage Δ
unittests 70.37% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@omarluq

omarluq commented Jun 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@omarluq omarluq merged commit 02bf481 into main Jun 8, 2026
14 checks passed
@omarluq omarluq deleted the fix/blank-provider-responses branch June 8, 2026 20:16
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 030959f5-cbc0-4dca-afb3-26c2042d535e

📥 Commits

Reviewing files that changed from the base of the PR and between b13db37 and f62bcd4.

📒 Files selected for processing (9)
  • internal/assistant/anthropic.go
  • internal/assistant/empty_response_internal_test.go
  • internal/assistant/errors_extra.go
  • internal/assistant/openai_chat.go
  • internal/assistant/openai_responses.go
  • internal/assistant/retry.go
  • internal/assistant/retry_test.go
  • internal/assistant/runtime_test.go
  • internal/assistant/tool_loop.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of empty provider responses to be accepted and properly finalized instead of triggering unnecessary retries or errors.
  • Tests

    • Expanded test coverage for empty response scenarios across multiple provider types, including validation of proper completion behavior without retry attempts.

Walkthrough

The PR refactors empty provider response handling from error rejection to graceful acceptance. The finishTextResult function is simplified to accept empty text, provider parsers return successful results instead of errors, and retry logic no longer flags empty responses as retryable failures.

Changes

Empty Response Handling Refactor

Layer / File(s) Summary
Simplify finishTextResult to accept empty text
internal/assistant/tool_loop.go, internal/assistant/empty_response_internal_test.go
finishTextResult signature is updated to remove the emptyCode parameter, allowing the function to accept and process empty or whitespace-only text without triggering a provider-specific error. A unit test validates this behavior.
Update provider parsers to return empty results
internal/assistant/empty_response_internal_test.go, internal/assistant/openai_chat.go, internal/assistant/openai_responses.go, internal/assistant/anthropic.go
Provider-specific parsing functions across OpenAI Chat, OpenAI Responses, and Anthropic now return successful providerResult objects with empty text instead of errors. Loop completion logic is updated to work with the simplified finishTextResult signature. Table-driven tests validate all provider parsers accept empty responses successfully.
Remove empty responses from retryable error patterns
internal/assistant/retry.go, internal/assistant/retry_test.go
retryableProviderCode and retryableProviderMessage are narrowed to remove empty-response codes and message patterns from their retryable sets. Related test cases are removed and a new billing token limit test case is added.
Validate empty responses persist without retry
internal/assistant/runtime_test.go
Runtime-level integration test confirms that empty provider completions are persisted to the session without triggering a retry, validating the full flow accepts empty responses end-to-end.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • omarluq/librecode#32: Both PRs touch the assistant's tool-loop and text-tool handling around finishTextResult and empty-response behavior in internal/assistant/tool_loop.go and advanceAnthropicLoop paths.
  • omarluq/librecode#42: Both PRs modify internal/assistant/retry.go's retryability logic in retryableProviderMessage and provider error-code handling.
  • omarluq/librecode#45: Both PRs directly change the core provider request/completion loop logic in internal/assistant at the same execution points.

Poem

🐰 Empty responses need not fear,
No error codes to make us tear,
Just finish clean and let them be,
A graceful null, wild and free!
No retry loops, just persist the peace—
Sometimes silence is release. 🌙

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/blank-provider-responses

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

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