Repository navigation
[codex] test: assert runtime plan reaches harness attempts - #71197
100yenadmin wants to merge 5 commits into
Conversation
Greptile SummaryThis test-only PR extends Confidence Score: 5/5Safe 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 |
There was a problem hiding this comment.
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
runtimePlanwith 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.
There was a problem hiding this comment.
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
runtimePlanare passed into the embedded attempt call. - Extends Codex plugin-harness tests to assert
runtimePlanforwarding, including Codex auth profile forwarding in both directcodex/*and “openai forced through codex” cases.
There was a problem hiding this comment.
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
runtimePlanare forwarded into the built-in attempt call. - Extends Codex plugin-harness forwarding tests to assert
runtimePlan.resolvedRefand 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()formockedRunEmbeddedAttemptso 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
internalEventsarray 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 andtoBe(internalEvents)) or use a matcher that checks identity.
beforeAll(async () => {
({ runEmbeddedPiAgent } = await loadRunOverflowCompactionHarness());
});
beforeEach(() => {
resetRunOverflowCompactionHarnessMocks();
mockedBuildEmbeddedRunPayloads.mockReturnValue([{ text: "ok" }]);
});
There was a problem hiding this comment.
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 minimalAgentRuntimePlanin 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.resolvedRefand auth-forwarding fields are present on the harness attempt params.
|
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 proves the prepared
AgentRuntimePlanreaches 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.
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
What Changed
AgentRuntimePlanshape.codex/*and forcedopenai/*through Codex harness cases.Maintainer Review Guide
src/agents/pi-embedded-runner/run.overflow-compaction.test.ts.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.tsgit diff --checkLocal broad
pnpm check:changedhas previously hit unrelated repository type/dependency drift; this PR is test-only and the focused forwarding suite is the merge signal.