fix: preserve checkpoints after failed LLM requests#9359
Open
wcqqq1214 wants to merge 1 commit into
Open
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
wcqqq1214
marked this pull request as ready for review
July 23, 2026 07:43
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
_save_to_historybranch for failed/non-assistant responses duplicates the message filtering and checkpoint-handling logic that the assistant-success path uses; consider extracting this into a shared helper to keep the behavior consistent and reduce maintenance overhead. - The conditionals guarding the different save/return paths in
_save_to_history(not user_aborted,llm_response is None,llm_response.role != "assistant", etc.) are now fairly intricate; adding a brief inline comment or restructuring to make the intent of each branch (success vs failure vs abort) clearer would help future readers avoid misinterpreting the flow. - In
test_failed_llm_response_persists_checkpoint_for_retry, consider also asserting that no assistant message containing the failedcompletion_textis stored in the conversation history to more directly lock in the requirement that upstream error text is excluded.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `_save_to_history` branch for failed/non-assistant responses duplicates the message filtering and checkpoint-handling logic that the assistant-success path uses; consider extracting this into a shared helper to keep the behavior consistent and reduce maintenance overhead.
- The conditionals guarding the different save/return paths in `_save_to_history` (`not user_aborted`, `llm_response is None`, `llm_response.role != "assistant"`, etc.) are now fairly intricate; adding a brief inline comment or restructuring to make the intent of each branch (success vs failure vs abort) clearer would help future readers avoid misinterpreting the flow.
- In `test_failed_llm_response_persists_checkpoint_for_retry`, consider also asserting that no assistant message containing the failed `completion_text` is stored in the conversation history to more directly lock in the requirement that upstream error text is excluded.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9358.
Modifications
Test Results
uv run pytest tests/test_conversation_checkpoint.py -q— 12 passed.uv run pytest -q— 1855 passed, 6 warnings.uv run ruff format .— passed.uv run ruff check .— passed.scripts/pr_test_env.sh --profile neo --skip-sync --skip-lint— 12 passed and startup smoke test passed.The full fast profile also exposed two unrelated
pip_installertest failures caused by itslog_cli=trueoutput-capture combination; those tests pass when run independently.Checklist
Summary by Sourcery
Ensure conversation checkpoints and history are persisted when LLM requests fail or return non-assistant responses, without saving failed response content to assistant history.
Bug Fixes:
Enhancements:
Tests: