Skip to content

refactor: unify the embedded-agent fallback run-entry across all four pipelines - #111608

Merged
steipete merged 3 commits into
mainfrom
refactor/unified-run-entry
Jul 20, 2026
Merged

steipete merged 3 commits into
mainfrom
refactor/unified-run-entry

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Four separate pipelines wrapped runWithModelFallback + runEmbeddedAgent with their own copies of fallback-candidate construction, result classification, exhausted-result merging, retry indexing, abort projection, terminal-outcome normalization, and completed-session reconciliation: the channel reply path, the gateway command/RPC path, the memory-flush maintenance path, and the follow-up delivery path. The copies drifted (that drift class has produced real bugs), and every failover change had to be made four times.

Why This Change Was Made

One shared runEmbeddedAgentEntry helper now owns the common lifecycle, with intentional per-path differences expressed as closed discriminated variants (channel-delivery / command-rpc / maintenance / followup-delivery, and preserve / reconcile-completed session handling) instead of caller-side plumbing — impossible states unrepresentable, and terminal projection normalized through agent-run-terminal-outcome.ts as the repo mandates. Behavior is intentionally unchanged; genuinely different semantics (maintenance's thrown-errors-only fallback, follow-up's preserve-on-exhaustion, command's committed-cron-media retry guard, channel delivery evidence) remain explicit per variant. A detailed two-path/four-path comparison map with file:line cites is in the review artifacts.

User Impact

No behavior change. Future failover/terminal fixes land once instead of four times; the divergence class that produced past regressions is structurally closed. One remaining direct call site (src/cron/isolated-agent/run-executor.ts) is outside these four pipelines and noted as follow-up.

Evidence

  • 941 tests across the 43 owning suites (channel agent-runner, command attempt-execution, live-model-switch), plus 54 memory-suite, 152 follow-up-suite, and new helper regression tests proving identical shared behavior across configurations and each variant's contract — all passing.
  • Changed-file gate green (typechecks, lint, boundaries, import cycles: 0 runtime value cycles); format/oxlint clean; git diff --check clean; autoreview clean (one earlier finding rejected with line-cited proof of abort forwarding).
  • Production LOC: caller regions net −38; the new 319-line shared owner makes the total +281 — accepted trade: four divergence-prone copies collapse into one typed canonical path.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Jul 20, 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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 20, 2026
@clawsweeper

clawsweeper Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 20, 2026, 1:32 AM ET / 05:32 UTC.

Summary
The branch replaces four embedded-agent model-fallback wrappers with a shared typed runEmbeddedAgentEntry helper for channel delivery, command RPC, memory maintenance, and follow-up delivery.

PR surface: Source +302, Tests +333. Total +635 across 12 files.

Reproducibility: not applicable. This PR is presented as a behavior-preserving refactor, not a report of a currently failing user workflow. The relevant evidence needed is after-fix runtime equivalence across the four execution variants.

Review metrics: 1 noteworthy metric.

  • Lifecycle pipelines centralized: 4 pipelines routed through 1 shared entrypoint. The refactor centralizes fallback, terminal, and settlement behavior across paths with intentionally different contracts, increasing the value of runtime equivalence proof.

Stored data model
Persistent data-model change detected: vector/embedding metadata: src/agents/embedded-agent-runner/run-entry.ts, vector/embedding metadata: src/auto-reply/reply/agent-runner-fallback-settlement.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof is added.

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

Rank-up moves:

  • [P2] Add redacted runtime proof showing an actual embedded-agent fallback or terminal path through the shared helper.
  • Diagnose and resolve the failing check-test-types check, then refresh the review evidence.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Tests and static checks are supplemental only; add a redacted after-fix embedded-agent execution transcript, runtime log, terminal output, or recording that shows a representative fallback or terminal path through the new shared entrypoint. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P2] The shared helper now controls terminal projection and session settlement for four distinct pipelines; an unproven variant mismatch could regress completed-session reconciliation or fallback terminal handling.
  • [P1] check-test-types is failing without a supplied diagnosis, so the changed shared contracts are not yet fully validated.
  • [P2] The PR has no redacted after-fix runtime evidence demonstrating real embedded-agent fallback behavior, abort handling, or terminal outcome propagation.

Maintainer options:

  1. Prove each runtime contract before merge (recommended)
    Provide redacted real fallback/terminal evidence for the shared entrypoint and resolve check-test-types so session reconciliation and failure handling are verified across the affected pipelines.
  2. Pause for boundary redesign
    Pause the PR if maintainer review concludes that the four pipelines do not share a stable enough lifecycle contract for one canonical owner.

Next step before merge

  • [P1] The protected maintainer label, missing real behavior proof, and unresolved type-test failure require a human merge decision rather than an automated repair attempt.

Maintainer decision needed

  • Question: After the failing type-test check is diagnosed and redacted runtime evidence demonstrates the shared helper on representative fallback and terminal paths, should this cross-pipeline refactor be accepted as the canonical lifecycle owner?
  • Rationale: The protected maintainer signal and the choice to centralize four intentionally different runtime contracts require an owner to judge whether the abstraction boundary remains appropriate after proof is complete.
  • Likely owner: steipete — The available evidence ties this person to the proposed shared lifecycle boundary; broader current-main ownership needs history confirmation.
  • Options:
    • Require proof and clean validation (recommended): Keep the canonical helper direction, but require a redacted real execution artifact plus a resolved check-test-types result before merge.
    • Narrow the refactor: Retain only the common fallback mechanics and move any path-specific terminal or settlement behavior back behind narrower owners if runtime proof exposes a contract mismatch.

Security
Cleared: The supplied diff is limited to TypeScript agent-runtime refactoring and tests; it adds no dependency, workflow, publishing, secret, permission, or artifact-execution surface.

Review details

Best possible solution:

Keep one typed shared entrypoint only if representative real executions prove each variant preserves its intended fallback, abort, terminal, and session-settlement contract, and resolve the failing type-test check before a maintainer decides whether to merge.

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

Not applicable: this PR is presented as a behavior-preserving refactor, not a report of a currently failing user workflow. The relevant evidence needed is after-fix runtime equivalence across the four execution variants.

Is this the best way to solve the issue?

Unclear: centralizing repeated lifecycle logic is a plausible maintainability improvement, but it is the best solution only if real executions confirm that the variant-specific fallback, abort, terminal, and session contracts remain unchanged.

AGENTS.md: unclear because the file could not be read completely.

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

Label changes

Label justifications:

  • P2: This is a high-surface internal runtime refactor with meaningful but not demonstrated user-facing regression risk.
  • merge-risk: 🚨 session-state: The patch moves completed-session reconciliation and terminal metadata ownership into one helper used by channel and follow-up settlement paths.
  • merge-risk: 🚨 availability: The helper now mediates model fallback, abort projection, and terminal error handling across four agent execution pipelines.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Tests and static checks are supplemental only; add a redacted after-fix embedded-agent execution transcript, runtime log, terminal output, or recording that shows a representative fallback or terminal path through the new shared entrypoint. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +302, Tests +333. Total +635 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 10 575 273 +302
Tests 2 335 2 +333
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 910 275 +635

What I checked:

  • Shared lifecycle surface: The PR introduces runEmbeddedAgentEntry as the owner of fallback candidate construction, result classification, exhaustion merging, abort projection, terminal normalization, and session settlement, then routes four runtime pipelines through it. (src/agents/embedded-agent-runner/run-entry.ts:1, dbd65204d906)
  • Session settlement moved into the shared result: Channel fallback settlement now calls the shared result’s settleSessionOverride() and reads shared terminal metadata, so a mismatch in the helper can affect completed-session reconciliation. (src/auto-reply/reply/agent-runner-fallback-settlement.ts:65, dbd65204d906)
  • Current validation state: Most supplied CI checks are green, but check-test-types is completed with failure and its cause is not present in the review context; several remaining checks are still in progress. (dbd65204d906)
  • Proof gate remains unmet: The PR body reports tests and static gates but contains no after-fix live embedded-agent run transcript, redacted runtime log, terminal output, recording, or linked artifact showing the shared helper preserves a real fallback or terminal path. (dbd65204d906)
  • Prior review continuity: The previous completed ClawSweeper cycle raised only the missing-real-behavior-proof blocker and no code findings; the current PR body still does not supply that proof. (58e2e57428fc)

Likely related people:

  • steipete: The supplied PR history shows authorship of both commits that introduce the shared helper and update its callers; current-main feature ownership could not be established from the available read-only evidence. (role: current refactor author; confidence: low; commits: 58e2e57428fc, dbd65204d906; files: src/agents/embedded-agent-runner/run-entry.ts, src/agents/command/run-embedded-attempt.ts, src/auto-reply/reply/agent-runner-fallback-candidate.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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-20T02:09:26.765Z sha 58e2e57 :: needs real behavior proof before merge. :: none

@steipete
steipete merged commit f67e55a into main Jul 20, 2026
118 checks passed
@steipete
steipete deleted the refactor/unified-run-entry branch July 20, 2026 06:08
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 20, 2026
… pipelines (openclaw#111608)

* refactor(agents): unify fallback run-entry across channel, command, memory, and follow-up paths

* refactor(agents): keep run-entry contracts module-local

* test(reply): derive run-entry params type locally
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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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: XL 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.

1 participant