feat: supervise isolated recursive RLM sessions - #134
Open
hallerite wants to merge 21 commits into
Open
Conversation
hallerite
force-pushed
the
feat/runtime-context
branch
from
August 18, 2026 14:11
534fa28 to
254aaff
Compare
snimu
marked this pull request as ready for review
August 21, 2026 14:26
Absorbs #141 (stable conversation log path): build_system_prompt loses messages_path and advertises $RLM_SESSION_DIR/messages.jsonl; engine and prompt tests updated to the merged signature (allow_git + shell_skills kept from this branch).
initialize() now returns ai.prime.rlm/contract-v1 in its response _meta so clients can fail fast on the wrong agent, matching the documented handshake. Rewrite the README ACP section to describe the implemented contract: one authoritative close snapshot (no per-response snapshots or final flag) and Idempotency-Key/x-stainless-retry-count transport headers (no X-RLM-* provenance family). Rename _runtime_config's parameter to meta_kwargs and document that the ACP router spreads session/new._meta into handler kwargs.
Absorbs #143 (markdownlint via pre-commit). The merged markdown already passes the new hook; no re-lint changes were needed.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 108604e. Configure here.
_run_child created the child Session, then awaited the registry lock outside any try/finally. A cancellation in that window (scope close, kernel disconnect, supervisor shutdown) skipped both the session close and the registry rollback, leaking the messages.jsonl handle. Start the try block before the first await and close the session ahead of the finally's own lock acquisition so a second cancellation cannot skip it. The new regression test cancels a child while it waits for the lock and asserts the session log handle is closed and the registry is empty.
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.

Summary
ai.prime.rlm/runtime-v1payload at ACPsession/newand return one authoritativeai.prime.rlm/session-v1snapshot atsession/closekernel_env, so provider, MCP, and search credentials are unavailable to kernel code and its subprocessesIdempotency-Keyfor each actual model call, stable across SDK and outer retries, without exporting training-specific lineage semanticsrlm.run(prompt)returns a typed result while the supervisor owns identity, limits, metrics, and lifecycleContract
This intentionally breaks the earlier environment-variable and draft ACP contracts. There is no compatibility negotiation or fallback: clients must send the strict v1 runtime payload and consume the final v1 close snapshot. PrimeIntellect-ai/verifiers#2386 is the companion client change.
Security boundary
The kernel receives only the explicit task variables granted through
kernel_env; provider, MCP, and search credentials stay in the supervisor. This prevents ambient credential leakage but is not hostile-code containment through a separate OS user or container boundary.Validation
uv run ruff check src testsuv run ruff format --check src testsuv run pytest tests/ -q— 122 passed7a26d3c2cd2f38e11807ef7b88ce4ea197552ea8— passed, covering two ACP prompts, MCP resume, concurrent recursive children, explicit/ambient environment isolation, and final close metricsNote
High Risk
Reworks ACP session lifecycle, credential handling, and recursive execution. Breaking contract plus kernel isolation and broker RPC make this security- and training-critical.
Overview
Moves recursive
rlm()calls, MCP, and credentialedsearchout of the IPython kernel into a session-tree supervisor. The kernel talks over a local framed broker using opaque capabilities; MCP URLs/headers/env andSERPER_API_KEYare no longer copied into kernel env or session artifacts.ACP is now a strict versioned contract, not env-var fallback.
initializeadvertisesai.prime.rlm/contract-v1;session/newmust send a completeruntime-v1object (model, provider, policy, skills, kernel env, search key).session/closereturns a credential-freesession-v1snapshot. Close/cancel/delivery are joinable and shielded.Standalone CLI/Python still resolve
RuntimeConfigfrom env (RLM_KERNEL_ENV, concurrency/call limits, tool-output window). Kernels start from a small platform env plus explicit task vars. Each model call gets a stableIdempotency-Key(retries usex-stainless-retry-count); those header names are reserved.rlm.run(prompt)is the public recursive surface.Reviewed by Cursor Bugbot for commit 9f67cd7. Bugbot is set up for automated code reviews on this repo. Configure here.