Skip to content

fix: avoid duplicate media completion fallback#77754

Merged
steipete merged 1 commit intomainfrom
fix/media-completion-pending-fallback
May 5, 2026
Merged

fix: avoid duplicate media completion fallback#77754
steipete merged 1 commit intomainfrom
fix/media-completion-pending-fallback

Conversation

@steipete
Copy link
Copy Markdown
Contributor

@steipete steipete commented May 5, 2026

Summary

  • treat pending announce-agent gateway responses as delivered/pending instead of fallback-worthy
  • prevent generated media completions from sending a raw fallback while the announce agent is still running
  • add regression coverage for pending media announce responses

Test

  • pnpm test src/agents/subagent-announce-delivery.test.ts

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels May 5, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented May 5, 2026

Codex review: needs real behavior proof before merge.

Summary
This PR treats pending direct announce-agent responses as delivered/pending and adds regression coverage for generated media completion fallback behavior.

Reproducibility: yes. by source inspection. On current main, a direct announce response shaped like { status: "accepted" } has no result, so the existing fallback check treats it as fallback-worthy and can send the raw generated-media completion while the announce run is still pending.

Real behavior proof
Not applicable: The PR is maintainer-labeled, so the external contributor real-behavior-proof gate is not applied by this read-only review.

Next step before merge
A worker can make the narrow changelog-only repair without changing the runtime or test behavior.

Security
Cleared: The diff only touches agent delivery logic and a colocated Vitest regression test, with no dependency, CI, secret, install, or release-script changes.

Review findings

  • [P3] Add the changelog entry — src/agents/subagent-announce-delivery.ts:1055
Review details

Best possible solution:

Land the narrow pending-status guard with regression coverage after adding or explicitly folding the user-facing duplicate-media-fallback note into the existing Unreleased media changelog entries.

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

Yes by source inspection. On current main, a direct announce response shaped like { status: "accepted" } has no result, so the existing fallback check treats it as fallback-worthy and can send the raw generated-media completion while the announce run is still pending.

Is this the best way to solve the issue?

Yes for the code path. Recognizing accepted, started, and in_flight as pending before fallback matches the gateway contract and is the narrowest maintainable runtime fix; the remaining issue is the required changelog handling.

Full review comments:

  • [P3] Add the changelog entry — src/agents/subagent-announce-delivery.ts:1055
    This is a user-facing fix for duplicate generated-media completion messages, but the PR only changes runtime code and tests. Repo policy requires a CHANGELOG.md entry for user-facing fixes before merge, unless maintainers explicitly fold this into an existing media entry.
    Confidence: 0.78

Overall correctness: patch is correct
Overall confidence: 0.84

Acceptance criteria:

  • git diff --check
  • pnpm test src/agents/subagent-announce-delivery.test.ts

What I checked:

Likely related people:

  • steipete: The directly relevant async media completion delivery hardening appears in current-main history at commit 6c8974f, authored and committed by Peter Steinberger, touching the same runtime, test, and changelog surface. (role: recent maintainer and behavior author; confidence: high; commits: 6c8974f3f5a9; files: src/agents/subagent-announce-delivery.ts, src/agents/subagent-announce-delivery.test.ts, CHANGELOG.md)
  • vincentkoc: Local file history also shows Vincent Koc touching the same central files in commit a52010b, and adjacent Unreleased Agents/media and Agents/subagents changelog entries credit related work to @vincentkoc. (role: adjacent recent maintainer; confidence: medium; commits: a52010be7d2d; files: src/agents/subagent-announce-delivery.ts, src/agents/subagent-announce-delivery.test.ts, CHANGELOG.md)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 9c4a335007d7.

Re-review progress:

Copy link
Copy Markdown

@byungskers byungskers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix for the race condition between media generation and completion fallback. Extracting into a dedicated predicate makes the intent very clear.

The test case for pending video generation is a good addition — it locks in the behavior that we shouldn't fall back while an announce-agent run is still in flight.

LGTM.

Copy link
Copy Markdown

@byungskers byungskers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix for the race condition between media generation and completion fallback. Extracting isGatewayAgentRunPending into a dedicated predicate makes the intent very clear.

The test case for pending video generation is a good addition — it locks in the behavior that we shouldn't fall back while an announce-agent run is still in flight.

LGTM.

@steipete steipete merged commit b32d4c5 into main May 5, 2026
97 of 100 checks passed
@steipete steipete deleted the fix/media-completion-pending-fallback branch May 5, 2026 17:11
@steipete
Copy link
Copy Markdown
Contributor Author

steipete commented May 5, 2026

Landed via rebase onto main.

  • Gate: PR CI green for relevant lanes; local pnpm test src/agents/subagent-announce-delivery.test.ts passed before merge.
  • Merge commit: b32d4c5

Changelog repair is included in the follow-up refactor diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants