Skip to content

Revert "fix: let finished background commands reach the agent before an active goal advances (#204265)" - #204534

Closed
obviyus wants to merge 1 commit into
mainfrom
revert/204265-owed-exec
Closed

obviyus wants to merge 1 commit into
mainfrom
revert/204265-owed-exec

Conversation

@obviyus

@obviyus obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Result

Reverts #204265 (463d774). Background exec results in incognito chats are lost: the result never reaches the chat.

Why now

A real scratch-Gateway run on clean main (isolated state, real model) started a background exec in an incognito chat. No completion turn arrived within 240 s. The Gateway logged:

[exec] completion was not admitted (Chat session storage admission ended); inspect the result with process log.

owe() throws for incognito sessions, and the exec-notify catch only logs it, so a produced result is silently dropped. The shared team Gateway has just auto-deployed a build that contains 463d774. This revert stops the loss before it reaches more users.

Reland plan

#204265 relands with the class fix:

Notes

A clean revert, apart from src/sessions/owed.ts: #204478 edited it later, and it is deleted here as #204265 added it. Nothing else on main imports it.

@clawsweeper

clawsweeper Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L labels Nov 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 24, 2026
@clawsweeper

clawsweeper Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR restores in-memory background-command notifications and removes stored completion delivery, restart recovery, and completion-before-Goal ordering.

Example: An incognito chat starts a background command that prints READY after its initiating turn finishes.

  • Before: Saving the completion fails with “Chat session storage admission ended,” and no completion turn arrives.
  • After: The rollback skips saving, but live admission still inherits the expired incognito actor and can fail with SessionDeliveryGenerationUnavailableError.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The rollback lacks demonstrated recovery and has two source-backed delivery blockers; the separate CI failure matches an existing main report.
Proof confidence 🦪 silver shellfish (2/6) This maintainer-authored PR is outside the contributor proof gate; its supplied log shows the main-branch failure, while successful recovery on the reviewed rollback is not demonstrated.
Patch quality 🧂 unranked krab (1/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: No · Fix scope: Partial
User problem: A background command finishes, but its incognito conversation receives no completion turn.
Reason: The maintainer-authored rollback has direction approval, but subsequent same-author evidence shows it does not restore incognito delivery, and a focused forward repair is already open.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this maintainer-authored PR open, but do not merge this revision: the rollback leaves the incognito failure reachable and makes existing saved exec completions unrecoverable.

Priority: P1
Reviewed head: dbcbd507bad077effb01eaab1639f937f2493282

Before merge

  • Detach completion admission from the finished incognito turn (P1) - When an incognito background command exits after its initiating chat turn finishes, this restored enqueue still runs with that turn's session-actor binding. Chat storage has already released the binding; prepareSessionEventTargetForHost reaches prepareMemorySessionGeneration, which selects that inherited actor and fails with SessionDeliveryGenerationUnavailableError. Removing owe only moves the failure point, leaving the stated user problem intact. The same author's fix: deliver background command results in incognito chats and when storing them fails #204532 reports this failure on the pre-fix revision and adds the existing independent-work boundaries needed at this owner.
  • Preserve recovery of exec results saved before the rollback (P1) - A Gateway running the current implementation can already have queued session_pending_inputs rows whose message_json has kind:"exec". After updating to this rollback, removing their recovery branch routes those rows through human-input recovery. Owed messages have no __openclaw.senderIdentity, so the sender check throws and failQueuedInput marks the result cancelled with restart-unrecoverable instead of delivering it. Preserve a recovery path for these accepted results before removing their reader.
  • Product: not worth merging - The maintainer-authored rollback has direction approval, but subsequent same-author evidence shows it does not restore incognito delivery, and a focused forward repair is already open.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Detach completion admission from the finished incognito turn — src/agents/bash-tools.exec-notify.ts:295-301
  • [P1] Preserve recovery of exec results saved before the rollback — src/gateway/queued-chat-inputs.ts:82-83

Tests

  • Missing end-to-end proof: No after-revert incognito completion run, red/green regression, or upgrade run carrying queued exec results is supplied.
Agent review details

How this fits together

Background process exits enter the session-event owner, which admits completion turns into the originating conversation; pending-input storage also supports restart recovery and Goal ordering.

flowchart LR
  A[Background command exits] --> B[Exec notification owner]
  B --> C[Session event admission]
  C --> D[Session controller]
  D --> E[Agent completion turn]
  F[Pending input storage] --> D
  E --> G[Goal continuation]
Loading

Technical review

Best possible solution:

Validate the focused forward repair in #204532 while preserving saved completions and existing Goal ordering.

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

The source exposes both failure paths, and the same author's forward PR reports matching real-Gateway incognito failures before and after the original change; no target code was executed during this review.

Is this the best way to solve the issue?

A full rollback is not the best repair: it leaves the incognito lifetime cause intact and removes recovery of stored results, whereas the forward candidate targets the existing notification owner.

Full review comments:

  • [P1] Detach completion admission from the finished incognito turn — src/agents/bash-tools.exec-notify.ts:295-301
    When an incognito background command exits after its initiating chat turn finishes, this restored enqueue still runs with that turn's session-actor binding. Chat storage has already released the binding; prepareSessionEventTargetForHost reaches prepareMemorySessionGeneration, which selects that inherited actor and fails with SessionDeliveryGenerationUnavailableError. Removing owe only moves the failure point, leaving the stated user problem intact. The same author's fix: deliver background command results in incognito chats and when storing them fails #204532 reports this failure on the pre-fix revision and adds the existing independent-work boundaries needed at this owner.
    Confidence: 0.99
  • [P1] Preserve recovery of exec results saved before the rollback — src/gateway/queued-chat-inputs.ts:82-83
    A Gateway running the current implementation can already have queued session_pending_inputs rows whose message_json has kind:"exec". After updating to this rollback, removing their recovery branch routes those rows through human-input recovery. Owed messages have no __openclaw.senderIdentity, so the sender check throws and failQueuedInput marks the result cancelled with restart-unrecoverable instead of delivering it. Preserve a recovery path for these accepted results before removing their reader.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 856ee3d006ee.

Provenance checked

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

PR surface

Source -431, Tests -214, Docs -1. Total -646 across 17 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 12 98 529 -431
Tests 4 9 223 -214
Docs 1 0 1 -1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 107 753 -646

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: Background-command results fail to reach agents, and the rollback can additionally prevent delivery of completions saved before an update.
  • add merge-risk: 🚨 message-delivery: The restored live admission path leaves incognito completions failing after their originating turn ends.
  • add merge-risk: 🚨 session-state: Previously queued kind:exec pending-input rows become restart-unrecoverable when their dedicated recovery branch is removed.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: Background-command results fail to reach agents, and the rollback can additionally prevent delivery of completions saved before an update.
  • merge-risk: 🚨 message-delivery: The restored live admission path leaves incognito completions failing after their originating turn ends.
  • merge-risk: 🚨 session-state: Previously queued kind:exec pending-input rows become restart-unrecoverable when their dedicated recovery branch is removed.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 24, 2026, 4:32 AM ET / 09:32 UTC.

@obviyus

obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #204532 (0164469), which fixes the incognito exec completion loss at the owner. That loss was older than #204265, so this revert would not have fixed it.

@obviyus obviyus closed this Nov 24, 2026
@obviyus
obviyus deleted the revert/204265-owed-exec branch November 24, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant