Repository navigation
feat(desktop): regenerate the last reply by taking the turn back first - #1165
Draft
sosidudku1 wants to merge 2 commits into
Draft
sosidudku1 wants to merge 2 commits into
sosidudku1 wants to merge 2 commits into
Conversation
"Ask again" under the last reply and a failed turn's "Try again" used to
send the question once more on top of the old turn, so the transcript and
the agent's context kept both copies. The agent can now remove its last
question and answer (POST /api/sessions/{id}/rollback-last-turn), so the
new answer replaces the old one.
- agent-client: rollbackLastTurn(sessionId) returns {ok, supported, text,
code, error}. The route's 404 (session_not_found) is an unknown chat; an
agent without the route (404 with no code) is reported as unsupported.
A 409 carries the agent's refusal code. IPC agent:rollbackLastTurn and
the preload method go with it.
- renderer: the reply's button is "Regenerate" with its own data-regen.
regenerateReply checks the same composer gates as resendUser before the
agent is asked (once the turn is gone the question only lives in the
window), then drops the question and the rows after it from S.log in
place (the transcript window keys on the array) and sends the question
through submit(). An agent without the route, an unsaved chat, a running
turn or an older question keep the old resend. A refusal under the reply
says why and changes nothing. If the agent took back a different
question than the one on screen, the chat is redrawn from the agent and
the question waits in the composer.
- Try again on a failed turn uses the same handler and falls back to the
resend on any refusal other than a running turn (a failed turn that ran
a tool stays retryable). The retry verb and the user bubble's button do
not change; the greyed hint under a reply that used tools stays.
Refs ATO-1299, ATO-1300, ATO-1301
…n the chat changes Regenerate and Try again now send the question's position (questions before it, steers left out) with its text, so a failed "continue" that never reached the agent cannot take back an earlier "continue" and its real answer. A stopped turn, which the agent now refuses (turn_stopped), falls back to the old resend like a mismatch. After the agent took the turn back: if another chat was opened during the call, the question is kept and put in the composer when that chat is opened again; if the composer was in use, the chat is drawn again from the agent (the old answer is gone there) and the question waits for the box to be free. Refs ATO-1299, ATO-1300, ATO-1301
This branch has not been deployed
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.
What
AgentClient.rollbackLastTurn(sessionId, expectText), an IPC handleragent:rollbackLastTurnand a preload method. A 404 withsession_not_foundmeans the chat is unknown. Any other 404 means an agent without the route (supported: false). A 409 carries the agent's refusalcode.data-regen. It checks the same composer gates asresendUserbefore asking the agent, because once the turn is gone the question only lives in the window. Those gates are: open microphone, a draft in the way, a running turn. Then it takes the turn back, removes the question and the rows after it fromS.login place (the transcript window keys on that array), and sends the question throughsubmit().retrycommand and the greyed hint under a reply that used tools.expectTextandexpectPriorQuestions(its position). If the agent's last question is a different one (a failed turn it never stored), or the turn was stopped, it removes nothing and the window falls back to the resend.Why
Users hit "Try again" after provider errors, and it showed the question twice: on screen, after a reopen, and in the model's context. The context bar grew on every retry.
Needs the agent route from the main PR (#1162). Without it, the old behaviour stays.
How it was verified
desktop/test/rollback-last-turn.test.mjscovers the client against a stand-in agent andregenerateReplyin a vm.retry-answerandacted-retry-hintare updated for the new button.node --checkhas run. Builds, tests and the app have not been run yet.Refs ATO-1299, ATO-1300, ATO-1301
Not yet checked on the second Mac.