Skip to content

refactor(agents): split code mode execution - #113669

Merged
steipete merged 2 commits into
mainfrom
codex/r2-codemode
Jul 25, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/r2-codemode

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

src/agents/code-mode.ts had grown to 2,373 lines and remained grandfathered in the max-lines baseline. Its configuration, source preparation, worker transport, bridge dispatch, headless orchestration, suspended-run lifecycle, interactive execution, and public catalog facade shared one file, making ownership and review unnecessarily broad.

Why This Change Was Made

This AI-assisted, maintainer-commissioned refactor mechanically separates those responsibilities into cohesive modules while preserving the existing code-mode.ts public surface and test-only hook. It stays consistent with the child-program boundary extracted in #113237 and does not change config, protocol, runtime behavior, lazy imports, or tests.

User Impact

No user-visible behavior changes. Maintainers get smaller ownership boundaries: the public facade is 334 lines and every extracted production module is between 164 and 499 lines, so src/agents/code-mode.ts can leave the max-lines baseline.

Evidence

  • Numstat: production +2221/-2077; tests +0/-0; config/baseline +0/-1; repository net +143. The added production lines are module import/export boundaries; execution logic and comments are preserved.
  • node scripts/run-vitest.mjs src/agents/code-mode.test.ts src/agents/code-mode-headless.test.ts src/agents/code-mode-swarm.test.ts src/agents/agent-tools.before-tool-call.integration.e2e.test.ts — remote Testbox equivalent passed 119 tests across 4 files / 2 shards.
  • CI=1 OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 pnpm build — passed; no [INEFFECTIVE_DYNAMIC_IMPORT] warning.
  • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1 corepack pnpm check:changed — passed, including max-lines ratchet, core and test typechecks, core/script lint, and 0 runtime import cycles.
  • Blacksmith Testbox: tbx_01kycm0azbhc1ybpfb7t357fhv; hydration run https://github.com/openclaw/openclaw/actions/runs/30158056901
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted — clean, no accepted/actionable findings.
  • git diff --check — passed.

@steipete
steipete marked this pull request as ready for review July 25, 2026 12:55
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Jul 25, 2026
@steipete
steipete force-pushed the codex/r2-codemode branch from 2363cdb to accdbe7 Compare July 25, 2026 13:17
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for the rebased head accdbe7925883f7a82c2d593214088dafdd34ea7:

  • Focused behavior proof: pnpm test src/agents/code-mode.test.ts src/agents/code-mode-headless.test.ts src/agents/code-mode-swarm.test.ts src/agents/agent-tools.before-tool-call.integration.e2e.test.ts passed 119 unchanged tests across the agents and E2E shards on Blacksmith Testbox tbx_01kycm0azbhc1ybpfb7t357fhv.
  • Packaged proof: CI=1 OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 pnpm build passed with no [INEFFECTIVE_DYNAMIC_IMPORT] warning.
  • Broad proof: OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1 corepack pnpm check:changed passed, including max-lines ratchet, core/test typechecks, lint, and 0 runtime import cycles.
  • CI recovery: run 30158793214 found one overly broad internal type export; after making it private, both pnpm deadcode:exports and pnpm deadcode:dependencies passed. Exact-head CI run 30159178693 is green on 2363cdba6647983f5a0946bb4a1b137c90cb8a86.
  • Final rebase: stable patch ID 44bbf85285b4a8a1788d53643e88667dbd1dc90b is identical before and after rebasing onto current origin/main; git diff --check origin/main...HEAD passed.
  • Autoreview: the full uncommitted split and the later type-visibility fix each completed cleanly with no accepted/actionable findings.
  • LOC: production +2221/-2077; tests +0/-0; baseline/config +0/-1. The target is 334 lines and every extracted production module is 164–499 lines.

ClawSweeper congested-publisher exception: the latest exact-head ClawSweeper comment is still only the generated “review started” placeholder and contains no review or Rank-up moves: list. Per the commissioned fleet precedent, there are no published moves to apply or skip, so landing proceeds on the source, unchanged tests, Testbox proof, exact-head green CI, clean autoreview, and patch-identical rebase evidence above.

Testbox tbx_01kycm0azbhc1ybpfb7t357fhv has been stopped.

@steipete
steipete merged commit e52222c into main Jul 25, 2026
115 checks passed
@steipete
steipete deleted the codex/r2-codemode branch July 25, 2026 13:22
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant