fix(agent-session): mark stopped pending messages as paused#16720
Conversation
Code Review · PR #16720 · Request changes
The target behavior of the changes is correct (deferred-abort can be hit, 🔴 Must Fix — Use turn-level AbortController to unify pre-stream abort, remove
|
There was a problem hiding this comment.
This review was translated automatically.
pre-stream abort must be handled using a unified turn-level AbortController. Remove pendingAborts/TTL/messageId matching and DB pre-flip in abort(). Keep canPersistEmptyTerminal + assistantMessageId. See review comments for details: #16720 (comment)
Original Content
pre-stream abort 必须用统一的 turn 级 AbortController 处理,移除 pendingAborts/TTL/messageId 匹配及 abort() 里的 DB 预 flip;保留 canPersistEmptyTerminal + assistantMessageId。详见评审评论:#16720 (comment)
There was a problem hiding this comment.
This review was translated automatically.
I found one non-blocking type invariant issue that is separate from the existing DeJeune feedback.
- Suggestion:
src/main/ai/agentSession/AgentSessionRuntimeService.ts:58still declaresassistantMessageIdoptional, but the newcreatePersistenceListener()path now requires it and throws when it is missing. BecausebeginTurn()mutates runtime entry state before listener creation in the new-entry path, a caller can compile successfully while leaving the session runtime partially installed if it omits the id. Please either makeassistantMessageIdrequired onBeginAgentSessionTurnInput/AgentSessionTurn, or validate it before mutatingentries.
After fixing, please request eeee0717 for further review.
No local pnpm lint/test/format was run, per instruction.
Original Content
I found one non-blocking type invariant issue that is separate from the existing DeJeune feedback.
- Suggestion:
src/main/ai/agentSession/AgentSessionRuntimeService.ts:58still declaresassistantMessageIdoptional, but the newcreatePersistenceListener()path now requires it and throws when it is missing. BecausebeginTurn()mutates runtime entry state before listener creation in the new-entry path, a caller can compile successfully while leaving the session runtime partially installed if it omits the id. Please either makeassistantMessageIdrequired onBeginAgentSessionTurnInput/AgentSessionTurn, or validate it before mutatingentries.
修复后请 request eeee0717 再进行后续 review。
No local pnpm lint/test/format was run, per instruction.
…m abort Signed-off-by: kangfenmao <kangfenmao@qq.com>
Signed-off-by: kangfenmao <kangfenmao@qq.com>
570f546 to
6587e21
Compare
zhangjiadi225
left a comment
There was a problem hiding this comment.
LGTM. Verified the latest head replaces the pendingAborts/DB pre-flip path with a turn-level AbortController, removes markPendingAssistantPlaceholdersPaused, and makes assistantMessageId required. CI basic-checks and general-test are passing. Note: PR is still behind main, so please update before merge.
eeee0717
left a comment
There was a problem hiding this comment.
No substantive issues found.
CI checked via GitHub: visible checks are passing or intentionally skipped. Local pnpm lint/test/format not run per repository review instructions.
|
a reviewer is still requesting review |
032e7aa to
b33f6f1
Compare
What this PR does
Before this PR:
When a user clicked stop after sending an agent session message, the assistant placeholder could remain
pendingin the database if the stop request arrived before the stream was created.After this PR:
Stop requests now mark matching empty pending assistant placeholders as
pausedand persist the paused terminal status back to the existing placeholder row, so the database no longer keeps the stopped message inpending.Fixes # N/A
Why we need it and why it was done in this way
The following tradeoffs were made:
The fix is scoped to agent-session topics and only applies the deferred stop request to the matching assistant placeholder id. A short TTL prevents stale stop requests from affecting later turns.
The following alternatives were considered:
Creating a new assistant message on empty paused terminal events was avoided because agent sessions already create a placeholder before streaming starts; final status should update that row instead.
Links to places where the discussion took place: N/A
Breaking changes
If this PR introduces breaking changes, please describe the changes and the impact on users.
None.
Special notes for your reviewer
The change is intentionally limited to agent-session placeholder persistence and stop handling before stream creation.
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
mainfor active development,v1for v1 maintenance fixes/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note