Repository navigation
[codex] refactor: centralize runtime plan tool policy - #71220
100yenadmin wants to merge 4 commits into
Conversation
Greptile SummaryThis PR centralizes the duplicated Confidence Score: 5/5Safe to merge — pure refactor with no behavioral change and passing tests. All findings are P2 or lower. The behavioral equivalence is clear from the diff, the logic is covered by the new tests (three cases), and the Codex diagnostic omission is intentional (no prior call existed). No correctness or security concerns found. No files require special attention. Reviews (2): Last reviewed commit: "refactor: centralize runtime plan tool p..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
Centralizes the RuntimePlan-first tool policy (normalization + diagnostics) behind a shared helper so Pi embedded attempts and the Codex app-server adapter don’t each maintain their own RuntimePlan/legacy fallback branches.
Changes:
- Added
normalizeAgentRuntimeToolsandlogAgentRuntimeToolDiagnosticshelper functions that preferruntimePlan.tools.*when available and fall back to legacy provider schema normalization/diagnostics otherwise. - Updated Pi embedded attempt tool setup and diagnostics logging to use the shared helper.
- Updated Codex app-server dynamic tool building to use the same helper, and re-exported the helper from
plugin-sdk/agent-harness-runtime.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/plugin-sdk/agent-harness-runtime.ts | Re-exports the shared tool-policy helpers for extension consumption. |
| src/agents/runtime-plan/tools.ts | New shared adapter implementing RuntimePlan-first tool normalization + diagnostics with legacy fallback. |
| src/agents/runtime-plan/tools.test.ts | Adds focused unit coverage for RuntimePlan routing vs legacy fallback behavior. |
| src/agents/pi-embedded-runner/run/attempt.ts | Switches embedded attempt tool normalization and diagnostics to the shared helper. |
| extensions/codex/src/app-server/run-attempt.ts | Switches Codex dynamic tool normalization to the shared helper via plugin-sdk runtime surface. |
| const runtimePlanModelContext = { | ||
| workspaceDir: effectiveWorkspace, | ||
| modelApi: params.model.api, | ||
| model: params.model, | ||
| }; |
There was a problem hiding this comment.
runtimePlanModelContext is now unused after switching to normalizeAgentRuntimeTools / logAgentRuntimeToolDiagnostics. It should be removed (or passed into the helper) to avoid unused-local lint/typecheck failures.
|
Superseded by #71722, which consolidates the RuntimePlan/Harness package into one review PR and preserves this PR's commits via cherry-pick -x. Keeping this PR as review/history evidence. |
Summary
Follow-up to #71096 and RFC #71004. This PR centralizes the RuntimePlan-first tool normalization and diagnostics policy into one helper used by both Pi and Codex app-server paths.
Runtime behavior is intended to be equivalent: RuntimePlan wins when present, and the legacy provider-schema fallback remains intact when no plan is available.
RuntimePlan Package Context
This is the first production dedupe rung after the contract and forwarding proofs. It removes duplicate OpenClaw-owned tool-policy reassembly from Pi and Codex without adding new hooks or changing the harness SPI.
Review package links: #71196, #71197, #71201, #71220, #71222, #71223, #71224, #71238, #71239.
Local Architecture
Why This PR Exists
Tool policy was one of the clearest examples of Pi/Codex policy drift: each path knew how to prefer RuntimePlan when present and fall back to legacy normalization, but the branches were duplicated. This PR keeps the behavior but makes the ownership boundary explicit.
What Changed
src/agents/runtime-plan/tools.tsas the shared RuntimePlan-first tool-policy adapter.plan.toolswhen present.plugin-sdk/agent-harness-runtimefor Codex extension consumption.Maintainer Review Guide
src/agents/runtime-plan/tools.ts,src/agents/pi-embedded-runner/run/attempt.ts,extensions/codex/src/app-server/run-attempt.ts.What Did Not Change
Verification
./node_modules/.bin/vitest run src/agents/runtime-plan/tools.test.ts --config test/vitest/vitest.agents.config.ts./node_modules/.bin/vitest run src/agents/pi-embedded-runner/run.attempt-param-forwarding.test.ts --config test/vitest/vitest.agents.config.ts./node_modules/.bin/vitest run extensions/codex/src/app-server/run-attempt.test.ts --config test/vitest/vitest.extensions.config.ts./node_modules/.bin/oxlint --tsconfig tsconfig.oxlint.core.json src/agents/runtime-plan/tools.ts src/agents/runtime-plan/tools.test.ts src/plugin-sdk/agent-harness-runtime.ts extensions/codex/src/app-server/run-attempt.ts src/agents/pi-embedded-runner/run/attempt.tsgit diff --checkpnpm check:architectureLocal broad
pnpm check:changedhas previously hit unrelated repository type/dependency drift; focused RuntimePlan tool-policy checks are the intended merge signal for this slice.