Skip to content

fix(agents): harden final assistant payload assembly#82850

Merged
joshavant merged 1 commit into
mainfrom
fix/discord-truncated-progress-final
May 17, 2026
Merged

fix(agents): harden final assistant payload assembly#82850
joshavant merged 1 commit into
mainfrom
fix/discord-truncated-progress-final

Conversation

@joshavant

@joshavant joshavant commented May 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Follow up fix(discord): recover truncated progress finals #82862 by hardening embedded agent final payload assembly so completed current-turn assistant answers are preferred over streamed preview fragments.
  • Pass the current attempt assistant into buildEmbeddedRunPayloads, while avoiding stale transcript assistants for current one-chunk replies.
  • Keep error/abort surfaces on their existing error path and add focused regressions for incomplete streamed text and stale assistant fallback.

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.ts
  • 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

Real 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:changed passed.
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

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: M maintainer Maintainer-authored PR labels May 17, 2026
@clawsweeper

clawsweeper Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR passes the current attempt assistant into embedded-runner payload assembly, prefers current structured final text over streamed preview fragments, adds payload regressions, and updates the changelog.

Reproducibility: no. high-confidence live reproduction was established for current main. Source inspection supports the generic risk: current main has only lastAssistant in payload assembly, while this PR distinguishes the current attempt assistant from stale transcript fallback.

Real behavior proof
Needs real behavior proof before merge: The PR body provides focused test and changed-check output, but no after-fix real runtime, channel, terminal, log, recording, screenshot, or linked artifact proof of the changed behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Next step before merge
Protected label, missing real behavior proof, and overlap with the already-merged Discord fix make this a maintainer decision rather than a ClawSweeper repair-lane task.

Security
Cleared: The diff changes agent payload selection, focused tests, and changelog text without adding dependencies, CI permissions, credential handling, network access, or package execution paths.

Review details

Best 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 lastAssistant in payload assembly, while this PR distinguishes the current attempt assistant from stale transcript fallback.

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:

  • 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
  • Redacted live Discord or runtime proof showing a long/final assistant payload uses the completed final answer rather than a streamed preview fragment

What I checked:

Likely related people:

  • steipete: Authored the current payload-helper extraction commit and authored/merged the related Discord recovery fix that closed the linked long-message report. (role: feature owner and recent area contributor; confidence: high; commits: f45390416565, 549a0ea31310, b29152e3b951; files: src/agents/pi-embedded-runner/run/payloads.ts, src/agents/pi-embedded-runner/run/payloads.test.ts, extensions/discord/src/monitor/message-handler.process.test.ts)
  • Galin Iliev: Recent history on run.ts shows adjacent embedded-attempt dispatch timing work at the payload call-site surface. (role: recent agent runner contributor; confidence: medium; commits: 91ae1a6c03bf; files: src/agents/pi-embedded-runner/run.ts)

Remaining risk / open question:

  • The PR body provides focused tests and pnpm check:changed, but no redacted live runtime, channel, terminal, log, recording, screenshot, or linked artifact proof of the changed delivery path.
  • The linked Discord truncation report is already fixed by fix(discord): recover truncated progress finals #82862, so maintainers need to decide whether this generic embedded-runner hardening is still worth landing as a follow-up.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 2c549ae20593.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. labels May 17, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S and removed channel: discord Channel integration: discord size: M labels May 17, 2026
@joshavant joshavant changed the title fix(discord): recover truncated progress finals fix(agents): harden final assistant payload assembly May 17, 2026
@joshavant joshavant force-pushed the fix/discord-truncated-progress-final branch from f99d7c6 to 6683bc5 Compare May 17, 2026 04:08
@joshavant joshavant merged commit 7d13176 into main May 17, 2026
113 of 114 checks passed
@joshavant joshavant deleted the fix/discord-truncated-progress-final branch May 17, 2026 04:20
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 20, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
SYU8384 pushed a commit to SYU8384/openclaw that referenced this pull request Jun 3, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant