Skip to content

fix(edit): mirror regenerate action-facet fallback in edit_message_sse#803

Open
bdart wants to merge 3 commits into
mainfrom
feat/edit-message-action-facet-fallback-c3de
Open

fix(edit): mirror regenerate action-facet fallback in edit_message_sse#803
bdart wants to merge 3 commits into
mainfrom
feat/edit-message-action-facet-fallback-c3de

Conversation

@bdart

@bdart bdart commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Editing a message that was originally sent with an action facet (e.g. outlook_rewrite_selection with selected_text args) 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_sse mapped request.action_facet directly with no fallback — unlike the regenerate path which gained a fallback_action_facet block in commit b86276a. The action_facet field on EditMessageRequest was wired in commit bb50e35 but the matching backend fallback was never implemented.

Solution

Mirror the regenerate fallback exactly inside edit_message_sse:

  • When request.action_facet is None, read the edited message's stored facet from generation_parameters via get_generation_action_facet_from_message(&message_to_edit).
  • Re-validate against the current config and platform — a facet removed from config since the original send is dropped with tracing::warn rather than returning a 400.
  • Apply via .or(fallback_action_facet.as_ref()), so an explicit action_facet in 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 — add fallback_action_facet block inside the spawned task in edit_message_sse, update PromptCompositionUserInput.action_facet to 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 a rewrite facet, edits without one, asserts the facet appears in the edit's generation_parameters and 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

cursoragent and others added 2 commits July 5, 2026 21:44
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>
@bdart bdart marked this pull request as ready for review July 5, 2026 19:45
@bdart bdart force-pushed the feat/edit-message-action-facet-fallback-c3de branch from 0558dbd to 3c2f04b Compare July 5, 2026 19:52
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.

2 participants