feat(gateway/transcript): add silent option to assistant transcript append helper#76819
Conversation
|
Hi @steipete @clawsweeper — review when you have a moment, thanks. |
|
Thanks for the context here. I did a careful shell check against current Current main already resolves the WebChat transcript problem through the Pi-owned transcript path and now explicitly avoids mirroring normal agent-run final delivery from WebChat, so this PR is obsolete and would conflict with the current ownership model. So I’m closing this as already implemented rather than keeping a duplicate issue open. Review detailsBest possible solution: Keep the current Pi-owned transcript persistence model and avoid adding a WebChat mirror for normal agent-run final replies. Do we have a high-confidence way to reproduce the issue? No failing current-main reproduction path was established in this read-only review. The old v2026.5.2 failure is well documented in the PR discussion, but current main has source, docs, and regression tests showing the WebChat mirror path is now intentionally avoided. Is this the best way to solve the issue? No. The PR's silent append was a reasonable intermediate attempt, but current main now treats normal agent-run assistant text as Pi-owned and the PR's gateway mirror would risk duplicate assistant turns. Security review: Security review cleared: The diff is limited to gateway transcript persistence, focused tests, and changelog text; it adds no dependency, workflow, permission, secret, network, or package-resolution surface. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 18db16471bdd; fix evidence: commit 0fcf2c64c06a, main fix timestamp 2026-05-04T06:00:01+01:00. |
db04f22 to
773ed23
Compare
|
Hi @steipete, rebased onto latest main, CHANGELOG conflict resolved. Could you take a look when you have time? Thanks. |
773ed23 to
9fa3986
Compare
|
Hi @steipete, rebased onto latest main, CHANGELOG conflict resolved. Ready for review when you have time, thanks. |
|
its not good to tag maintainers |
|
Thanks, @MkDev11 |
|
Tested this patch on v2026.5.2 dist (macOS arm64, npm global install). Two issues: 1. Doubled output: Every assistant response appears twice in the Control UI. The 2. Previous responses still vanish: After the doubled response renders, sending the next message triggers another The text IS being persisted to the JSONL correctly (verified with direct file inspection). The issue is the side effects of Environment:
Suggestion: The cc @amzzzzzzz — did you test the PR on your install? Curious if you see the same doubling. |
|
@/tmp/openclaw-pr-76819-comment.md |
9fa3986 to
8cfa72d
Compare
|
Thanks @dertbv, you nailed it. The transcript-update emit was firing a chat.history reload, which caused both the doubling and the next-turn drop. Pushed 8cfa72d93e: added a silent option to appendInjectedAssistantMessageToTranscript that skips the emitSessionTranscriptUpdate side effect, and the WebChat agent-run persist call now uses it. The text still lands in the JSONL with the assistant-text idempotency key, but no chat.history reload is triggered, so the streaming text on screen stays as-is. Tests now read the JSONL directly instead of the emit signal: 68/68 pass. cc @amzzzzzzz if you can retest. |
8cfa72d to
9c89bb3
Compare
|
Rebased onto latest main, CHANGELOG conflict resolved. 68/68 tests still pass. Ready for review when you have time, thanks. |
|
Hi, I am working on resolving conflicts. |
9c89bb3 to
0b2df8a
Compare
|
Hi @steipete, pivoted this PR after seeing your alternate solution land on main (skip chat.history reload during active sends, plus the explicit no-mirror tests). The new scope is just an additive seam: a silent option on appendInjectedAssistantMessageToTranscript that lets callers persist to JSONL without firing a session.message broadcast. Useful for any future caller that already has the message on screen via streaming and just needs the durable record. No changes to chat.ts or the existing behavior. 4/4 helper tests pass with the new default-emit and silent-skip cases. Updated title and description to match. Ready for review when you have time, thanks. |
Refs #76804.
The Gateway helper
appendInjectedAssistantMessageToTranscriptalways emits asession.messageevent on the transcript-events bus after writing. WebChat clients listen for that event and callchat.history, which replaces visible chat messages from the persisted snapshot. Callers that already have the assistant message on screen via streaming have no way to persist a JSONL record without triggering that reload.Add a
silentoption that skips the post-writeemitSessionTranscriptUpdatecall. The JSONL write is unchanged; only the WS broadcast is suppressed. The default stays opt-in (emit on by default) so existing callers are not affected.The maintainer's main-branch fix for #76804 (skip chat.history reload during active sends) addresses the visible disappearing-message symptom; this option gives future and out-of-band transcript writers a safe way to keep the JSONL in sync without re-firing the reload path.
pnpm test src/gateway/server-methods/chat.inject.parentid.test.ts-> 4/4 PASS (2 new cases: default emit + silent skip).pnpm exec oxfmt --checkclean.