Skip to content

[codex] test: assert runtime plan reaches harness attempts - #71197

Closed
100yenadmin wants to merge 5 commits into
openclaw:mainfrom
electricsheephq:contract-first/runtime-plan-adoption-cleanup
Closed

100yenadmin wants to merge 5 commits into
openclaw:mainfrom
electricsheephq:contract-first/runtime-plan-adoption-cleanup

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #71096 and RFC #71004. This PR proves the prepared AgentRuntimePlan reaches the hot runner-to-harness seam for both the built-in Pi attempt and plugin harness attempts.

No production runtime behavior changes.

RuntimePlan Package Context

This is the adoption-seam proof in the RuntimePlan package. Before later PRs delete duplicated policy assembly, this PR makes the forwarding contract executable.

flowchart TD
  RFC["#71004 RFC"] --> Base["#71096 RuntimePlan merged"]
  Base --> Contracts["#71196 leaf-safe contracts"]
  Contracts --> This["#71197 plan reaches harness attempts"]
  This --> Observability["#71201 observability coverage"]
  This --> Dedupe["#71220 shared policy helpers"]
  Dedupe --> Harness["#71222/#71238 Harness V2 lifecycle"]
  Dedupe --> Split["#71223 transcript resolver split"]
  Split --> Alias["#71224 embedded-runner alias"]
  Harness --> Outcome["#71239 shared outcome classifier"]
Loading

Review package links: #71196, #71197, #71201, #71220, #71222, #71223, #71224, #71238, #71239.

Why This PR Exists

The next RuntimePlan cleanup PRs are only safe if the prepared plan is already present where Pi and Codex execution cross the harness boundary. Without this proof, removing legacy fallbacks would be another "looks right locally, regresses another path" change.

Local Architecture

sequenceDiagram
  participant Runner as runEmbeddedPiAgent
  participant Plan as buildAgentRuntimePlan
  participant Pi as Built-in Pi attempt
  participant Plugin as Plugin harness attempt

  Runner->>Plan: build prepared OpenClaw policy
  Plan-->>Runner: AgentRuntimePlan
  Runner->>Pi: attempt params include runtimePlan
  Runner->>Plugin: harness params include runtimePlan
Loading

What Changed

  • Extended the forwarding test to assert built-in Pi attempts receive a complete AgentRuntimePlan shape.
  • Extended plugin-harness forwarding tests to assert the same plan reaches Codex/plugin harness attempts.
  • Locked Codex auth forwarding through the RuntimePlan for both direct codex/* and forced openai/* through Codex harness cases.

Maintainer Review Guide

  • Highest-signal file: src/agents/pi-embedded-runner/run.overflow-compaction.test.ts.
  • Check that assertions validate plan identity and shape, not just a loose object fragment.
  • Check call-count assertions preserve the "one attempt" forwarding contract.
  • This is test-only and intentionally does not remove legacy fallback paths yet.

What Did Not Change

Verification

  • ./node_modules/.bin/vitest run src/agents/pi-embedded-runner/run.overflow-compaction.test.ts --config test/vitest/vitest.agents.config.ts
  • ./node_modules/.bin/oxlint --tsconfig tsconfig.oxlint.core.json src/agents/pi-embedded-runner/run.overflow-compaction.test.ts
  • git diff --check

Local broad pnpm check:changed has previously hit unrelated repository type/dependency drift; this PR is test-only and the focused forwarding suite is the merge signal.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Apr 24, 2026
@100yenadmin
100yenadmin marked this pull request as ready for review April 24, 2026 18:59
Copilot AI review requested due to automatic review settings April 24, 2026 18:59
@greptile-apps

greptile-apps Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This test-only PR extends run.attempt-param-forwarding.test.ts to assert that runEmbeddedPiAgent forwards a fully-resolved runtimePlan (with resolvedRef, auth, tools, and transport) into both the built-in Pi attempt and plugin harness attempts, including auth-profile forwarding for Codex and forced-Codex-via-openai cases. No production code is changed.

Confidence Score: 5/5

Safe to merge; test-only change with no production code impact.

All added assertions are structurally consistent with the production buildAgentRuntimePlan/buildAgentRuntimeAuthPlan implementations reviewed. Mock setup in the shared harness correctly seeds the expected field values.

No files require special attention.

Reviews (1): Last reviewed commit: "test: assert runtime plan reaches harnes..." | Re-trigger Greptile

Copilot AI 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.

Pull request overview

This PR strengthens the test contract around the RuntimePlan adoption seam by asserting that runEmbeddedPiAgent forwards a prepared runtimePlan into both the built-in embedded PI attempt path and plugin harness attempts. It fits into the ongoing RuntimePlan hardening ladder by making the “prepared policy is available on the hot path” boundary executable before follow-up cleanup removes legacy fallbacks.

Changes:

  • Extend the attempt param forwarding test to assert the built-in attempt receives a runtimePlan with resolved model identity plus key policy hooks (tool normalization, transport param resolution).
  • Extend Codex plugin harness forwarding tests to assert the harness receives the same runtimePlan, including canonical resolvedRef/auth identity and auth-profile forwarding behavior.

Copilot AI 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.

Pull request overview

This PR strengthens the runEmbeddedPiAgent test harness by asserting that the prepared runtimePlan (and selected optional attempt params) are forwarded into both the built-in attempt path and Codex plugin-harness attempts, helping lock in the RuntimePlan adoption seam for future refactors.

Changes:

  • Adds a new forwarding test that asserts optional attempt params and runtimePlan are passed into the embedded attempt call.
  • Extends Codex plugin-harness tests to assert runtimePlan forwarding, including Codex auth profile forwarding in both direct codex/* and “openai forced through codex” cases.

Copilot AI 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.

Pull request overview

This PR strengthens the test suite around the runEmbeddedPiAgent “runner → attempt/harness” seam by asserting that a prepared runtimePlan (and selected attempt params) is forwarded into both built-in Pi attempts and plugin harness attempts, supporting the ongoing RuntimePlan adoption ladder.

Changes:

  • Adds a new overflow-compaction test asserting optional attempt params and runtimePlan are forwarded into the built-in attempt call.
  • Extends Codex plugin-harness forwarding tests to assert runtimePlan.resolvedRef and auth-forwarding fields reach harness attempts (including “openai/* forced through codex”).
  • Introduces local test helpers/fixtures (forwardingCase, makeForwardedRuntimePlan) to build expected forwarded shapes.
Comments suppressed due to low confidence (2)

src/agents/pi-embedded-runner/run.overflow-compaction.test.ts:163

  • The test name says "into one attempt call", but the assertions only verify that a matching call occurred. Add an explicit toHaveBeenCalledTimes(1)/toHaveBeenCalledOnce() for mockedRunEmbeddedAttempt so regressions that introduce extra attempts aren't masked.
      ...basePlan.auth,
      ...overrides.auth,
    },
    resolvedRef: {
      ...basePlan.resolvedRef,
      ...overrides.resolvedRef,
    },
  };
}

describe("runEmbeddedPiAgent overflow compaction trigger routing", () => {
  beforeAll(async () => {
    ({ runEmbeddedPiAgent } = await loadRunOverflowCompactionHarness());
  });

  beforeEach(() => {
    resetRunOverflowCompactionHarnessMocks();
    mockedBuildEmbeddedRunPayloads.mockReturnValue([{ text: "ok" }]);
  });

  it("passes precomputed legacy before_agent_start result into the attempt", async () => {
    const legacyResult = {
      modelOverride: "legacy-model",
      prependContext: "legacy context",
    };
    mockedGlobalHookRunner.hasHooks.mockImplementation(
      (hookName) => hookName === "before_agent_start",
    );
    mockedGlobalHookRunner.runBeforeAgentStart.mockResolvedValueOnce(legacyResult);

src/agents/pi-embedded-runner/run.overflow-compaction.test.ts:153

  • This assertion doesn't guarantee the provided internalEvents array instance is forwarded: expect.objectContaining({ internalEvents }) uses deep equality, so a different empty array would still satisfy the expectation. If the goal is to lock the forwarding seam, assert reference equality (e.g. inspect the first call arg and toBe(internalEvents)) or use a matcher that checks identity.
  beforeAll(async () => {
    ({ runEmbeddedPiAgent } = await loadRunOverflowCompactionHarness());
  });

  beforeEach(() => {
    resetRunOverflowCompactionHarnessMocks();
    mockedBuildEmbeddedRunPayloads.mockReturnValue([{ text: "ok" }]);
  });

Copilot AI 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.

Pull request overview

Adds additional test assertions around the runEmbeddedPiAgent runner-to-attempt seam to ensure a prepared runtimePlan (and selected optional attempt params) reaches both built-in attempt execution and plugin harness attempts.

Changes:

  • Introduces a typed makeForwardedRuntimePlan() helper for constructing a minimal AgentRuntimePlan in tests.
  • Adds a new forwarding test ensuring optional attempt params and a runtime plan are passed into the embedded attempt call.
  • Extends Codex plugin harness tests to assert runtimePlan.resolvedRef and auth-forwarding fields are present on the harness attempt params.

@100yenadmin 100yenadmin changed the title test: assert runtime plan reaches harness attempts [codex] test: assert runtime plan reaches harness attempts Apr 25, 2026
@100yenadmin

Copy link
Copy Markdown
Contributor Author

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.

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

Labels

agents Agent runtime and tooling size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants