Skip to content

fix(agents): keep not_required delivery status when completion_announced_at exists - #108710

Merged
steipete merged 2 commits into
openclaw:mainfrom
bladin:fix/delivery-status-contradictory-expects-completion-false
Jul 16, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
bladin:fix/delivery-status-contradictory-expects-completion-false

Conversation

@bladin

@bladin bladin commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

createDeliveryFromTypedColumns in subagent-registry.store.sqlite.ts unconditionally overrode delivery status to "delivered" whenever completion_announced_at was present, even for runs where expectsCompletionMessage is false. This produced a contradictory delivery state: a run that does not require completion delivery was marked as delivered.

Why This Change Was Made

When restoring subagent run records from SQLite typed columns, the hydration at lines 92-98 spread status: "delivered" whenever completion_announced_at !== null, without checking whether the run actually requires completion delivery. For expectsCompletionMessage === false runs, the correct status is "not_required" — the completion_announced_at timestamp may exist for informational logging but should not override delivery semantics.

This contradicts the normalization logic in buildDeliveryState (subagent-delivery-state.ts:238) which correctly returns { status: "not_required" } when expectsCompletionMessage === false, bypassing all delivery state checks.

User Impact

Subagent runs with expectsCompletionMessage === false that have their completion timestamp recorded would get incorrect status: "delivered" after gateway restart (which reloads from SQLite). Downstream delivery logic checking status === "delivered" could attempt unnecessary delivery retries for runs that should be dormant.

Evidence

  • createDeliveryFromTypedColumns at src/agents/subagent-registry.store.sqlite.ts:92-98 unconditionally spreads status: "delivered" based on completion_announced_at.
  • buildDeliveryState at src/agents/subagent-delivery-state.ts:238-239 correctly returns { status: "not_required" } for the same scenario.
  • Added two test cases verifying not_required status is preserved and announcedAt is kept for informational purposes.

Real behavior proof

proof: test — SQLite round-trip tests directly assert delivery status after save+load. Local execution blocked by Node 22.22.0 SQLite WAL version gate; CI validates.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Jul 16, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 16, 2026, 3:17 AM ET / 07:17 UTC.

Summary
The PR prevents completion_announced_at from changing delivery status to delivered when completion messages are not expected, while retaining the announcement timestamp and adding SQLite round-trip tests.

PR surface: Source +2, Tests +35. Total +37 across 2 files.

Reproducibility: yes. from source, but not as a live run: current main unconditionally applies delivered when completion_announced_at exists, and the new round-trip test directly exercises the contradictory row shape.

Review metrics: 1 noteworthy metric.

  • Persisted-state rule: 1 hydration override narrowed. The change affects delivery-state interpretation after gateway restart, so upgrade-path behavior deserves explicit attention before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Post redacted terminal output or runtime logs from a real gateway restart showing the corrected restored delivery fields.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Only SQLite tests and CI are provided; before merge, add a redacted live gateway save/restart/reload transcript or logs, then update the PR body to trigger review again—or ask a maintainer to comment @clawsweeper re-review if it does not.

Risk before merge

  • [P1] The change alters how persisted subagent delivery state is interpreted after restart; the PR does not yet show a live gateway save, restart, and reload using an existing on-disk row.
  • [P1] The supplied exact-head check snapshot is incomplete and includes a failed bundled-protocol check, so merge readiness is not yet established even though many focused checks have passed.

Maintainer options:

  1. Prove restart hydration before merge (recommended)
    Capture a redacted terminal transcript or runtime logs showing a real gateway restart reloads the persisted row with status: not_required, retained announcedAt, and no deliveredAt.
  2. Accept the focused test evidence
    Maintainers may intentionally accept the persisted-state interpretation change based on source analysis and SQLite round-trip coverage alone.

Next step before merge

  • [P1] Do not merge until the contributor supplies real restart/reload proof and the exact-head required checks finish successfully; there is no concrete code defect for an automated repair lane.

Security
Cleared: The two-file change introduces no dependency, permission, secret-handling, workflow, or third-party code-execution surface.

Review details

Best possible solution:

Keep the narrow hydration rule and regression tests, then demonstrate a real gateway restart that reloads a non-delivery subagent row as not_required while retaining announcedAt.

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

Yes from source, but not as a live run: current main unconditionally applies delivered when completion_announced_at exists, and the new round-trip test directly exercises the contradictory row shape.

Is this the best way to solve the issue?

Yes, provisionally: conditioning the typed-column override on whether completion delivery is expected is the narrowest fix and aligns hydration with the existing delivery-state invariant; live restart proof remains required.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f9e7a4cab8f0.

Label changes

Label changes:

  • add P2: This is a bounded persisted-state correctness bug affecting some subagent records after restart, without evidence of widespread message loss or runtime unavailability.
  • add merge-risk: 🚨 session-state: Merging changes how existing SQLite delivery records are reconstructed after restart, and live upgrade-path proof is not yet present.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Only SQLite tests and CI are provided; before merge, add a redacted live gateway save/restart/reload transcript or logs, then update the PR body to trigger review again—or ask a maintainer to comment @clawsweeper re-review if it does not.

Label justifications:

  • P2: This is a bounded persisted-state correctness bug affecting some subagent records after restart, without evidence of widespread message loss or runtime unavailability.
  • merge-risk: 🚨 session-state: Merging changes how existing SQLite delivery records are reconstructed after restart, and live upgrade-path proof is not yet present.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Only SQLite tests and CI are provided; before merge, add a redacted live gateway save/restart/reload transcript or logs, then update the PR body to trigger review again—or ask a maintainer to comment @clawsweeper re-review if it does not.
Evidence reviewed

PR surface:

Source +2, Tests +35. Total +37 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 2 +2
Tests 1 35 0 +35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 39 2 +37

What I checked:

  • Current-main contradiction: Current main promotes any row with completion_announced_at to delivered, without considering expects_completion_message; the PR narrows that override to rows where completion delivery is expected. (src/agents/subagent-registry.store.sqlite.ts:92, f9e7a4cab8f0)
  • Canonical delivery invariant: The existing delivery-state normalization treats runs with expectsCompletionMessage === false as not_required, supporting the PR's intended status semantics. (src/agents/subagent-delivery-state.ts:238, f9e7a4cab8f0)
  • Focused regression coverage: The added round-trip case stores a not_required delivery with announcedAt, reloads it from SQLite, and verifies that status and timestamp remain distinct while deliveredAt stays unset. (src/agents/subagent-registry.store.sqlite.test.ts:139, 66c6d370b443)
  • Real behavior proof gap: The PR body reports only SQLite tests and says local execution was blocked; tests and CI are supplemental rather than after-fix proof from a running gateway restart and reload path. (66c6d370b443)
  • Release state: The latest release is v2026.7.1 at 2d2ddc43d0dcf71f31283d780f9fe9ff4cc04fe4; this open PR's head is not part of that released revision or current main. (2d2ddc43d0dc)

Likely related people:

  • vincentkoc: Recent release history credits work on pending subagent completion announcements, making this person a useful routing candidate for delivery-lifecycle invariants. (role: adjacent feature contributor; confidence: medium; files: src/agents/subagent-delivery-state.ts, src/agents/subagent-registry.ts)
  • steipete: Recent merged subagent lifecycle and agent-runtime work makes this person a secondary routing candidate for the persisted delivery-state boundary. (role: recent area contributor; confidence: low; commits: aad014c7c1; files: src/agents/subagent-registry.store.sqlite.ts, src/agents/subagent-delivery-state.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete steipete self-assigned this Jul 16, 2026
@steipete
steipete force-pushed the fix/delivery-status-contradictory-expects-completion-false branch from 66c6d37 to 8bd8fa9 Compare July 16, 2026 17:03
@steipete

Copy link
Copy Markdown
Contributor

Maintainer repair and verification complete at 8bd8fa9b0fcbb98884a656bb07b6255bf00196be.

Best-fix check: typed SQLite columns are the canonical persistence source, the final override repairs both clean and contradictory upgrade rows, and no runtime compatibility path or sibling delivery-state change is needed.

bladin and others added 2 commits July 16, 2026 18:12
…ced_at exists for expectsCompletionMessage=false runs

createDeliveryFromTypedColumns unconditionally overrode status to
'delivered' when completion_announced_at was present, even for runs
where expects_completion_message is false. This produced a contradictory
delivery state where a run that does not require completion delivery
was marked as delivered.

Only set status to 'delivered' when expects_completion_message is true.
For not_required runs that still have completion_announced_at recorded
(for informational purposes), preserve announcedAt without overriding
the status.
@steipete
steipete force-pushed the fix/delivery-status-contradictory-expects-completion-false branch from 8bd8fa9 to 8ee4445 Compare July 16, 2026 17:14
@steipete

Copy link
Copy Markdown
Contributor

Final post-rebase verification complete at 8ee4445d9729aac04a2b1778addbf12b88c03419.

Best-fix check: typed SQLite columns are the canonical persistence source, the final override repairs both clean and contradictory upgrade rows, and no runtime compatibility path or sibling delivery-state change is needed.

@steipete
steipete merged commit 1f3b4e8 into openclaw:main Jul 16, 2026
118 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…ced_at exists (openclaw#108710)

* fix(agents): keep not_required delivery status when completion_announced_at exists for expectsCompletionMessage=false runs

createDeliveryFromTypedColumns unconditionally overrode status to
'delivered' when completion_announced_at was present, even for runs
where expects_completion_message is false. This produced a contradictory
delivery state where a run that does not require completion delivery
was marked as delivered.

Only set status to 'delivered' when expects_completion_message is true.
For not_required runs that still have completion_announced_at recorded
(for informational purposes), preserve announcedAt without overriding
the status.

* test(agents): cover tainted delivery rows

---------

Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…ced_at exists (openclaw#108710)

* fix(agents): keep not_required delivery status when completion_announced_at exists for expectsCompletionMessage=false runs

createDeliveryFromTypedColumns unconditionally overrode status to
'delivered' when completion_announced_at was present, even for runs
where expects_completion_message is false. This produced a contradictory
delivery state where a run that does not require completion delivery
was marked as delivered.

Only set status to 'delivered' when expects_completion_message is true.
For not_required runs that still have completion_announced_at recorded
(for informational purposes), preserve announcedAt without overriding
the status.

* test(agents): cover tainted delivery rows

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants