Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RUST-BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ancestry with merge commits; never rebase or squash the integration history.
| Headless exit follows the answer | `crates/pa-cli/src/headless_exit.rs`, `crates/pa-core/src/kernel/bootstrap/venv/subprocess.rs`, `KernelPrewarm` in `crates/pa-core/src/session_engine/engine.rs` | Upstream's print runtime started the kernel bootstrap in the background and dropped its Tokio runtime implicitly, which waits without bound for the bootstrap's blocking `uv`/interpreter children: a fresh home's first one-shot exited 43 s after its answer. Print/json now set the kernel environment up before the first turn (`KernelPrewarm::BeforeFirstTurn`), run every setup child as an owned, cancellable tokio child, abandon the kernel boot after the last output and shut the runtime down within 300 ms; the hosted client's detach waits the same budget. `--verbose` traces the exit phases. Resident sessions keep `KernelPrewarm::Background`. Either mode runs only when the Python REPL tool (`python_repl`, with `ipython`/`python` selection aliases) is active after the launch tool selection (`--tools`/`--no-tools`/`--no-builtin-tools`). |
| `--tools`/`--no-tools`/`--no-builtin-tools` honoured (kept against upstream #3211, `a3700282c`, which deletes them) | `crates/pa-core/src/session_engine/tool_selection.rs`, `crates/pa-core/src/prompts/no_repl.rs`, `crates/pa-core/src/session_engine/engine.rs`, `crates/pa-types/src/daemon/tool_selection.rs`, `crates/pa-cli/src/{args,mode,prompt_command}.rs`, the daemon create/summary/headless client, `crates/pa-tui/src/interactive.rs` | Upstream parsed the flags but always added the Python tool (`python_repl`, `ipython` before the rename) and the harness prompt; `sol` and the factory pass `--no-tools` for plain calls. TS semantics: an explicit list wins over both disable flags, then `--no-tools`, then `--no-builtin-tools`. A session with no active tools sends no tool definitions; any session without `python_repl` prepares no kernel environment, starts no kernel and gets the TS no-tools prompt byte for byte (`crates/pa-core/tests/golden/corpus/no-tools-prompt-ts.txt`). Daemon wire: introduced in fork schema revision 31 and carried in the combined revision 33 (fork-only id), capability `session_tool_selection`, create keys `tools`/`noTools`/`noBuiltinTools` (durable for respawns, and kept with the session policy in the per-session record, so a passivated session wakes, a session moved onto by `new_session`/fork keeps, and an RLM child inherits the selection; a record without the keys reads as the defaults), summary `toolSelection`. A merge that includes #3211 must keep the flags, their help rows and this implementation. |
| Unknown model ids on a models.json provider resolve as custom models (#32) | `build_fallback_model` in `crates/pa-core/src/models/resolver.rs` | TS sends any `--model` id to a provider defined in models.json; the port's fallback returned `None` for every provider without a compiled-in default (every models.json provider: cpa, cpa-r, cpa-a), so CPA's per-login prefix routing (`--provider cpa-r --model antevon/gpt-6.1-sol`, the proxy strips the prefix upstream) failed with `Model ... not found`. The fallback template is the provider's own entry for the id behind one routing prefix (only the first path segment is a prefix: `antevon/openai/gpt-4o` keeps its namespace), else the provider's first model; a provider with a compiled-in default keeps that template (TS parity). Resolver tests cover the boundaries. An upstream merge must keep this. |
| Helper model for spawned agents | `crates/pa-core/src/session_engine/helper_model.rs`, `resolve_helper` in `crates/pa-daemon/src/rlm_child_model.rs`, `crates/pa-daemon/src/rlm_children/host.rs`, `crates/pa-cli/src/print_rlm.rs`, `crates/pa-daemon/src/rlm_surface.rs`, `crates/pa-tui/src/session_ui/settings.rs`, `docs/oneiron/HELPER-MODEL.md` | Upstream runs a spawned agent on its parent's model unless the call names one, and never reads its own `subagentDefaultModel` (TS read it, and failed the spawn on an unavailable default). The fork resolves each field in order: the spawn call, the session override (`--subagent-model`/`--subagent-thinking`, `PRIME_SUBAGENT_MODEL`/`PRIME_SUBAGENT_THINKING`, TUI `/subagent-model`), the settings file (`subagentDefaultModel` plus the fork's `subagentDefaultThinking`), the parent. An unknown default warns once and falls back to the parent's model (a TS divergence, by ruling); a default level clamps to the model. The override rides RLM child creates (`subagentModel`/`subagentThinking`) and persists as a `subagent_model_state` session row. Daemon wire: capability `subagent_model`, commands `get_subagent_model_status`/`set_subagent_model` (no schema bump). The spawn and create-session handles add `thinking`. `/settings` gains "Helper model" and "Helper thinking". An upstream merge must keep all of it. |
| Helper model for spawned agents | `crates/pa-core/src/session_engine/helper_model.rs`, `resolve_helper` in `crates/pa-daemon/src/rlm_child_model.rs`, `crates/pa-daemon/src/rlm_children/host.rs`, `crates/pa-cli/src/print_rlm.rs`, `crates/pa-daemon/src/rlm_surface.rs`, `crates/pa-tui/src/session_ui/settings.rs`, `docs/oneiron/HELPER-MODEL.md` | Upstream runs a spawned agent on its parent's model unless the call names one, and never reads its own `subagentDefaultModel` (TS read it, and failed the spawn on an unavailable default). The fork resolves each field in order: the spawn call, the session override (`--subagent-model`/`--subagent-thinking`, `PRIME_SUBAGENT_MODEL`/`PRIME_SUBAGENT_THINKING`, TUI `/subagent-model`), the settings file (`subagentDefaultModel` plus the fork's `subagentDefaultThinking`), the parent. An unknown default warns once and falls back to the parent's model (a TS divergence, by ruling); a default level clamps to the model. The override rides RLM child creates (`subagentModel`/`subagentThinking`) and persists as a `subagent_model_state` session row. Daemon wire: capability `subagent_model`, commands `get_subagent_model_status`/`set_subagent_model` (no schema bump). The spawn and create-session handles add `thinking`. `/settings` gains "Helper model" and "Helper thinking". The helper model list (`subagentModels`, global settings only) limits what spawned agents may run on: a spawn call naming a model off it is refused with the allowed models named, a settings default or parent model off it falls to its first entry, and a person's choice (the session override, or `--subagent-models`/`PRIME_SUBAGENT_MODELS`/TUI `/subagent-models`) is allowed; `rlm.find_models` lists only its models (`RlmSubagentHost::helper_model_list`), and `set_subagent_models` sits behind the capability `subagent_models`. An upstream merge must keep all of it. |
| Side-by-side install + probe | `scripts/oneiron/side_by_side.py` | Installs a staged release beside the TS build and writes receipts. |
| Release feed, rollout, rollback, status | `scripts/oneiron/release_feed.py`, `rollout.py`, `daemon_idle.py` (subcommands of `side_by_side.py`), `docs/oneiron/RELEASE.md`, `docs/oneiron/ROLLBACK.md` | Stamps a `package_release.py` build into a versioned feed release (`feed/releases/v<ver>/`), rolls it out with verified sums, a probe before selection and an idle-only Rust daemon check, and rolls back to the previous install; every step writes a receipt. `crates/pa-core/tests/oneiron_feed_manifest.rs` checks the feed manifest against the native updater's parser. |
| Test-policy gate | `scripts/check-test-policy.mjs` (from the TS fork), `scripts/oneiron/test_policy_gate.py` | Runs the fork's test policy with `TEST_POLICY_BASE=oneiron/main` and fails only on violations beyond the reviewed upstream baseline (`scripts/oneiron/test-policy-baseline.txt`): 4 original entries plus 8 occurrences in 3 byte-identical upstream tests at the 2026-10-24 sync. |
Expand Down
9 changes: 7 additions & 2 deletions crates/pa-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ process). A child that names no model or thinking level runs on the helper
model (fork-only, `docs/oneiron/HELPER-MODEL.md`): the invocation's
`--subagent-model`/`--subagent-thinking` (else `PRIME_SUBAGENT_MODEL`/
`PRIME_SUBAGENT_THINKING`), then the settings file's
`subagentDefaultModel`/`subagentDefaultThinking`, then the parent's.
`subagentDefaultModel`/`subagentDefaultThinking`, then the parent's. The
helper model list (`subagentModels`, widened for the run by
`--subagent-models`/`PRIME_SUBAGENT_MODELS`) refuses a spawn naming a model
off it, moves a default off it to its first entry, and limits
`rlm.find_models` (the inline host's `helper_model_list`).
`--daemon-hosted` and the interactive launch set the same override on their
session (`set_subagent_model`, behind the `subagent_model` capability).
session (`set_subagent_model`/`set_subagent_models`, behind the
`subagent_model`/`subagent_models` capabilities).
Session slash commands (`print_session_command.rs`, the #253 residue): print
prompts that are `/compact`, `/refine`, `/goal`, or `/autonomous` execute
through the pa-core session-command executor (the daemon worker's seam — no
Expand Down
13 changes: 13 additions & 0 deletions crates/pa-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ pub struct Args {
pub subagent_model: Option<String>,
/// `--subagent-thinking`: this session's helper thinking level (a level or `parent`).
pub subagent_thinking: Option<String>,
/// `--subagent-models a,b`: this session's additions to the helper model list.
pub subagent_models: Option<Vec<String>>,
pub continue_: bool,
/// `true` when `--resume` was given without a selector.
pub resume_bare: bool,
Expand Down Expand Up @@ -368,6 +370,11 @@ pub fn parse_args(args: &[String]) -> Args {
}
}
"--subagent-model" => result.subagent_model = Some(require_value!(arg)),
"--subagent-models" => {
result.subagent_models = Some(
pa_core::session_engine::helper_model::parse_model_list(&require_value!(arg)),
);
}
"--subagent-thinking" => {
let level = require_value!(arg);
if level == pa_core::session_engine::helper_model::INHERIT_PARENT
Expand Down Expand Up @@ -645,6 +652,10 @@ mod tests {
let expected = Args {
subagent_model: Some("cpa-r/deepseek-flash-1017".to_string()),
subagent_thinking: Some("max".to_string()),
subagent_models: Some(vec![
"cpa-a/claude-opus-5".to_string(),
"cpa-a/gpt-6".to_string(),
]),
print: true,
messages: vec!["hi".to_string()],
..Args::default()
Expand All @@ -657,6 +668,8 @@ mod tests {
"cpa-r/deepseek-flash-1017",
"--subagent-thinking",
"max",
"--subagent-models",
"cpa-a/claude-opus-5, cpa-a/gpt-6",
"-p",
"hi"
])
Expand Down
7 changes: 7 additions & 0 deletions crates/pa-cli/src/client_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use std::sync::Arc;

use pa_tui::client_settings::ClientSettings;

#[cfg(all(test, unix))]
mod helper_launch_tests;

/// The seam handle the interactive run carries.
#[derive(Clone)]
pub struct CliClientSettings {
Expand Down Expand Up @@ -114,6 +117,10 @@ impl ClientSettings for CliClientSettings {
self.manager().get_subagent_default_thinking()
}

fn subagent_models(&self) -> Option<Vec<String>> {
self.manager().get_subagent_models()
}

fn set_subagent_default_thinking(&self, level: Option<&str>) -> Result<()> {
if let Some(level) =
level.filter(|level| pa_types::ai::thinking_level_from_str(level).is_none())
Expand Down
134 changes: 134 additions & 0 deletions crates/pa-cli/src/client_settings/helper_launch_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
//! Launch overrides still reach a daemon that supports helper defaults but not helper lists.
use std::io::{BufRead, BufReader, Write};
use std::os::unix::net::UnixListener;
use std::path::PathBuf;

use pa_tui::interactive::{
run_interactive, HeadlessPlan, InteractiveOptions, ModelSelection, SessionSelection, UiMode,
};
use serde_json::{json, Value};

fn options(socket: PathBuf) -> InteractiveOptions {
InteractiveOptions {
tool_selection: pa_types::daemon::ToolSelectionFlags::default(),
models: None,
socket_path: socket,
cwd: PathBuf::from("/tmp"),
session_dir: None,
script_path: None,
model_selection: ModelSelection::default(),
model_catalog: Vec::new(),
model_configured_providers: std::collections::HashSet::default(),
model_recent_models: Vec::new(),
default_thinking_level: None,
no_session: false,
session: SessionSelection::New,
restore_dock_focus: false,
initial_message: None,
show_images: true,
fullscreen_mouse: true,
theme: "prime".to_string(),
code_block_indent: " ".to_string(),
tree_filter_mode: String::new(),
branch_summary_skip_prompt: false,
version: "0.0.0".to_string(),
onboarding: None,
telemetry_disabled: None,
client_auth: None,
traces: None,
provider_auth: None,
update_commands: None,
telemetry: None,
keybindings: pa_tui::keybindings::KeybindingsManager::new(),
session_rlm_depth: None,
prompt_stash: std::sync::Arc::default(),
session_has_children: false,
client_settings: None,
}
}

#[test]
fn helper_launch_override_survives_an_old_daemon_with_a_settings_list() {
let dir = tempfile::tempdir().unwrap();
let socket = dir.path().join("tui.sock");
let listener = UnixListener::bind(&socket).unwrap();
let server = std::thread::spawn(move || {
let (stream, _) = listener.accept().unwrap();
let mut writer = stream.try_clone().unwrap();
let mut reader = BufReader::new(stream);
let hello = json!({
"type": "daemon_hello",
"protocol": {"name": "prime-agent.daemon", "version": 7},
"serverCapabilities": ["subagent_model"],
"clientId": "mock",
});
writeln!(writer, "{hello}").unwrap();
let mut overrides = Vec::new();
let mut line = String::new();
while reader.read_line(&mut line).unwrap() != 0 {
if line.trim().is_empty() {
line.clear();
continue;
}
let envelope: Value = serde_json::from_str(line.trim()).unwrap();
line.clear();
let command = &envelope["command"];
let kind = command["type"].as_str().unwrap();
let data = match kind {
"create" => json!({"activeSessionId": "s1", "sessionId": "saved"}),
"attach" => json!({
"activeSessionId": "s1",
"snapshot": {"state": {"sessionId": "saved"}, "messages": []},
}),
"set_subagent_model" => {
overrides.push(command.clone());
json!({"model": command["model"], "modelSource": "session", "thinking": command["thinking"], "thinkingSource": "session"})
}
_ => json!({}),
};
let response = json!({"type": "response", "id": envelope["id"], "command": kind, "success": true, "data": data});
if writeln!(writer, "{response}").is_err() {
break;
}
}
overrides
});
std::fs::write(
dir.path().join("settings.json"),
json!({"subagentModels": ["test-provider/listed"]}).to_string(),
)
.unwrap();
let mut options = options(socket);
options.client_settings = Some(super::CliClientSettings::new(
dir.path().to_path_buf(),
dir.path().to_path_buf(),
));
options.model_selection.subagent_model = Some("test-provider/chosen".to_string());
options.model_selection.subagent_thinking = Some("max".to_string());
let runtime = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap();
let outcome = runtime
.block_on(run_interactive(
options,
UiMode::Headless(HeadlessPlan {
steps: Vec::new(),
width: 160,
height: 40,
}),
))
.unwrap();
let overrides = server.join().unwrap();
assert_eq!(
overrides,
vec![json!({
"type": "set_subagent_model", "activeSessionId": "s1",
"model": "test-provider/chosen", "thinking": "max",
})]
);
assert!(outcome
.frames
.join("\n")
.contains("does not enforce subagentModels"));
}
4 changes: 4 additions & 0 deletions crates/pa-cli/src/command_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ const TOP_LEVEL_OPTION_GROUPS: &[OptionGroup] = &[
"--subagent-thinking <level>",
"Set this session's reasoning for spawned agents (or parent)",
),
(
"--subagent-models <ids>",
"Add models spawned agents may run on, this session (comma-separated)",
),
],
},
OptionGroup {
Expand Down
3 changes: 2 additions & 1 deletion crates/pa-cli/src/global_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::collections::HashSet;

/// Global flags that consume the next argument as their value.
pub const GLOBAL_VALUE_FLAGS: [&str; 27] = [
pub const GLOBAL_VALUE_FLAGS: [&str; 28] = [
"--mode",
"--json-event-profile",
"--daemon-socket",
Expand All @@ -21,6 +21,7 @@ pub const GLOBAL_VALUE_FLAGS: [&str; 27] = [
"--thinking",
"--subagent-model",
"--subagent-thinking",
"--subagent-models",
"--skill",
"--prompt-template",
"--theme",
Expand Down
7 changes: 7 additions & 0 deletions crates/pa-cli/src/hosted_print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ async fn hosted_print_main(options: &RunOptions) -> Result<i32, String> {
no_skills: config.no_skills,
},
subagent_override: config.subagent_override.clone(),
enforce_helper_model_list:
pa_core::session_engine::helper_model::HelperDefaults::load_settings(
&cwd,
&config.agent_dir,
)
.models
.is_some(),
})
.await
.map_err(|error| format!("{error:#}"))?;
Expand Down
4 changes: 3 additions & 1 deletion crates/pa-cli/src/interactive_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,10 @@ async fn run_agents_view_flow(
notice: Option<String>,
) -> Result<()> {
// The launch helper-model override belongs to the session the launch opened; a session
// opened from the view keeps its own (`/subagent-model` changes it there).
// opened from the view keeps its own (`/subagent-model`/`/subagent-models` change it there).
base.model_selection.subagent_model = None;
base.model_selection.subagent_thinking = None;
base.model_selection.subagent_models = None;
let mut anchor = anchor;
// Every view run reuses the roster connection (a chat run hands it
// back), so a switch back from a chat skips the handshake.
Expand Down Expand Up @@ -496,6 +497,7 @@ fn build_tui_options(
// The launch helper-model override, set on the opened session.
subagent_model: config.subagent_override.model.clone(),
subagent_thinking: config.subagent_override.thinking.clone(),
subagent_models: config.subagent_override.models.clone(),
},
// The raw `--models` patterns ride the create config (the daemon
// owns the resolution).
Expand Down
Loading