Skip to content

fix: keep scheduled global work in its existing conversation - #188173

Merged
shakkernerd merged 1 commit into
mainfrom
global-cron-session-target
Oct 30, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
global-cron-session-target

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Refs #188165.

What Problem This Solves

A scheduled agentTurn addressed to session:global under session.scope: "global" can leave the existing conversation, create agent:main:global with a different session ID, and fail settlement with a duplicate canonical-key warning. In the native reproduction, the run performed useful file work before failing, so retrying on the assumption that nothing happened would be misleading.

User Impact

Explicit global targets keep the selected agent's existing global conversation and context. Ordinary per-sender targets, explicitly qualified named keys, foreign-agent rejection, and duplicate-row integrity checks retain their current behavior. No configuration change or schema migration is introduced.

This correction prevents the demonstrated producer error. It does not merge or delete rows created by earlier failed runs, and it does not claim that updating or running Doctor repairs an already-affected two-row state. That recovery remains separate from this change.

Why This Change Was Made

The Gateway resolver applied ordinary agent qualification to the literal global selector before alias resolution. Under global scope, storage uses the literal key while the event queue can expose an agent-qualified identity. Passing the latter as a fresh physical target created the second conversation.

The resolver now preserves the literal selector under global scope before continuing its existing owner checks and dispatch. The change is confined to that producer and the existing routing regression table; it does not alter session storage or delivery accounting.

Evidence

A fresh isolated native Gateway was configured for global scope before any conversation existed. Native session creation and an ordinary model turn kept one global row and saved the requested initial note. A single scheduled review then created a second qualified row with a different ID, saved a review without the earlier conversation context, and ended in the duplicate-key error. The original row and selected input bytes were preserved.

The extended target-boundary regression fails on the unchanged production base for both selected-agent cases; eight controls pass, including the global main alias, per-sender global name, explicit qualified address, and foreign-agent refusal. The preexisting physical-identity suite also passes, including actual duplicate rejection.

Changed-file formatting/lint and all selected production/test type families passed on the exact candidate tree. All 103 cases in the four affected files passed. The requested single-worker target file then passed all 10 cases in 29.49 seconds (mostly cold transformation; 31.47 seconds through the native runner). Seven net test lines extend the existing table through the repository allocation mechanism.

On head 619a3fcb6dbb67cb0af22deca453268630a009fe, a second fresh native fixture used global scope before session creation. The direct-global scheduled review and a main-alias continuation both retained the original session ID and the single physical global row. They saved a correct 39-parcel loading plan and a 9-space capacity check while preserving the input files. No duplicate-key warning occurred. The actual harness was openclaw.

Both runs recorded execution status ok. Their missing-channel completion failure remains visible in the captures and belongs to delivery accounting, which this patch leaves unchanged. The original affected fixture remains intact; this proof establishes prevention, not recovery of the already-created duplicate.

Independent engineering review is clean for that prevention scope, and automatic review found no actionable issue through P2. Exact-head CI passed. The completed ClawSweeper review rates the exact head Diamond (5/6) with no findings.

Visual evidence

Open preview

Before After
Scheduled global review fails with a duplicate canonical session-key warning Scheduled review executes successfully in the existing global conversation; separate missing-channel delivery error remains

Open the exact-head native run history and inspect the saved result; this does not replay the scheduled job

result-redacted.webm

Visual verification

  • Baseline: d67aa60
  • Exact head: 619a3fcb6dbb67cb0af22deca453268630a009fe
  • Scenario: Inspect the native result of one explicit global scheduled review. The original failure created a second conversation; the corrected run retains the original conversation and saves its useful result. Delivery accounting remains a separate limitation.
  • Runtime/build: OpenClaw 2026.10.9, build 2026.10.9-619a3fcb6dbb-2026-10-30T07-54-30.997Z
  • Physical session rows: Baseline: 1 to 2; corrected: 1 to 1, original session ID retained
  • Useful work: 39 eligible parcels planned in two pickups; 7 fragile parcels held; prior files unchanged
  • Execution and delivery: Execution changes from error to ok. Missing-channel completion failure remains independently scoped.
  • Native sessions created only after global scope configuration; no manual database rows.
  • Same 1440 × 1000 viewport and synthetic task. The successful one-shot retired, so its result is shown in global history rather than the original job-detail view.
  • Screenshots and the entire result-inspection recording inspected; model metadata redacted.
  • Original affected state is retained. This demonstrates prevention, not recovery of existing duplicates.

@shakkernerd shakkernerd self-assigned this Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 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 size: XS labels Oct 30, 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserve the literal global conversation key when scheduled work targets session:global under global session scope.

Example: Agent main schedules an agentTurn targeting session:global with session.scope set to global.

  • Before: The resolver selects agent:main:global, creating another conversation and potentially failing settlement after useful work.
  • After: The resolver selects global, retaining the existing conversation and its history.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused producer fix with distinct routing controls and native entry-point evidence; no actionable finding remains.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The exact-head native Gateway report exercises direct-global and main-alias scheduled continuations, retaining the original session ID and single global row; inspected screenshots show the prior duplicate-key failure and corrected review execution with saved results, satisfying the previous review's requested proof.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A scheduled continuation can leave its existing global conversation, lose context, and fail after already performing work.
Reason: The maintainer-authored direction restores the documented same-conversation contract with a narrow producer correction; recovery of previously created duplicate rows is explicitly separate.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it narrowly fixes a current conversation-routing bug, and no actionable defect was found in the introduced diff.

Priority: P1
Reviewed head: 619a3fcb6dbb67cb0af22deca453268630a009fe

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway cron resolver converts scheduled agent and session selectors into destinations consumed by ordinary session admission, execution, and settlement.

flowchart TD
A[Scheduled agent turn] --> B[Gateway cron target resolver]
B --> C[Selected agent and physical session key]
C --> D[Session event admission]
D --> E[Existing conversation and model turn]
E --> F[Cron settlement]
Loading

Technical review

Best possible solution:

Keep the correction in the existing cron resolver, preserving physical global identity without changing storage integrity checks or delivery accounting.

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

The current-main resolver deterministically qualifies the literal global key incorrectly, and the linked report supplies a native reproduction corroborated by the inspected failure screenshot; this review ran no target code.

Is this the best way to solve the issue?

This is the smallest complete prevention fix: preserve the sentinel at the existing producer and extend its routing table, without introducing another owner or weakening duplicate-row rejection.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 292faaa04587.

Provenance checked

  • Cron physical session target resolution keeps the original intent (ec5d369: The migration extraction retained Cron and ordinary session admission as execution owners; earlier resolver origins could not be established because older blobs were unavailable.)
  • Gateway routing regression table keeps the original intent (test(agents,gateway,plugins): remove low-value tests (batch d608) #184557: The earlier consolidation retained distinct boundary contracts while removing redundant fixtures; this PR extends the retained table rather than adding parallel scaffolding.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +4, Tests +7, Docs +2, Other +2. Total +15 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 9 5 +4
Tests 1 13 6 +7
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 4 26 11 +15

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: Scheduled continuation can lose the intended conversation context and report failure after performing useful work, making retries unreliable.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-30T08:07:39.411Z sha 619a3fc :: needs maintainer review before merge. :: none

Reviewed October 30, 2026, 4:16 AM ET / 08:16 UTC (Revision 2).

@shakkernerd

Copy link
Copy Markdown
Contributor Author

The PR now includes fixed-head native execution evidence for 619a3fcb6dbb67cb0af22deca453268630a009fe, plus inspected before/after captures and a recording of the retained run result. The direct-global scheduled review and the main-alias continuation each kept the original session ID and the single physical global row, produced the expected files, and preserved the inputs without a duplicate-key error.

Execution status was ok; the separately scoped missing-channel completion failure remains visible and is not presented as delivered. Recovery of an already-created duplicate pair remains outside this prevention patch.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@shakkernerd
shakkernerd merged commit e1535e4 into main Oct 30, 2026
170 checks passed
@shakkernerd
shakkernerd deleted the global-cron-session-target branch October 30, 2026 08:35
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: explicit global scheduled work stays in the selected agent's existing conversation.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…w#188173)

Keep explicit global scheduled targets in the selected agent's existing conversation under global scope.

Refs openclaw#188165.
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…w#188173)

(cherry picked from commit e1535e4)

Release adaptation: bounded product, matching tests and relevant documentation only. Excluded: config/test-lines-allocations/global-cron-session-target.txt.
Preserve literal global target under global scope; explicit agent-qualified targets unchanged. Related 11.6 canonicalization exists and 188257 follows. Validation queued.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit f84823ee6a6e28e78179be45714160513ab2dbdf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant