fix(edit): mirror regenerate action-facet fallback in edit_message_sse#803
Open
bdart wants to merge 3 commits into
Open
fix(edit): mirror regenerate action-facet fallback in edit_message_sse#803bdart wants to merge 3 commits into
bdart wants to merge 3 commits into
Conversation
When a user edits a message that was originally sent with an action facet and omits the facet from the edit request, the backend now re-applies the stored facet from the original message's generation_parameters — exactly as the regenerate path has done since commit b86276a. The fallback is re-validated against the CURRENT config and platform before use: if the facet has since been removed from config or became unavailable on the platform, it is dropped with a tracing::warn rather than returning a 400, maintaining parity with the regenerate lane. An explicit action_facet in the edit request still takes precedence over the fallback via .or(fallback_action_facet.as_ref()). Closes ERMAIN-429 Co-authored-by: Daniel <bdart@users.noreply.github.com>
The initial commit read the fallback facet via get_generation_action_facet_from_message which reads from message.generation_parameters — correct for assistant messages, but user messages store their facet payload in message.input_parameters (InputParameters struct) not generation_parameters. Add get_input_action_facet_from_message which reads from input_parameters and use it in edit_message_sse instead. Also apply rustfmt to the two changed files. Co-authored-by: Daniel <bdart@users.noreply.github.com>
0558dbd to
3c2f04b
Compare
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.
Problem
Editing a message that was originally sent with an action facet (e.g.
outlook_rewrite_selectionwithselected_textargs) silently dropped the entire facet context on the re-generated turn. The model received zero facet context, so it behaved as if no selection existed.Root cause:
edit_message_ssemappedrequest.action_facetdirectly with no fallback — unlike theregeneratepath which gained afallback_action_facetblock in commit b86276a. Theaction_facetfield onEditMessageRequestwas wired in commit bb50e35 but the matching backend fallback was never implemented.Solution
Mirror the regenerate fallback exactly inside
edit_message_sse:request.action_facetisNone, read the edited message's stored facet fromgeneration_parametersviaget_generation_action_facet_from_message(&message_to_edit).tracing::warnrather than returning a 400..or(fallback_action_facet.as_ref()), so an explicitaction_facetin the edit request still takes precedence.This is option (a) from the issue — a single backend location that fixes all clients (web, Outlook add-in, any future client) for free.
Changes
backend/erato/src/server/api/v1beta/message_streaming.rs— addfallback_action_facetblock inside the spawned task inedit_message_sse, updatePromptCompositionUserInput.action_facetto use.or(fallback_action_facet.as_ref()).backend/erato/tests/integration_tests/api/edit.rs— two new integration tests:test_edit_falls_back_to_stored_action_facet: submits with arewritefacet, edits without one, asserts the facet appears in the edit'sgeneration_parametersand that the rendered directive reached the LLM in both the original and edit requests.test_edit_drops_stored_action_facet_that_no_longer_validates: same setup but edit runs against a config that no longer declares the facet — asserts the edit succeeds (200) and the generation parameters contain no facet.Closes ERMAIN-429