Skip to content

feat: support RLM training over ACP - #2386

Closed
hallerite wants to merge 13 commits into
mainfrom
feat/rlm-acp-contract
Closed

feat: support RLM training over ACP#2386
hallerite wants to merge 13 commits into
mainfrom
feat/rlm-acp-contract

Conversation

@hallerite

@hallerite hallerite commented Aug 17, 2026

Copy link
Copy Markdown
Member

Summary

  • express the RLM runtime as typed harness configuration and send its strict ai.prime.rlm/runtime-v1 payload through ACP session/new
  • carry opaque ACP session/close metadata through the generic runner and let the RLM harness validate its final ai.prime.rlm/session-v1 snapshot into training metrics
  • preserve a canonical root ACP-visible reply independently from concurrently intercepted descendant branches
  • honor standard non-streaming HTTP idempotency by coalescing in-flight retries, replaying bounded completed responses, and namespacing provider keys per rollout
  • run live RLM E2Es directly against merged nano-rlm main

Verifiers does not model RLM lineage, compaction, subagents, or agent-specific ACP lifecycle artifacts. Those semantics stay inside nano-rlm. Verifiers transports standard ACP metadata and records every intercepted parent and descendant model call in the trace graph.

Contract

This intentionally requires the nano-rlm contract merged in PrimeIntellect-ai/nano-rlm#134. No compatibility path or temporary commit pin remains; the harness default and CI both use nano-rlm main.

Validation

  • unpinned deterministic Prime VM E2E against merged nano-rlm main (c27f8ea): 1 passed in 44.89s
  • forces two recursive child requests to be in flight simultaneously
  • asserts three retained trace branches: root, child one, and child two
  • persisted trace: reward 1.0, no errors, five sampled turns, sub_rlm_num_calls = 2, has_sub_rlm = 1
  • asserts the parent resumes after both children and the canonical reply remains the root ACP reply
  • validates MCP resume, kernel environment isolation, and strict terminal training metrics in the same rollout
  • exact Hermes ACP resume/Docker case passes, including its leading presentation-whitespace edge
  • full local Verifiers suite and focused trace, idempotency, and contract checks pass
  • pre-push Markdown, Ruff, format, and Ty checks pass
  • all commits are GitHub signature-verified

Note

Add RLM training support over ACP with session metadata and close metrics

  • RLM harness now passes configuration to ACP via structured session_meta from RLMHarness._runtime_metadata instead of environment variables; prepare_acp only forwards resolved env and RLM_HOME.
  • ACPSession.close now returns a metadata dict from the close-session response, and serve_stream includes it in shutdown responses; ACPHarnessSession._stop records harness metrics on the trace via acp_close_metrics and raises HarnessFinalizationError on shutdown/finalization failures.
  • Trace and Segment gain a primary_reply field; last_reply prefers it so child responses do not leak as the primary reply.
  • Interception server adds explicit Idempotency-Key handling for non-streaming calls: coalesces concurrent attempts, replays cached responses, rejects key reuse with different body/path, and applies TTL/size eviction via _prune_idempotent_requests.
  • Adds HarnessFinalizationError to the public verifier API and new tests for idempotency and the RLM Prime contract.
  • Risk: RLMHarness.summarize_threshold now returns int | None instead of str; any consumer expecting a string threshold will need updating. RLMHarnessConfig adds new policy fields and validation (e.g. max_output disallows 0, max_concurrent_subagents >= max_depth) that may reject previously accepted configs.

Macroscope summarized 762650a.


Note

High Risk
Changes the model interception path (idempotency coalescing) and RLM configuration transport; close-time metric finalization now fails rollouts when artifacts are missing.

Overview
Adds RLM training over ACP by sending typed ai.prime.rlm/runtime-v1 config through ACP session_meta instead of RLM env vars, and reading training metrics from validated session/close metadata (ai.prime.rlm/session-v1) rather than scraping meta.json on disk. RLMHarnessConfig grows policy fields (limits, kernel env, SDK retries, etc.); default nano-rlm ref is main, overridable in E2E via NANO_RLM_E2E_VERSION.

Introduces Trace.primary_reply (and Segment/last_reply behavior) so ACP harnesses can expose the canonical user-visible answer when subagent branches pollute graph leaf order; ACP prompts set it from the session reply.

ACP shutdown now returns close metadata to the host; harnesses implement acp_close_metrics. Failures to finalize required close artifacts raise HarnessFinalizationError and fail the rollout (not best-effort teardown).

The interception server honors non-streaming Idempotency-Key: coalesce in-flight duplicates, replay completed responses with TTL/size bounds, reject key/body mismatches, and rewrite upstream keys per rollout session.

New tests cover idempotency, wire primary_reply, ACP resume primary_reply, and a deterministic Prime VM RLM contract E2E.

Reviewed by Cursor Bugbot for commit 762650a. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread verifiers/v1/harnesses/rlm/harness.py Outdated
@hallerite
hallerite force-pushed the feat/rlm-acp-contract branch from 24a3788 to fc90deb Compare August 17, 2026 17:42
@hallerite
hallerite force-pushed the feat/rlm-acp-contract branch from 6cb8830 to edbe71a Compare August 17, 2026 19:48
@hallerite
hallerite force-pushed the feat/rlm-acp-contract branch from edbe71a to 4ab0bdc Compare August 17, 2026 20:41
Comment thread verifiers/v1/harnesses/rlm/harness.py Outdated
Comment thread verifiers/v1/acp/runner.py Outdated
@hallerite
hallerite changed the base branch from feat/rlm-lineage to main August 18, 2026 21:45
@hallerite
hallerite force-pushed the feat/rlm-acp-contract branch from 3f8ca38 to 4b4b1ac Compare August 18, 2026 22:50
@hallerite hallerite changed the title feat: use the RLM ACP training contract feat: support RLM training over ACP Aug 18, 2026
Comment thread verifiers/v1/acp/runner.py Outdated
@hallerite
hallerite force-pushed the feat/rlm-acp-contract branch 2 times, most recently from eb232a8 to 1b401b7 Compare August 19, 2026 19:23
Comment thread verifiers/v1/interception/server.py
@hallerite
hallerite force-pushed the feat/rlm-acp-contract branch from 1b401b7 to dcadf55 Compare August 19, 2026 21:20
Comment thread verifiers/v1/acp/__init__.py
Comment thread verifiers/v1/interception/server.py Outdated
@hallerite
hallerite force-pushed the feat/rlm-acp-contract branch from dcadf55 to 63aeea1 Compare August 21, 2026 23:34
Comment thread verifiers/v1/interception/server.py Outdated
@hallerite
hallerite marked this pull request as ready for review August 22, 2026 00:20
Comment thread verifiers/v1/acp/runner.py
Comment thread verifiers/v1/acp/__init__.py Outdated
Comment thread verifiers/v1/interception/server.py
@macroscopeapp

macroscopeapp Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR adds substantial RLM-over-ACP functionality while changing shared ACP lifecycle, close-time metric finalization, trace reply semantics, and model interception/idempotency behavior. The cross-process contract and broad runtime effects exceed the scope of a small isolated change and warrant human review.

You can add or adjust custom eligibility rules. Learn more.

Comment thread verifiers/v1/acp/__init__.py Outdated
Comment thread tests/v1/test_idempotency.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e4afc7b. Configure here.

Comment thread verifiers/v1/acp/__init__.py Outdated
@hallerite
hallerite requested a review from mikasenghaas August 24, 2026 20:24
@hallerite
hallerite requested a review from xeophon August 24, 2026 20:30
@hallerite hallerite closed this Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant