[RFC 005] 2/4: foundation types for agentic harnesses - #1098
Merged
burtenshaw merged 1 commit intoSep 28, 2026
Merged
Conversation
This was referenced Aug 28, 2026
splusq
marked this pull request as ready for review
August 31, 2026 21:22
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Contributor
|
Unable to authenticate your request. Please make sure to connect your GitHub account to Cursor. Go to Cursor |
This was referenced Sep 25, 2026
burtenshaw
approved these changes
Sep 28, 2026
burtenshaw
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. moving on to 3 and 4
Adds the type layer for wrapping an external agentic harness (Claude Code, OpenClaw, Codex) as an OpenEnv environment. No runtime behavior yet — this PR is types plus their unit tests. - `config.py`: `HarnessConfig` / `HarnessTransport`. `session_timeout_s` is documented as bounding ONE conversational turn, per the RFC's temporal-semantics section (the field comment in the RFC is ambiguous; flagging for reviewer sign-off). - `events.py`: `HarnessEventType` / `HarnessEvent` / `HarnessResponse`, plus `events_to_metadata()`, the sanctioned JSON-safe path for putting events into `Observation.metadata` so they survive wire serialization. - `adapter.py`: `AgenticHarnessAdapter` ABC and its error hierarchy. - `tools.py`: `resolve_tool_conflicts()` for the RFC's tool-name collision rules (`env_` prefixing, error on ambiguity). Two deliberate deviations from the RFC text, both because the RFC is stale against the code: 1. The RFC's `ToolDefinition` does not exist; the type is `Tool` (`env_server/mcp_types.py`), reused here rather than duplicated. Same for `RESERVED_TOOL_NAMES`, which `resolve_tool_conflicts` re-checks as defense in depth. 2. `send_message()` is concrete rather than abstract. Streaming is the single abstract turn primitive and `send_message()` drains it, which removes duplication from every concrete adapter and makes the terminal TURN_COMPLETE event an enforced contract instead of a convention. The ABC is named `AgenticHarnessAdapter` to avoid colliding with the rollout layer's existing `HarnessAdapter`. Worth discussing whether to rename the rollout classes instead and reclaim the RFC's plain names -- see the PR description. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
burtenshaw
force-pushed
the
rfc-005/pr2-harness-foundation-types
branch
from
September 28, 2026 09:58
6e07658 to
a1ea5d3
Compare
7 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack for RFC 005 — 2 of 4. Depends on #1097.
Cross-fork PRs cannot chain bases, so this targets
mainand its diff includes #1097. Review the top commit only:01bb0ce.HarnessEnvironment+ subprocess + tool bridge/harnessroute + mode wiringWhat
The type layer for wrapping an external agentic harness (Claude Code, OpenClaw, Codex) as an OpenEnv environment. Types plus unit tests only — nothing runs a harness yet, that is 3/4.
config.pyHarnessConfig,HarnessTransportevents.pyHarnessEventType,HarnessEvent,HarnessResponse,events_to_metadata()adapter.pyAgenticHarnessAdapterABC + error hierarchytools.pyresolve_tool_conflicts()Deviations from the RFC text, and why
The RFC has drifted from the code in a few places. Flagging each rather than silently following either one:
ToolDefinitiondoes not exist. The type isTool(env_server/mcp_types.py,name/description/input_schema). Reused rather than duplicated, soinject_toolstakeslist[Tool]. Same forRESERVED_TOOL_NAMES, whichresolve_tool_conflictsre-checks as defense in depth even thoughMCPEnvironment.__init__already validates.send_message()is concrete, not abstract. Streaming is the single abstract turn primitive;send_message()drains it and pulls the response/doneoff the terminal event. This removes the same boilerplate from every concrete adapter, and turns "the stream ends withTURN_COMPLETE" from a convention into an enforced contract — a stream that ends without it raises rather than silently yielding an empty response.events_to_metadata()is new.Observation.metadatagets serialized over the wire, so raw pydantic events inmetadata["turn_events"]would not survive. This is the one sanctioned way to put events there; 3/4 uses it and asserts the result isjson.dumps-able.Naming
The ABC is
AgenticHarnessAdapterbecauseHarnessAdapteris taken by the rollout layer (see the question at the end of #1097 — if we rename that layer, this becomes plainHarnessAdapter, matching the RFC).Needs a decision:
session_timeout_sThe RFC's field comment says "Max time for a single session/episode" but its temporal-semantics section says it bounds one turn. I implemented and documented the per-turn reading, since an episode-wide bound is not enforceable by an adapter that only sees one turn at a time. Flagging explicitly for sign-off.
Verification
test_agentic_harness_types.pycovers config defaults/validation, event JSON round-trip,events_to_metadataserializability, all sixresolve_tool_conflictsbranches (passthrough,env_prefixing with schema preserved, reserved-name rejection, duplicate rejection, and both ambiguity cases where the prefixed name is also taken), and the defaultsend_messageincluding the missing-TURN_COMPLETEerror. Back-compat and rollout suites still green. Lint clean.Note
Low Risk
New public types and re-exports only; no subprocess, routing, or changes to rollout/collect behavior.
Overview
Adds the RFC 005 type layer for turn-based external agentic harnesses (OpenClaw, Claude Code, etc.) alongside the existing trainer-side rollout API, without running a harness yet.
New modules define
HarnessConfig/HarnessTransport, normalizedHarnessEventstreams andHarnessResponse,AgenticHarnessAdapter(lifecycle, tool injection withlist[Tool], streaming turns) with a concretesend_message()that requires a terminalTURN_COMPLETEevent, harness-specific errors,events_to_metadata()for wire-safe observation metadata, andresolve_tool_conflicts()(prefixenv_, fail on reserved/duplicate/ambiguous names).openenv.core.harnessre-exports these symbols and documents both layers;AgenticHarnessAdapterstays distinct from rolloutHarnessAdapter.Unit tests cover config validation, event serialization, conflict resolution branches, default
send_messagebehavior, and rollout back-compat.Reviewed by Cursor Bugbot for commit a1ea5d3. Bugbot is set up for automated code reviews on this repo. Configure here.