Skip to content

[codex] feat: add agent harness v2 lifecycle adapter - #71222

Closed
100yenadmin wants to merge 6 commits into
openclaw:mainfrom
electricsheephq:contract-first/harness-v2-lifecycle-adapter
Closed

100yenadmin wants to merge 6 commits into
openclaw:mainfrom
electricsheephq:contract-first/harness-v2-lifecycle-adapter

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #71096 and RFC #71004. This PR adds the first additive Harness V2 lifecycle contract without migrating selection/execution yet.

No behavior change for existing harnesses.

RuntimePlan Package Context

This is the lifecycle foundation rung. RuntimePlan centralizes OpenClaw-owned policy; Harness V2 gives that policy a lifecycle-shaped execution boundary without redesigning the existing harness registry.

flowchart TD
  RFC["#71004 RFC"] --> Base["#71096 RuntimePlan merged"]
  Base --> Dedupe["#71220 shared policy helper"]
  Dedupe --> This["#71222 additive Harness V2 adapter"]
  This --> Execute["#71238 selected harnesses run through V2"]
  Execute --> Outcome["#71239 shared terminal outcome classifier"]
  Dedupe --> Transcript["#71223 transcript resolver split"]
  Transcript --> Alias["#71224 embedded-runner alias"]
Loading

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

Local Architecture

flowchart LR
  V1["Current AgentHarness\nrunAttempt/compact/reset/dispose"] --> Adapter["adaptAgentHarnessToV2"]
  Adapter --> Prepare["prepare"]
  Prepare --> Start["start/resume"]
  Start --> Send["send"]
  Send --> Outcome["resolveOutcome"]
  Outcome --> Cleanup["cleanup"]
Loading

Why This PR Exists

The existing harness SPI is intentionally small and should not be redesigned. The missing piece is an internal lifecycle boundary where OpenClaw can consistently attach RuntimePlan policy, telemetry, cleanup, and outcome classification. This PR adds that boundary additively and keeps V1 compatibility.

What Changed

  • Added src/agents/harness/v2.ts with an internal lifecycle-shaped harness interface.
  • Added adaptAgentHarnessToV2(...) so existing V1 harnesses can run through the V2 shape.
  • Kept result classification as an explicit resolveOutcome(...) stage.
  • Preserved V1 compact, reset, and dispose compatibility methods.
  • Added focused tests for lifecycle forwarding, classification, hook delegation, and stale-classification handling.

Maintainer Review Guide

  • Highest-signal files: src/agents/harness/v2.ts, src/agents/harness/result-classification.ts, src/agents/harness/v2.test.ts.
  • Check this remains additive: no selection path should change in this PR.
  • Check V1 adapter behavior remains compatible with existing harnesses.
  • Check classification behavior preserves harness-supplied terminal classifications when no explicit classifier exists.

What Did Not Change

Verification

  • ./node_modules/.bin/vitest run src/agents/harness/v2.test.ts --config test/vitest/vitest.agents.config.ts
  • ./node_modules/.bin/oxlint --tsconfig tsconfig.oxlint.core.json src/agents/harness/v2.ts src/agents/harness/result-classification.ts src/agents/harness/v2.test.ts
  • git diff --check
  • pnpm check:architecture

Local broad pnpm check:changed has previously hit unrelated repository type/dependency drift; focused Harness V2 tests and architecture checks are the intended merge signal for this slice.

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

greptile-apps Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces src/agents/harness/v2.ts with a new AgentHarnessV2 interface and an adaptAgentHarnessToV2 adapter that forwards V1 harnesses through the new prepare → start → send → resolveOutcome → cleanup lifecycle shape. No runtime selection or Pi/Codex migration is included. The implementation is clean and additive; prior threads already cover the three open items (identical PreparedRun/Session shapes, ok-branch classification carry-through, and the intentional cleanup no-op).

Confidence Score: 5/5

Safe to merge — purely additive, no existing behavior changed, and all remaining open items are tracked in prior threads at P2 or lower.

No new P0/P1 issues found. All three substantive concerns raised in previous review threads are open P2-level design suggestions. The core adapter logic is correct: delegation to runAttempt is identity-preserving, classification is properly isolated to resolveOutcome, and V1 hooks are faithfully re-exposed. Tests cover the three main code paths.

No files require special attention.

Reviews (2): Last reviewed commit: "feat: add agent harness v2 lifecycle ada..." | Re-trigger Greptile

Comment thread src/agents/harness/v2.ts Resolved
Comment thread src/agents/harness/v2.ts Resolved
Comment thread src/agents/harness/v2.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8bd9244c29

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/harness/v2.ts Resolved

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

Introduces an additive “Harness V2” lifecycle-shaped interface and a compatibility adapter so existing V1 AgentHarness implementations can be exercised through the V2 stages without changing runtime selection or migrating Pi/Codex execution yet.

Changes:

  • Added AgentHarnessV2 contract (prepare/start/resume/send/resolveOutcome/cleanup) plus supporting types.
  • Added adaptAgentHarnessToV2(...) to run existing V1 harnesses through the V2 lifecycle shape, preserving legacy hooks.
  • Added focused Vitest coverage for lifecycle forwarding, explicit outcome classification, and hook delegation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/agents/harness/v2.ts Defines the V2 lifecycle contract and implements the V1→V2 adapter plus classification helper.
src/agents/harness/v2.test.ts Adds tests ensuring adapter forwarding, explicit resolveOutcome classification, and legacy hook preservation.

Comment thread src/agents/harness/v2.ts Resolved
Comment thread src/agents/harness/v2.ts Resolved
@100yenadmin
100yenadmin marked this pull request as ready for review April 24, 2026 19:45

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9eb4585a71

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d61603eb2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@100yenadmin 100yenadmin changed the title feat: add agent harness v2 lifecycle adapter [codex] feat: add agent harness v2 lifecycle adapter 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