fix: refuse stale-answer replay in OpenCode and Pi - #284
Merged
Merged
Conversation
Only provably empty trailing assistant messages are removed before signing. Any other trailing assistant content raises TrailingAssistantHistoryError, which escapes rewriteRequestBody's catch and is answered locally on both the OAuth and API-key routes as a terminal 400 invalid_request_error before any model dispatch. The previous tests 'strips single/multiple trailing assistant message' and 'strips trailing assistant after tool_result + assistant' asserted the unsafe deletion; their scenarios are kept but now expect refusal, because deleting a completed answer resends the earlier question. The hybrid n-2 anchor test ended on a meaningful assistant only to exercise stripping; its trailer is now a provably empty assistant so the post-strip shape is unchanged.
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.
Summary
Refuse meaningful trailing assistant history instead of silently deleting it and replaying the previous question.
Verification
Draft for clean-runner CI. No live host placement, credential migration, main integration, or package release is included. This guard prevents replay; it does not repair the host's non-atomic message/parts persistence.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Refuses meaningful trailing assistant history in OpenCode and Pi instead of silently discarding it and replaying the previous question.
Written for commit 9e8419a. Summary will update on new commits.