fix(agents): harden final assistant payload assembly#82850
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: no. high-confidence live reproduction was established for current main. Source inspection supports the generic risk: current main has only Real behavior proof Next step before merge Security Review detailsBest possible solution: Keep the generic embedded-runner hardening only if maintainers want this extra protection beyond the merged Discord fix, then land it with redacted real runtime proof and green checks. Do we have a high-confidence way to reproduce the issue? No high-confidence live reproduction was established for current main. Source inspection supports the generic risk: current main has only Is this the best way to solve the issue? Likely yes, subject to maintainer judgment and proof. Passing the current assistant into generic payload construction is a narrow solution for stale/final-text selection, but the original Discord user problem is already fixed by a channel-level recovery PR. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 2c549ae20593. |
f99d7c6 to
6683bc5
Compare
Summary
buildEmbeddedRunPayloads, while avoiding stale transcript assistants for current one-chunk replies.Verification
pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/agents/pi-embedded-runner/run.ts src/agents/pi-embedded-runner/run/payloads.ts src/agents/pi-embedded-runner/run/payloads.test.ts src/agents/pi-embedded-runner/run/payloads.test-helpers.tsOPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/agents/pi-embedded-runner/run/payloads.test.ts src/agents/pi-embedded-runner/run/payloads.errors.test.ts extensions/discord/src/monitor/message-handler.process.test.tspnpm check:changedReal behavior proof:
Behavior addressed: Follow-up hardening for #82862: final reply payload assembly now uses the completed current-turn structured assistant final answer when available, reducing reliance on streamed preview fragments before channel-level transcript recovery is needed.
Real environment tested: Local source checkout rebased on current
origin/main, which includes #82862.Exact steps or command run after this patch:
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/agents/pi-embedded-runner/run/payloads.test.ts src/agents/pi-embedded-runner/run/payloads.errors.test.ts extensions/discord/src/monitor/message-handler.process.test.ts;pnpm check:changed.Evidence after fix: Payload regressions assert an incomplete streamed preview is replaced by the structured final answer, and a stale transcript assistant does not override a current one-chunk reply; Discord process tests still pass on top of #82862.
Observed result after fix: Focused Vitest passed with 3 files and 137 tests;
pnpm check:changedpassed.What was not tested: No new live Discord E2E in this follow-up PR; #82862 remains the issue-specific Discord recovery fix for #82807.
Refs #82807
Follow-up to #82862