Skip to content

refactor: split agent runner execution and preserve probe state - #108137

Merged
steipete merged 9 commits into
mainfrom
codex/refactor-agent-runner-followup
Jul 15, 2026
Merged

steipete merged 9 commits into
mainfrom
codex/refactor-agent-runner-followup

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a maintenance problem where the agent-runner execution path and its test coverage had grown into large monolithic files, making ownership and regression review difficult. Also fixes recovered-primary probe cleanup races that could overwrite a newer persisted or cached model/auth selection.

Why This Change Was Made

Splits execution, fallback candidate selection, settlement, shared types, and thematic tests into focused owner modules while keeping one canonical runtime path. Probe cleanup now compares persisted generations, guards cache replacements, deep-snapshots mutable session state, and uses the canonical session snapshot merger for unrelated concurrent updates.

User Impact

Agent behavior remains equivalent for normal runs. When a primary model recovers during concurrent session updates, newer model/auth selections and nested session state are preserved instead of being replaced by stale probe cleanup.

Evidence

  • 255 agent-runner tests passed across 19 split suites.
  • 34 focused auto-fallback, probe-integration, and session-snapshot tests passed.
  • Core test typecheck and touched-file lint passed.
  • git diff --check passed.
  • Fresh full-branch autoreview: 2/2 complete passes, zero accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Jul 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ff37ce82f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
if (authoritativeEntry) {
if (sessionEntryMatchesSnapshot(currentEntry, activeSessionEntryBeforeUpdate)) {
params.activeSessionStore[params.sessionKey] = authoritativeEntry;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Update the live session snapshot after clearing probes

When a recovered primary probe is cleared from persisted storage, this branch replaces only activeSessionStore[sessionKey]; the caller in agent-runner.ts:1862 still prefers its closed-over activeSessionEntry for fallback bookkeeping and then writes that object back to the store at agent-runner.ts:1887. In runs with an existing persisted auto-fallback entry (especially one with fallback notice fields), the stale in-memory entry can therefore resurrect the auto fallback for the rest of the process even though the database row was cleared; the old inline code mutated the same object, so the caller saw the cleared state. Please either mutate/adopt into the active entry object or return the authoritative entry so the caller can update activeSessionEntry too.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the codex/refactor-agent-runner-followup branch from e84c996 to 73c2e23 Compare July 15, 2026 08:15
@steipete
steipete merged commit ad1071b into main Jul 15, 2026
159 of 161 checks passed
@steipete
steipete deleted the codex/refactor-agent-runner-followup branch July 15, 2026 08:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

SunMe1977 pushed a commit to SunMe1977/openclaw that referenced this pull request Jul 15, 2026
…claw#108137)

* refactor(auto-reply): split agent runner execution

* fix(auto-reply): preserve concurrent probe selection

* fix(auto-reply): refresh rejected probe cache

* fix(auto-reply): preserve probe cache updates

* fix(auto-reply): preserve concurrent probe cache state

* fix(auto-reply): guard persisted probe generation

* fix(auto-reply): snapshot nested probe cache state

* fix(auto-reply): merge probe cleanup cache updates

* fix(auto-reply): privatize fallback cycle types
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 16, 2026
…claw#108137)

* refactor(auto-reply): split agent runner execution

* fix(auto-reply): preserve concurrent probe selection

* fix(auto-reply): refresh rejected probe cache

* fix(auto-reply): preserve probe cache updates

* fix(auto-reply): preserve concurrent probe cache state

* fix(auto-reply): guard persisted probe generation

* fix(auto-reply): snapshot nested probe cache state

* fix(auto-reply): merge probe cleanup cache updates

* fix(auto-reply): privatize fallback cycle types
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…claw#108137)

* refactor(auto-reply): split agent runner execution

* fix(auto-reply): preserve concurrent probe selection

* fix(auto-reply): refresh rejected probe cache

* fix(auto-reply): preserve probe cache updates

* fix(auto-reply): preserve concurrent probe cache state

* fix(auto-reply): guard persisted probe generation

* fix(auto-reply): snapshot nested probe cache state

* fix(auto-reply): merge probe cleanup cache updates

* fix(auto-reply): privatize fallback cycle types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant