You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
uv run python -m unittest test/test_create_session.py test/test_subagent_registry.py
Note
Medium Risk
Spawns new daemon sessions with model/auth and supervisor RPC; misconfiguration or partial failure is mitigated by validation and kill-on-error, but session lifecycle and naming still affect multi-agent orchestration.
Overview
Adds rlm.create_session so depth-0, daemon-backed root agents can spin up a separate resident top-level session (a sibling root), not a recursive child via rlm(...).
The coding-agent wires a new kernel host request rlm.create_session to AgentSession.createRlmSession, which validates prompt, optional name / model / thinking / cwd, enforces depth-0 and a host with createRlmRootSession, then delegates to the daemon. The daemon worker talks to the supervisor with create (lifecycle: resident) and prompt, returns session identifiers, and kills the new session if prompting fails.
The Python prime-agent-runtime exposes await rlm.create_session(...) (and on rlm.rlm) returning RLMCreateSessionHandle. Kernel bootstrap now requires callable create_session. Depth-0 RLM system prompts document the API. Shared RLM kwargs normalizers accept an operation label so error messages apply to both rlm.run and rlm.create_session.
Reviewed by Cursor Bugbot for commit 0c9c883. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add rlm.create_session API for daemon-backed root agents to create sibling sessions
Depth-0 daemon-backed agent sessions can now create a separate resident root session with an optional name, model, thinking level, and working directory, and receive its session IDs and file path.
The new rlm.create_session Python API dispatches a host request through the kernel and returns an RLMCreateSessionHandle typed result.
Runtime readiness probes now require callable rlm.create_session on both the top-level RLM module and its callable namespace.
AgentDaemon.createRlmRootSession connects to the supervisor, creates and prompts the resident session, and cleans up partially-created sessions on failure.
Risk: runtimes missing the required rlm.create_session entry points now fail RUNTIME_READY_CHECK in bootstrap.ts; nested, disposed, or inline sessions reject the operation via AgentSession.createRlmSession in agent-session.ts.
rlm.create_session sidesteps the spawn policy that rlm.run enforces. _startRlmChildRun refuses to spawn once _rlmDepth >= _rlmMaxDepth, but createRlmSession (agent-session.ts ~L10796) has no equivalent gate, and the siblings it creates are fresh roots: default rlmMaxDepth 2 plus their own create_session, so an agent with spawning disabled can still grow the session tree without bound. The prompt paragraph advertising create_session (prompts/rlm.ts ~L149) is gated on depth === 0 && hasIpython only, so a spawn-disabled agent is actively told about it. This is a resource guard, not a security boundary — bash can reach the supervisor socket anyway — but the inconsistency is worth closing.
Minimal fix:
reject in createRlmSession when _rlmMaxDepth === 0
createRlmRootSession (daemon-mode.ts ~L2501) sends a hand-built config subset — cwd, agentDir, sessionDir, provider, model, thinking, telemetryDisabled — with no launchEnv and no apiKey. The normal root-create path (main.ts ~L1007) sends the full config plus launchEnv: collectDaemonLaunchEnv(). The model preflight runs in the parent worker against the parent's credentials, but the sibling launches from the supervisor's ambient env, which can be older: after a new PRIME_API_KEY, --api-key, or custom provider env, create_session succeeds and the sibling's first prompt fails auth.
Suggested fix: forward the current worker's filtered launch env and spread runtimeConfig.apiKey into the config, same pattern as the existing sessionDir/telemetryDisabled spreads.
[written by prime-agent, checked by snimu]
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
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
await rlm.create_session(prompt, name=..., cwd=..., model=..., thinking=...)for daemon-backed depth-0 agentscreateandpromptoperationsrlm(...)calls recursive and reject root creation from nested or inline sessionsTest plan
npm run checkenv -u RLM_DEPTH -u RLM_MAX_DEPTH -u RLM_SESSION_DIR npx tsx ../../node_modules/vitest/dist/cli.js --run test/agent-session-recursion.test.ts test/daemon-mode.test.ts test/system-prompt.test.ts test/ipython-bootstrap.test.ts test/kernel-bootstrap.test.tsuv run python -m unittest test/test_create_session.py test/test_subagent_registry.pyNote
Medium Risk
Spawns new daemon sessions with model/auth and supervisor RPC; misconfiguration or partial failure is mitigated by validation and kill-on-error, but session lifecycle and naming still affect multi-agent orchestration.
Overview
Adds
rlm.create_sessionso depth-0, daemon-backed root agents can spin up a separate resident top-level session (a sibling root), not a recursive child viarlm(...).The coding-agent wires a new kernel host request
rlm.create_sessiontoAgentSession.createRlmSession, which validates prompt, optionalname/model/thinking/cwd, enforces depth-0 and a host withcreateRlmRootSession, then delegates to the daemon. The daemon worker talks to the supervisor withcreate(lifecycle: resident) andprompt, returns session identifiers, and kills the new session if prompting fails.The Python
prime-agent-runtimeexposesawait rlm.create_session(...)(and onrlm.rlm) returningRLMCreateSessionHandle. Kernel bootstrap now requires callablecreate_session. Depth-0 RLM system prompts document the API. Shared RLM kwargs normalizers accept anoperationlabel so error messages apply to bothrlm.runandrlm.create_session.Reviewed by Cursor Bugbot for commit 0c9c883. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add
rlm.create_sessionAPI for daemon-backed root agents to create sibling sessionsrlm.create_sessionPython API dispatches a host request through the kernel and returns anRLMCreateSessionHandletyped result.rlm.create_sessionon both the top-level RLM module and its callable namespace.AgentDaemon.createRlmRootSessionconnects to the supervisor, creates and prompts the resident session, and cleans up partially-created sessions on failure.rlm.create_sessionentry points now failRUNTIME_READY_CHECKin bootstrap.ts; nested, disposed, or inline sessions reject the operation viaAgentSession.createRlmSessionin agent-session.ts.Macroscope summarized 0c9c883.