Skip to content

feat(v1): run RLM over persistent ACP#2116

Open
hallerite wants to merge 8 commits into
mainfrom
agent/rlm-acp-sidecar
Open

feat(v1): run RLM over persistent ACP#2116
hallerite wants to merge 8 commits into
mainfrom
agent/rlm-acp-sidecar

Conversation

@hallerite

@hallerite hallerite commented Jul 23, 2026

Copy link
Copy Markdown
Member

Keeps ACP agents alive for the duration of a v1 interaction and moves RLM onto its native ACP transport.

RLM now preserves conversation and IPython state across segments, while MCP servers remain model-facing Python skills behind ipython.

Tested with:

  • uv run pytest tests/ — 909 passed, 64 skipped
  • uv run pre-commit run --all-files
  • DeepSeek V4 Flash in a Prime sandbox — two ACP segments, resumed MCP call, reward 1.0, finalized RLM metrics

Note

Run RLM harness over a persistent ACP sidecar per trace

  • The RLM harness now launches an ACP agent (rlm --acp) backed by a long-lived Unix-socket sidecar per trace instead of invoking the CLI in one-shot mode per prompt.
  • _runner.py gains a PersistentSession class and a serve_sidecar Unix-socket server that serializes prompts over a single agent process and session across segments.
  • acp/__init__.py extends ACP.run with a sidecar_path parameter that starts the sidecar on first use, routes subsequent prompts through it, and appends sidecar logs to stderr on failure; ACP.close shuts the sidecar down and removes its state directory.
  • Per-trace RLM_HOME is now stored under .vf-rlm/<trace.id>/home, enabling meta.json metrics (e.g. turns_since_last_compaction) to persist and be read after the sidecar is stopped.
  • Risk: the sidecar process outlives individual prompts; a crash or stale socket requires the cleanup path in RLMHarness.cleanup to recover correctly.

Macroscope summarized 7caf113.


Note

Medium Risk
New long-lived sidecar lifecycle and RLM execution path affect multi-segment rollouts; client disconnect during a prompt tears down the session and can discard in-progress work.

Overview
RLM now runs through rlm-harness on native ACP (rlm --acp) instead of a one-shot CLI invocation. MCP servers are wired through ACP; the old RLM_MCP_CONFIG path is removed. Per-trace state lives under .vf-rlm/{trace.id}/ (RLM_HOME and a private acp.sock sidecar).

The shared ACP layer gains an optional persistent sidecar: probe/start a background serve process, send each segment via request, and close/shutdown with log tailing on failures. _runner.py adds a UNIX-socket server with PersistentSession (one agent process for many prompts), plus once / serve / request / shutdown / probe commands.

E2E adds rlm to ACP resume coverage and asserts RLM compaction metrics on resumed runs. Docs pin the default rlm-harness git ref and describe the ACP + IPython skill model.

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

Comment thread verifiers/v1/acp/__init__.py Outdated
Comment thread verifiers/v1/acp/_runner.py
Comment thread verifiers/v1/acp/__init__.py Outdated
@hallerite
hallerite marked this pull request as ready for review July 23, 2026 17:28
Comment thread verifiers/v1/acp/_runner.py Outdated
Comment thread verifiers/v1/acp/__init__.py Outdated
@macroscopeapp

macroscopeapp Bot commented Jul 23, 2026

Copy link
Copy Markdown

Approvability

Verdict: Needs human review

This PR introduces significant new async/concurrency functionality for persistent ACP sessions. An unresolved high-severity review comment identifies a race condition in the disconnect handling logic where the session may close while an ACP prompt is still unwinding.

You can customize Macroscope's approvability policy. Learn more.

Comment thread verifiers/v1/harnesses/rlm/harness.py
Comment thread verifiers/v1/acp/_runner.py
Comment thread verifiers/v1/acp/_runner.py Outdated
Comment thread verifiers/v1/acp/_runner.py
Comment thread verifiers/v1/acp/_runner.py
Comment thread verifiers/v1/acp/_runner.py Outdated
Comment thread verifiers/v1/acp/__init__.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 7caf113. Configure here.

# consuming tokens without a client.
prompt_task.cancel()
await asyncio.gather(prompt_task, return_exceptions=True)
await stop_session()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Disconnect cancels prompt tracking early

High Severity

On client disconnect, the handler cancels prompt_task (run_prompt) before stop_session. That hits run_prompt's finally, which clears active_prompt without waiting for session.run to finish, so stop_session no longer sees the in-flight prompt and can close the session while the ACP prompt is still unwinding—the race this shutdown path was meant to prevent.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7caf113. Configure here.

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