Skip to content

[codex] Add payload regression for commentary-prefixed final answers - #83340

Closed
rteoo wants to merge 1 commit into
openclaw:mainfrom
rteoo:codex/payload-commentary-final-answer-regression
Closed

rteoo wants to merge 1 commit into
openclaw:mainfrom
rteoo:codex/payload-commentary-final-answer-regression

Conversation

@rteoo

@rteoo rteoo commented May 18, 2026 •

Copy link
Copy Markdown

Summary

  • Problem: the merged payload fix has coverage for incomplete streamed previews, but not the exact one-entry shape where accumulated assistant text contains commentary plus the final answer.
  • Why it matters: this was the remaining narrow regression Peter called out when closing Fix stale Discord final answer payload #82645 as superseded by fix(agents): harden final assistant payload assembly #82850.
  • What changed: added a focused buildEmbeddedRunPayloads regression asserting "Need inspect.\n\nDone." delivers only the phase-tagged final_answer text, "Done.".
  • What did NOT change (scope boundary): no runtime behavior, payload logic, channel delivery code, config, docs, dependencies, or changelog.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Real behavior proof (required for external PRs)

This PR is regression coverage only; it does not change runtime behavior. The underlying runtime behavior was fixed by #82850. This PR adds the exact remaining test shape Peter mentioned in #82645's closure comment.

  • Behavior or issue addressed: one accumulated assistant text can contain commentary plus final-answer text while the structured assistant message has phase-tagged commentary and final_answer blocks; the final payload should use only the structured final_answer.
  • Real environment tested: local OpenClaw source checkout at current main on macOS with Node v26.0.0 and pnpm 11.1.0.
  • 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
    • 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 exec oxfmt --check --threads=1 src/agents/pi-embedded-runner/run/payloads.test.ts
    • git diff --check
    • pnpm check:changed
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output):
payloads.test.ts: 1 file passed, 29 tests passed
focused suite: 3 files passed, 141 tests passed
oxfmt --check: All matched files use the correct format.
git diff --check: passed
pnpm check:changed: passed

Root Cause (if applicable)

  • Root cause: historical coverage did not explicitly lock the exact one-entry accumulated-text shape where commentary and final answer were concatenated in one assistant text while structured phase metadata was available separately.
  • Missing detection / guardrail: there was no focused regression for assistantTexts: ["Need inspect.\n\nDone."] plus structured commentary and final_answer blocks.
  • Contributing context (if known): fix(agents): harden final assistant payload assembly #82850 broadened final payload assembly; this PR only adds the narrow guardrail that was left as a possible follow-up when Fix stale Discord final answer payload #82645 was closed.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/pi-embedded-runner/run/payloads.test.ts
  • Scenario the test should lock in: a single accumulated assistant text containing commentary plus final answer should still deliver only the phase-tagged final answer.
  • Why this is the smallest reliable guardrail: the behavior is pure payload assembly, so a focused helper test catches the regression without requiring channel credentials or a running gateway.
  • Existing test that already covers this (if any): existing tests cover no streamed text, blank streamed text, incomplete preview, multi-entry accumulated progress, and stale assistant fallback, but not this exact one-entry commentary-plus-final shape.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

None. Test coverage only.

Diagram (if applicable)

N/A

Before guardrail:
[one accumulated text: commentary + final] + [structured final_answer] -> could regress without a direct test

After guardrail:
[one accumulated text: commentary + final] + [structured final_answer] -> payload text is "Done."

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local source checkout
  • Model/provider: N/A for focused payload helper test
  • Integration/channel (if any): embedded runner payload assembly / Discord-adjacent regression coverage
  • Relevant config (redacted): N/A

Steps

  1. Build payloads with one accumulated assistant text: Need inspect.\n\nDone..
  2. Provide structured assistant content with commentary text Need inspect. and final_answer text Done..
  3. Verify the generated payload text is exactly Done..

Expected

  • The payload uses only the structured final_answer.

Actual

  • Matches expected in the added regression test.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

The focused test output is copied in the Real behavior proof section.

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: exact one-entry commentary-plus-final accumulated text shape; existing payload test suite; focused Discord-adjacent payload/process suite.
  • Edge cases checked: existing tests still pass for blank streamed text, incomplete preview replacement, multi-entry pre-tool progress, stale transcript assistant fallback, and payload error paths.
  • What you did not verify: live Discord E2E, because this PR adds only regression coverage and does not alter runtime behavior.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

No bot review conversations are addressed by this PR yet.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: maintainers may consider this too small or test-only.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels May 18, 2026
@clawsweeper

clawsweeper Bot commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Close: current main already contains the exact regression guard this branch adds, with git history tying the duplicate test to a mainline commit after the latest release.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Close this branch and keep the mainline regression guard; any remaining channel-delivery behavior should stay with the canonical related issue or a maintainer-approved follow-up.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a current-main failure: current main already contains the exact helper regression and the final-answer payload selection path it guards.

Is this the best way to solve the issue?

Yes for cleanup: closing this branch is the narrowest outcome because merging it now would duplicate coverage already present on main.

Security review:

Security review cleared: The diff only adds a Vitest regression test and does not change runtime code, dependencies, workflows, secrets, permissions, or network behavior.

What I checked:

Likely related people:

  • compoodment: git blame attributes the exact current-main test lines to commit 6ebe91d92b2a1972dd6350142f59f851145589cf. (role: introduced current-main regression guard; confidence: high; commits: 6ebe91d92b2a; files: src/agents/pi-embedded-runner/run/payloads.test.ts)
  • steipete: Peter Steinberger committed the mainline test commit and authored the current payload helper import/stabilization commit that carries the canonical-final-answer selection path. (role: committer and recent adjacent owner; confidence: high; commits: 6ebe91d92b2a, af62fd45cdbf, 9eed092baa50; files: src/agents/pi-embedded-runner/run/payloads.test.ts, src/agents/pi-embedded-runner/run/payloads.ts)
  • joshavant: Live PR metadata and git history identify Josh Avant as the author of the merged related payload-hardening PR that this test follows up. (role: related runtime hardening author; confidence: medium; commits: 7d1317634e5b; files: 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)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 9aa46843ec89; fix evidence: commit 6ebe91d92b2a, main fix timestamp 2026-05-18T01:37:59+01:00.

@rteoo
rteoo marked this pull request as ready for review May 18, 2026 00:36
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels May 18, 2026
@clawsweeper clawsweeper Bot closed this May 18, 2026
@rteoo
rteoo deleted the codex/payload-commentary-final-answer-regression branch September 23, 2026 01:57
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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant