Skip to content

refactor(agents): remove stale runner state plumbing - #118495

Merged
steipete merged 6 commits into
mainfrom
cleanup/agents-sessions-smalls
Aug 3, 2026
Merged

steipete merged 6 commits into
mainfrom
cleanup/agents-sessions-smalls

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Removes stale agent/session plumbing that had accumulated after features were disabled or split across runners, and fixes a metadata drift where abort-wrapped tools lost their trusted terminal presentation.

Why This Change Was Made

The reply pipeline retained an unreachable Working: status path behind a literal false; the CLI and embedded runners separately assembled identical bootstrap-budget state; and six tool-cloning paths manually copied identity-backed metadata with one path missing terminal presentation. This change deletes the disabled path, gives bootstrap diagnosis and cloned-tool metadata one canonical owner, and keeps caller-specific routing/order behavior intact.

Session-key facade replacements were limited by byte equivalence: requester, depth, and status candidates intentionally preserve raw casing and lookup order, so they remain unchanged. No config, protocol, storage, or Plugin SDK surface changes.

AI-assisted implementation and review.

User Impact

Most of the change is behavior-neutral cleanup. Tools wrapped for abort handling now retain deterministic terminal summaries instead of silently losing that presentation metadata.

Evidence

  • /Users/steipete/Projects/openclaw/node_modules/.bin/oxfmt <touched TypeScript files> — passed.
  • git diff --check — passed before commit and again on the staged patch.
  • node scripts/run-vitest.mjs src/agents/bootstrap-budget.test.ts src/agents/embedded-agent-runner/run/attempt.spawn-workspace.bootstrap-warning.test.ts — 24 passed.
  • node scripts/run-vitest.mjs src/agents/bootstrap-budget.test.ts src/agents/embedded-agent-runner/run/attempt.spawn-workspace.bootstrap-warning.test.ts src/agents/prompt-composition.test.ts — 30 passed after the CI type/cycle repair.
  • node scripts/run-vitest.mjs src/agents/agent-tools.runtime.test.ts src/agents/agent-tools.schema.test.ts src/agents/agent-tools.deferred-followup-guidance.test.ts src/agents/tools/gateway-caller-context.test.ts src/agents/runtime-plan/tools.test.ts src/agents/embedded-agent-runner/run/tool-activity-heartbeat.test.ts — 111 passed across five shards.
  • node scripts/run-vitest.mjs src/auto-reply/reply/dispatch-from-config.test.ts — 311 passed.
  • node scripts/run-vitest.mjs src/agents/cli-runner/prepare.test.ts src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-injection.test.ts — 109 passed across two shards.
  • Codex autoreview, uncommitted mode, gpt-5.6-sol high reasoning — clean on the full patch and every CI follow-up; no accepted/actionable findings (0.98–0.99 confidence).
  • Regression coverage added for abort-wrapped terminal presentation and canonical bootstrap-budget composition; the heartbeat metadata test now uses the real private marker/source symbols instead of unrelated lookalikes.
  • An initial local test attempt was interrupted before Vitest started because this shared host was saturated in the repository planner; the later focused commands above passed. node scripts/check-changed.mjs classified the patch, then failed because no remote provider was ready (blacksmith-testbox doctor timeout; other configured providers unavailable). Exact-head hosted PR CI supplies the heavy type/lint/guard proof.
  • Exact-head hosted CI run 30788158149 — green, including build artifacts, test types, dependency/unused-export checks, import-cycle architecture, lint, focused and compact Node shards, QA smoke, and openclaw/ci-gate.
  • Production LOC: +316 / -443 (net -127). Test LOC: +67 / -45 (net +22).

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 3, 2026
@steipete
steipete marked this pull request as ready for review August 3, 2026 05:10
@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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 3, 2026, 4:49 AM ET / 08:49 UTC.

ClawSweeper review

What this changes

This PR centralizes identity-backed agent-tool metadata copying, unifies bootstrap-budget warning state for CLI and embedded runners, and removes unreachable auto-reply working-status plumbing.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 3 items remain

The patch is a coherent net-reducing cleanup with no discrete correctness defect found in the reviewed source, but it still needs inspectable after-fix real-behavior proof before merge. Current main does not already contain its central refactor, and the protected maintainer label keeps this PR for explicit human handling rather than automated cleanup.

Priority: P3
Reviewed head: 15d0514eccdcf6b8f7017c5d01e6dfeff1d24a9e

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is coherent and source-backed, but missing real behavior proof remains a merge gate.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: Focused tests and hosted-CI claims are useful supplemental evidence, but this external PR still lacks inspectable after-fix runtime output showing the repaired terminal presentation; add a redacted terminal transcript, recording, or runtime log before merge. 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.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Focused tests and hosted-CI claims are useful supplemental evidence, but this external PR still lacks inspectable after-fix runtime output showing the repaired terminal presentation; add a redacted terminal transcript, recording, or runtime log before merge. 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 7 items Canonical metadata owner: The new helper copies all five identity-backed metadata families, including terminal presentation, so wrapper paths use one preservation contract instead of maintaining divergent copy lists.
Wrapper coverage: The PR routes abort, deferred-followup, schema normalization, heartbeat, runtime-plan, and Gateway caller wrappers through the canonical metadata helper; the abort wrapper has focused coverage for terminal presentation retention.
Canonical bootstrap state reaches both runners: The shared builder owns limits, injection analysis, and warning state; both CLI preparation and embedded-attempt preparation call it after retaining their caller-specific routing decisions.
Findings None None.
Security None None.

How this fits together

Agent runners build workspace bootstrap context and wrap tools before sending work to model and channel execution paths. The copied metadata carries policy, hooks, channel details, terminal presentation, and control-flow identity across those wrappers, while bootstrap analysis feeds prompt warnings and run metadata.

flowchart LR
  A[Workspace bootstrap files] --> B[CLI and embedded runners]
  B --> C[Bootstrap budget diagnosis]
  C --> D[Prompt warning and run metadata]
  E[Agent tools] --> F[Tool wrappers]
  F --> G[Policy hooks and terminal presentation]
  H[Auto-reply callbacks] --> I[Channel progress delivery]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Focused tests and hosted-CI claims are useful supplemental evidence, but this external PR still lacks inspectable after-fix runtime output showing the repaired terminal presentation; add a redacted terminal transcript, recording, or runtime log before merge. 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.
  • Resolve merge risk (P1) - An agent-tool wrapper can affect terminal output without a failing unit test; merge should wait for a redacted real agent-run artifact showing that an abort-wrapped tool still renders its terminal presentation.
  • Complete next step (P2) - This protected maintainer-labeled PR has no mechanical repair finding; it needs contributor-supplied real behavior proof and normal maintainer merge review.
Agent review details

Security

None.

PR surface

Source -127, Tests +22. Total -105 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 18 316 443 -127
Tests 6 67 45 +22
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 24 383 488 -105

Review metrics

Metric Value Why it matters
Production versus test LOC production +316/-443 (net -127); tests +67/-45 (net +22) The refactor materially reduces production code while adding focused regression coverage for the new canonical owners.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/agents/agent-tool-metadata.ts, vector/embedding metadata: src/agents/agent-tools.abort.ts, vector/embedding metadata: src/agents/agent-tools.deferred-followup.ts, vector/embedding metadata: src/agents/agent-tools.runtime.test.ts, vector/embedding metadata: src/agents/agent-tools.schema.ts, vector/embedding metadata: src/agents/embedded-agent-runner/run/tool-activity-heartbeat.test.ts, and 3 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the canonical metadata and bootstrap-state refactor, then add a redacted real runtime transcript or terminal capture showing preserved terminal presentation through the abort wrapper before merging.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the canonical metadata and bootstrap-state refactor, then add a redacted real runtime transcript or terminal capture showing preserved terminal presentation through the abort wrapper before merging.

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

Yes from source: the current abort wrapper copies three identity-backed markers but omits terminal presentation, while sibling wrapper paths already preserve it. A real runtime reproduction has not been supplied in the PR materials.

Is this the best way to solve the issue?

Yes. A single canonical metadata copier and a shared bootstrap-state builder remove the duplicate owner-boundary logic while preserving each runner's routing decisions; no safer competing implementation was found.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is low-urgency internal agent-runner cleanup with a bounded presentation-metadata repair rather than a reported outage or user-blocking regression.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused tests and hosted-CI claims are useful supplemental evidence, but this external PR still lacks inspectable after-fix runtime output showing the repaired terminal presentation; add a redacted terminal transcript, recording, or runtime log before merge. 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

What I checked:

  • Canonical metadata owner: The new helper copies all five identity-backed metadata families, including terminal presentation, so wrapper paths use one preservation contract instead of maintaining divergent copy lists. (src/agents/agent-tool-metadata.ts:12, 15d0514eccdc)
  • Wrapper coverage: The PR routes abort, deferred-followup, schema normalization, heartbeat, runtime-plan, and Gateway caller wrappers through the canonical metadata helper; the abort wrapper has focused coverage for terminal presentation retention. (src/agents/agent-tools.abort.ts:73, 15d0514eccdc)
  • Canonical bootstrap state reaches both runners: The shared builder owns limits, injection analysis, and warning state; both CLI preparation and embedded-attempt preparation call it after retaining their caller-specific routing decisions. (src/agents/bootstrap-budget.ts:187, 15d0514eccdc)
  • Existing-path provenance: The original abort wrapper copied only plugin, channel, and before-tool-call markers; its current-base blame attributes that implementation and the adjacent embedded bootstrap assembly to the same feature-introduction commit. (src/agents/agent-tools.abort.ts:75, 2781abf960)
  • Current-main comparison: The only post-base agent-related main commit visible in the checked-out history is an unrelated Telegram model-status fix, and the proposed 24-file refactor remains distinct from current main. (b21056a0dcb8)
  • Patch hygiene: The proposed patch passes whitespace validation; no textual merge-conflict markers were produced by the three-way merge inspection against the checked-out current main. (15d0514eccdc)

Likely related people:

  • joshavant: Current-base blame attributes the pre-refactor abort metadata copying and embedded bootstrap-budget assembly to the feature-introduction commit. (role: original feature contributor; confidence: high; commits: 2781abf960; files: src/agents/agent-tools.abort.ts, src/agents/embedded-agent-runner/run/attempt-bootstrap-prepare.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted real agent-run terminal capture proving an abort-wrapped tool retains its terminal summary; redact private endpoints, identifiers, and secrets before posting it.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-08-03T05:15:56.249Z sha da5285289876f58edad8c7585fc7c53f8ce44d6e :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T05:33:24.854Z sha 56f846b52e5a6cceb72603603f1d7d9f479f703b :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T05:46:43.017Z sha 7f28f0866f5c52f47d2143da860aa0ede593a2f9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T05:53:33.250Z sha a3627ce :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T06:04:02.376Z sha a3627ce :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T08:40:06.512Z sha 916e0c3 :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the cleanup/agents-sessions-smalls branch from da52852 to 56f846b Compare August 3, 2026 05:27
@steipete
steipete force-pushed the cleanup/agents-sessions-smalls branch 4 times, most recently from a3627ce to 916e0c3 Compare August 3, 2026 08:14
@steipete
steipete force-pushed the cleanup/agents-sessions-smalls branch from 916e0c3 to 15d0514 Compare August 3, 2026 08:43
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 3, 2026
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Rank-up move disposition: I am not adding a synthetic terminal capture. The affected contract is identity-backed formatter retention across the internal abort wrapper, and there is no stable operator command that deterministically selects that wrapper/presentation pairing without provider and model nondeterminism. The direct regression asserts the exact formatter identity through the real wrapper; exact-head CI and the native Testbox-backed prepare gate are green. A manufactured transcript would be less precise evidence and would not improve the ownership-boundary proof.

@steipete steipete self-assigned this Aug 3, 2026
@steipete
steipete merged commit e797e69 into main Aug 3, 2026
124 of 126 checks passed
@steipete
steipete deleted the cleanup/agents-sessions-smalls branch August 3, 2026 08:59
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 3, 2026
…ion-routing

* origin/main:
  refactor(agents): remove stale runner state plumbing (#118495)
  test(gateway): skip servers for handler fixtures (#118581)
  test(tui): reuse real gateway PTY fixture (#118567)
  fix: keep command tests independent of ambient Gateway tokens (#118577)
  fix: show effective channel model in Telegram status (#118548)
  test(system-agent): reuse approval CLI fixture (#118572)
  test(macos): deduplicate Claude session catalog fixtures (#118571)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
* refactor(agents): remove stale runner state plumbing

* refactor(agents): keep bootstrap warning owner reachable

* refactor(agents): inline bootstrap warning predicates

* refactor(agents): extract bootstrap warning contracts

* refactor(agents): keep bootstrap detail type private

* refactor(auto-reply): drop vacuous abort returns
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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L 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