Skip to content

refactor(agents): unify tool availability and plugin work ownership - #152073

Merged
steipete merged 3 commits into
mainfrom
codex/tool-runtime-architecture
Sep 18, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/tool-runtime-architecture

Conversation

@steipete

@steipete steipete commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Related: #151651

What Problem This Solves

Copilot could lose managed GitHub publication tools despite successful host preparation, and plugin replacement could begin while model preparation still used the selected registry.

User Impact

Built-in, Codex, and Copilot harnesses receive the host-prepared publication tools allowed by their tool profile. Plugin replacement waits for active construction and run work while idle cached publications remain replaceable.

SDK behavior note: the host now takes precedence over a harness-supplied githubPublicationAvailable option. Existing method and option types remain accepted; tool profiles and allow/deny policy remain the visibility controls. This documented ownership decision addresses ClawSweeper's compatibility concern. No configuration, schema, protocol, or permission change is required.

Why This Change Was Made

One host owns publication availability, and one construction scope retains registry work through the complete build. Active work is independent of physical plugin-resource custody. Codex's production test-factory bypass is removed; fixtures preserve real host identity where authority is exercised.

Pure attempt-context mapping no longer imports Gateway startup. A single Gateway test-listener dispatcher replaces overlapping spies that could recurse or restore prematurely.

Production code: 40 fewer lines. Tests/support: 430 additional lines. Documentation: 8 additional lines.

Evidence

  • Complete final-head check:changed passed, including all four typecheck lanes, lint, dead exports, SDK budgets, and boundary/storage/import-cycle guards.
  • 306 post-rebase Codex cases verified across the initial run and focused rerun; 23 final-head requester-authority, listener-overlap, and registry-construction cases passed. Two fixture-arity failures were repaired; one five-second polling case passed unchanged on the focused rerun. CI import/type/lint findings were corrected without weakening assertions.
  • The pre-rebase candidate also passed 675 focused cases and a full build on Blacksmith Testbox. Independent P0–P2 reviews are clean.
  • Exact-head CI passed for a693772edd9460b9e75dbff7371dc3c41eb753ec: https://github.com/openclaw/openclaw/actions/runs/35385992419 (zero pending checks).

Gateway flow evidence uses isolated synthetic fixtures; no live provider call or production deployment is claimed. Direct upstream Codex source inspection confirmed dynamic tools initialize at thread start and are copied from session configuration; this change preserves that protocol contract.

@clawsweeper

clawsweeper Bot commented Sep 18, 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 agents Agent runtime and tooling extensions: codex extensions: copilot size: XL maintainer Maintainer-authored PR labels Sep 18, 2026
@steipete
steipete marked this pull request as ready for review September 18, 2026 18:57
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 18, 2026, 3:33 PM ET / 19:33 UTC (Revision 3).

ClawSweeper review

What this changes

Centralizes GitHub tool availability in the agent host, retains plugin work throughout model preparation, and replaces production test hooks with scoped test fixtures.

Merge readiness

⛔ Blocked before merge - 1 item remains

The PR remains useful: current main lacks these availability and lifecycle fixes. No blocking defect was found, and the PR body explicitly resolves the earlier compatibility decision.

Priority: P2
Reviewed head: a693772edd9460b9e75dbff7371dc3c41eb753ec

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused ownership repair with meaningful regression coverage, no blocking findings, and an explicitly accepted SDK compatibility tradeoff.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported isolated Gateway and focused tests support host availability and registry lifetime behavior; no live provider or deployment proof is claimed, and the diff does not materially expand execution authority.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported isolated Gateway and focused tests support host availability and registry lifetime behavior; no live provider or deployment proof is claimed, and the diff does not materially expand execution authority.
Evidence reviewed 9 items Host owns availability without replacing execution guards: The host captures the prepared availability at construction and applies it after plugin options. Tool construction still passes through host binding, source execution guards, abort handling, and live authority checks.
Current main still needs the changes: Inspection of fetched main shows createToolSurface still forwards plugin options without the host availability override, and workspace preparation still limits registry work borrowing to its local facts scope. The related merged continuation fix does not cover these remaining paths.
Construction and idle publication have distinct lifetimes: Build resources retain selected registries and finite work through the batch; generation run leases retain work even for externally owned registries. Regression coverage checks owned and Gateway registries across run, configured, and explicit preparation, then permits replacement after work settles.
Findings None None.
Security None None.

How this fits together

The agent host prepares tools and plugin resources before handing an attempt to the built-in, Codex, or Copilot harness. Tool policy controls the visible catalog, while live Gateway authority controls execution.

flowchart TD
  A[Admitted agent attempt] --> B[Prepare GitHub availability]
  B --> C[Host constructs tools]
  C --> D[Tool policy filters catalog]
  D --> E[Selected agent harness]
  E --> F[Live authority checks and execution]
  G[Plugin registry build and run claims] --> E
  G --> H[Release work before replacement]
Loading

Before merge

  • Resolve merge risk (P1) - Third-party harnesses that relied on githubPublicationAvailable as a per-call visibility override will receive the host-selected catalog instead; external reliance is unestablished, and the PR explicitly accepts this compatibility tradeoff.
Agent review details

Security

None.

PR surface

Source -2, Tests +392, Docs +8. Total +398 across 42 files.

View PR surface stats
Area Files Added Removed Net
Source 16 218 220 -2
Tests 24 638 246 +392
Docs 2 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 42 864 466 +398

Review metrics

Metric Value Why it matters
SDK behavior 1 option precedence change; existing call signatures retained Harness authors must use tool policy instead of overriding host-prepared publication availability.

Merge-risk options

Maintainer options:

  1. Retain the documented host precedence (recommended)
    Accept the explicitly documented SDK behavior change and use existing tool profiles or allow/deny policy for visibility control.

Technical review

Best possible solution:

Keep one host-owned availability decision and batch-owned plugin work lifetime, with the documented SDK precedence change accepted and existing tool-policy controls preserved.

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

Yes, from source: Copilot omits the publication flag while current main forwards only harness options, and registry work claims can end before later catalog projection. The focused regressions cover these triggers; this review did not execute them.

Is this the best way to solve the issue?

Yes. Centralizing the prepared fact and extending the existing resource owner removes competing ownership without adding configuration or changing publication authorization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 47b6eb550cb4.

Labels

Label justifications:

  • P2: Repairs bounded tool-availability and plugin-replacement defects without evidence of an emergency outage.
  • merge-risk: 🚨 compatibility: The host now overrides a previously forwarded SDK option, an intentional compatibility tradeoff explicitly accepted in the PR body.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported isolated Gateway and focused tests support host availability and registry lifetime behavior; no live provider or deployment proof is claimed, and the diff does not materially expand execution authority.

Evidence

What I checked:

  • Host owns availability without replacing execution guards: The host captures the prepared availability at construction and applies it after plugin options. Tool construction still passes through host binding, source execution guards, abort handling, and live authority checks. (src/agents/harness/host-capability.ts:518, a693772edd94)
  • Current main still needs the changes: Inspection of fetched main shows createToolSurface still forwards plugin options without the host availability override, and workspace preparation still limits registry work borrowing to its local facts scope. The related merged continuation fix does not cover these remaining paths. (src/agents/prepared-model-runtime.facts.ts:163, 47b6eb550cb4)
  • Construction and idle publication have distinct lifetimes: Build resources retain selected registries and finite work through the batch; generation run leases retain work even for externally owned registries. Regression coverage checks owned and Gateway registries across run, configured, and explicit preparation, then permits replacement after work settles. (src/agents/prepared-model-runtime.registry-borrow.test.ts:247, a693772edd94)
  • Compatibility disposition and review continuity: The captured PR body explicitly accepts host precedence over githubPublicationAvailable and identifies tool profiles and allow/deny policy as supported visibility controls. The previous completed review contained no findings or published rank-up moves. GitHub's exact-head commit patch confirms the latest change only renames a shadowing test callback parameter. (extensions/codex/src/app-server/side-question.test-support.ts:91, a693772edd94)
  • Dependency signal: The changed Codex dynamic-tool builder calls the host tool constructor, and the PR explicitly claims preservation of Codex thread-start dynamic-tool semantics. This establishes the dependency-specific inspection requirement. (extensions/codex/src/app-server/dynamic-tool-build.ts:369, a693772edd94)
  • Direct Codex contract inspection: Personally inspected the sibling source: thread startup validates dynamic_tools and passes them into StartThreadOptions; session persistence copies session_configuration.dynamic_tools. Ownership was verified through the backing cache's GitHub remote, rather than inferred from its directory name. (codex-rs/app-server/src/request_processors/thread_processor.rs:1422, 6b9826e3aa83)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • jalehman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (2 earlier review cycles)
  • reviewed 2026-09-18T19:06:06.598Z sha 93f78c6 :: blocked before merge. :: none
  • reviewed 2026-09-18T19:17:32.251Z sha c2637bd :: blocked before merge. :: none

@VACInc

VACInc commented Sep 18, 2026

Copy link
Copy Markdown
Member

Related plugin-construction contract landed in #150295: contextVersion: 2 tool factories receive a required assertInvocationCurrent guard, composed with the admitted invocation and plugin lifetime, and only explicitly opted-in factories can receive continued owner identity after the exact parent yields. Legacy direct-turn behavior is retained without granting legacy factories continuation authority.

This does not implement this PR's host-owned GitHub publication availability or active construction/run work ownership changes. Keeping this PR open. When integrating the shared tool-construction paths, preserve the V2 opt-in boundary and final-effect guard rather than treating owner availability as invocation authority.

@steipete
steipete merged commit 45849c0 into main Sep 18, 2026
218 checks passed
@steipete
steipete deleted the codex/tool-runtime-architecture branch September 18, 2026 20:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 18, 2026
…/current-conversation-binding-row

* commit 'f5276e5a54c088dd23475f08479acd9738d959bd': (46 commits)
  perf(plugins): combine runtime and tool call scopes (#152101)
  test(memory): seed restart fixtures with the Gateway stopped (#152038)
  perf(gateway): avoid session list stalls on broad updates (#152074)
  fix: preserve model failure causes and worker fallback runtime (#152028)
  perf(logging): reduce Gateway hot-path info log volume (#152080)
  improve(gateway): reduce duplicate worker data fetched from SQLite (#151878)
  improve: format messages with many links faster (#152112)
  perf(cron): avoid unused SQL binding in config projections (#152029)
  fix: explain cloud worker startup failures (#152043)
  refactor(discord): share Markdown edit projection (#149214)
  refactor(media): remove unreachable geometry metadata backfills (#149272)
  chore(autoreview): sync mirror to agent-skills a7e91e1 (#152039)
  fix(ui): restore sidebar and chat test collection (#152099)
  fix(clickclack): finish SQLite cleanup between persistence tests (#152061)
  fix(workboard): isolate board deletion from unrelated subscriptions (#152102)
  refactor(agents): unify tool availability and plugin work ownership (#152073)
  fix: session group moves lag while requests are pending (#151689)
  fix(agents): preserve active cleanup during requester settlement (#151907)
  perf(sessions): keep deletion responsive under disk pressure (#152092)
  fix: preserve successful direct replies without serializing bookkeeping keys (#151870)
  ...
vincentkoc added a commit that referenced this pull request Sep 18, 2026
…pr-149282-proof-20260918

* refs/remotes/origin/main:
  fix(clickclack): finish SQLite cleanup between persistence tests (#152061)
  fix(workboard): isolate board deletion from unrelated subscriptions (#152102)
  refactor(agents): unify tool availability and plugin work ownership (#152073)
  fix: session group moves lag while requests are pending (#151689)
  fix(agents): preserve active cleanup during requester settlement (#151907)
  perf(sessions): keep deletion responsive under disk pressure (#152092)
  fix: preserve successful direct replies without serializing bookkeeping keys (#151870)
  fix(gateway): keep the previous plugin generation serving when a replacement stalls on admitted work (#151273)
  fix(agents): resume parent tasks after provider retries (#151879)
  perf(skills): silence identical collisions across workspaces (#152062)
  fix: reduce Doctor preparation time for large fleets (#151366)
  perf(ui): reuse session snapshots for roster updates (#152067)
  perf(tasks): skip SQLite admission for transient agent events (#152088)
  fix: await initial task persistence before Gateway activation (#151634)
  test: keep Vitest prototype ownership on execFile mocks (#152064)
  fix(pr): recover interrupted checkouts and isolate allocation state (#152069)
  fix(test): keep quota observer armed during Codex prewarm (#152090)
  fix(cron): keep scheduled jobs alive after their creating request ends (#152051)
  refactor(shared): reduce immutable graph traversal allocations (#152077)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 19, 2026
…penclaw#152073)

* refactor(agents): unify tool and plugin work ownership

* test(agents): align migrated fixtures with host contracts

* test(codex): avoid shadowing side-question options
@VACInc

VACInc commented Sep 20, 2026

Copy link
Copy Markdown
Member

Related follow-up: #141865 is now merged.

It keeps this PR's host-owned GitHub availability and plugin-work ownership implementation; it does not restore the older duplicate availability helper. Its separate production change preserves the existing operator.write to read/Talk implications during synthetic Gateway dispatch. The merged regression coverage also checks attempt replacement. This is complementary work, not a supersession of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex extensions: copilot gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

2 participants