Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

rename the model's tool from ipython to python_repl (#3400)

Sebastian Müller3e0893260eef
diff --git a/AGENTS.md b/AGENTS.md
index 338b635f67..90efbf8717 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -174,7 +174,7 @@ EXPLICIT EXCEPTION: wire-protocol identifiers that must stay byte-compatible wit
## Surface contract (must not change)
-- Tools exposed to the model: `bash`, `edit`, `ipython` (internal helpers: `rename`, `stdout`).
+- Tools exposed to the model: `bash`, `edit`, `python_repl` (internal helpers: `rename`, `stdout`).
- RLM kernel API in the persistent Python REPL: `rlm.spawn/find_models/collect/list_subagents/delete_subagent/create_session/progress_note`, `rlm.harness` CRUD, `agent_message.send`, `agent_observe`, `compact`, `goal`, `refine`, `attach_image`, skills (markdown + Python) per the skill contract in the base system prompt.
- System prompt structure: layered — cache-stable static layer files (core harness description with the full API surface, mandatory usage rules, opinionated guidelines, per-model additions from the model-prompts TOML rule map) followed by one dynamic tail (packages, project context, skills inventory, MCP servers, environment, session role); the harness digest stays a separate `[harness-digest]` user message. `prime-agent prompt` dumps the assembled prompt with its layer breakdown.
- CLI shape: `prime-agent` with the same commands/flags as the TS product; headless modes (RPC/daemon/session-worker) with identical behavior.
diff --git a/crates/pa-agent/src/agent_loop/tool_call.rs b/crates/pa-agent/src/agent_loop/tool_call.rs
index 771086e1f7..13ec058a29 100644
--- a/crates/pa-agent/src/agent_loop/tool_call.rs
+++ b/crates/pa-agent/src/agent_loop/tool_call.rs
@@ -12,7 +12,7 @@ use crate::types::{
use super::abort::race_with_abort;
use super::run::clone_context;
-use super::tools::{FinalizedToolCallOutcome, Preparation, PreparedToolCall};
+use super::tools::{find_tool, FinalizedToolCallOutcome, Preparation, PreparedToolCall};
use super::{AgentEventSink, AgentLoopConfig};
/// Tool lookup, `prepareArguments`, schema validation, and the
@@ -25,11 +25,7 @@ pub(crate) async fn prepare_tool_call(
config: &AgentLoopConfig,
signal: Option<&AbortSignal>,
) -> Preparation {
- let Some(tool) = current_context
- .tools
- .iter()
- .find(|t| t.name() == tool_call.name)
- else {
+ let Some(tool) = find_tool(&current_context.tools, &tool_call.name) else {
return Preparation::Immediate {
result: AgentToolResult::error(format!("Tool {} not found", tool_call.name)),
is_error: true,
diff --git a/crates/pa-agent/src/agent_loop/tools.rs b/crates/pa-agent/src/agent_loop/tools.rs
index 21aac406e7..09036e188a 100644
--- a/crates/pa-agent/src/agent_loop/tools.rs
+++ b/crates/pa-agent/src/agent_loop/tools.rs
@@ -28,6 +28,17 @@ pub(crate) struct FinalizedToolCallOutcome {
pub(crate) is_error: bool,
}
+/// Tool lookup by name; exact matches win over alias-based dispatch.
+pub(crate) fn find_tool<'a>(
+ tools: &'a [Arc<dyn AgentTool>],
+ name: &str,
+) -> Option<&'a Arc<dyn AgentTool>> {
+ if let Some(tool) = tools.iter().find(|t| t.name() == name) {
+ return Some(tool);
+ }
+ tools.iter().find(|t| t.accepts_alias(name))
+}
+
pub(crate) async fn execute_tool_calls(
current_context: &AgentContext,
assistant_message: &AssistantMessage,
@@ -41,11 +52,7 @@ pub(crate) async fn execute_tool_calls(
.cloned()
.collect::<Vec<ToolCall>>();
let has_sequential_tool_call = tool_calls.iter().any(|tc| {
- current_context
- .tools
- .iter()
- .find(|t| t.name() == tc.name)
- .and_then(|tool| tool.execution_mode())
+ find_tool(&current_context.tools, &tc.name).and_then(|tool| tool.execution_mode())
== Some(ToolExecutionMode::Sequential)
});
if config.tool_execution == ToolExecutionMode::Sequential || has_sequential_tool_call {
diff --git a/crates/pa-agent/src/types.rs b/crates/pa-agent/src/types.rs
index 8a2dc52459..bd7d06f925 100644
--- a/crates/pa-agent/src/types.rs
+++ b/crates/pa-agent/src/types.rs
@@ -500,6 +500,12 @@ pub trait AgentTool: Send + Sync {
fn prepare_arguments(&self, _args: &serde_json::Value) -> Option<serde_json::Value> {
None
}
+ /// Whether a call naming another tool should dispatch to this one
+ /// (e.g. pre-rename names replayed from history); exact name matches
+ /// win.
+ fn accepts_alias(&self, _name: &str) -> bool {
+ false
+ }
/// Execute the tool call. Return `Err` on failure instead of encoding
/// errors in `content`, like a `throw` in the TS reference.
fn execute(
diff --git a/crates/pa-cli/src/print_runtime.rs b/crates/pa-cli/src/print_runtime.rs
index 6bad142b0a..47cafe8801 100644
--- a/crates/pa-cli/src/print_runtime.rs
+++ b/crates/pa-cli/src/print_runtime.rs
@@ -1176,7 +1176,7 @@ pub(crate) fn render_selector_error(error: &SessionSelectorError) -> String {
)
}
-/// Model tools for the print runtime: `ipython` only — the engine adds the kernel-backed tool
+/// Model tools for the print runtime: `python_repl` only — the engine adds the kernel-backed tool
/// itself.
fn builtin_tools(_cwd: &std::path::Path) -> Vec<Arc<dyn pa_agent::types::AgentTool>> {
Vec::new()
diff --git a/crates/pa-cli/src/prompt_command.rs b/crates/pa-cli/src/prompt_command.rs
index 3a5bf2ecaa..8ad8e0f8d2 100644
--- a/crates/pa-cli/src/prompt_command.rs
+++ b/crates/pa-cli/src/prompt_command.rs
@@ -126,9 +126,9 @@ fn assemble_breakdown(
.map(|file| (file.path.display().to_string(), file.content.clone()))
.collect(),
skills: resources.skills.clone(),
- // The shipped model-tool surface: `ipython` only; bash/edit are kernel-resident
+ // The shipped model-tool surface: `python_repl` only; bash/edit are kernel-resident
// programmatic tools.
- selected_tools: Some(vec!["ipython"]),
+ selected_tools: Some(vec![pa_types::ai::PYTHON_TOOL_NAME]),
allow_recursion: Some(true),
generic_mcp_servers: generic_servers,
rlm_depth: Some(0),
diff --git a/crates/pa-cli/tests/acp_mode_e2e.rs b/crates/pa-cli/tests/acp_mode_e2e.rs
index 41ffaddc05..a08dadff65 100644
--- a/crates/pa-cli/tests/acp_mode_e2e.rs
+++ b/crates/pa-cli/tests/acp_mode_e2e.rs
@@ -2193,7 +2193,7 @@ fn spawn_parent_script(spawn_cell: &str) -> Value {
"engine": "faux",
"responses": [
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": { "code": spawn_cell } },
+ { "type": "toolCall", "name": "python_repl", "arguments": { "code": spawn_cell } },
] },
{ "text": "spawn turn done" },
{ "text": "notice seen" },
diff --git a/crates/pa-cli/tests/export_live_differential.rs b/crates/pa-cli/tests/export_live_differential.rs
index 55ba27b094..cc41840e02 100644
--- a/crates/pa-cli/tests/export_live_differential.rs
+++ b/crates/pa-cli/tests/export_live_differential.rs
@@ -423,23 +423,24 @@ fn differential_live_export_matches_ts_binary() {
assert_prefix(&ts_data, "ts");
assert_prefix(&rs_data, "rust");
- // The tools section: the session's registered tool contract, equal in
- // both products (TS `state.tools` vs the Rust engine registry).
- assert_eq!(ts_data["tools"], rs_data["tools"], "tools section");
- let ipython_registered = ts_data["tools"]
- .as_array()
- .expect("tools array")
- .iter()
- .any(|tool| {
- tool["name"] == "ipython"
- && tool["description"].is_string()
- && tool["parameters"].is_object()
- });
- assert!(
- ipython_registered,
- "ipython contract in tools: {}",
- ts_data["tools"]
- );
+ // The Rust tool was intentionally renamed; the TS reference still
+ // advertises ipython. Assert each surface before normalizing only that
+ // name so description/schema differences still fail the comparison.
+ let ts_tools = ts_data["tools"].as_array().expect("TS tools array");
+ let rs_tools = rs_data["tools"].as_array().expect("Rust tools array");
+ assert!(ts_tools.iter().any(|tool| tool["name"] == "ipython"));
+ assert!(rs_tools.iter().any(|tool| {
+ tool["name"] == "python_repl"
+ && tool["description"].is_string()
+ && tool["parameters"].is_object()
+ }));
+ let mut normalized_ts_tools = ts_tools.clone();
+ for tool in &mut normalized_ts_tools {
+ if tool["name"] == "ipython" {
+ tool["name"] = json!("python_repl");
+ }
+ }
+ assert_eq!(&normalized_ts_tools, rs_tools, "tools section");
// The custom-tool call has no renderer in either product: the section
// is omitted (not null), so the template's generic fallback applies
diff --git a/crates/pa-cli/tests/export_share_e2e.rs b/crates/pa-cli/tests/export_share_e2e.rs
index 3988a7406c..d37c7b25a8 100644
--- a/crates/pa-cli/tests/export_share_e2e.rs
+++ b/crates/pa-cli/tests/export_share_e2e.rs
@@ -351,10 +351,10 @@ async fn tui_export_and_share_surface() {
// `state.tools` in the live-session export).
let tools = data["tools"].as_array().expect("tools section");
assert!(
- tools.iter().any(|tool| tool["name"] == "ipython"
+ tools.iter().any(|tool| tool["name"] == "python_repl"
&& tool["description"].is_string()
&& tool["parameters"].is_object()),
- "ipython contract in export tools: {data}"
+ "python_repl contract in export tools: {data}"
);
// No custom tool ran: the pre-render section is omitted, not null.
assert!(
diff --git a/crates/pa-cli/tests/packaged_layout_e2e.rs b/crates/pa-cli/tests/packaged_layout_e2e.rs
index 89aba70b7a..7433730dc6 100644
--- a/crates/pa-cli/tests/packaged_layout_e2e.rs
+++ b/crates/pa-cli/tests/packaged_layout_e2e.rs
@@ -213,7 +213,7 @@ fn kernel_boot_script(receipt: &Path) -> serde_json::Value {
);
serde_json::json!({
"responses": [
- { "content": [ { "type": "toolCall", "name": "ipython", "arguments": {
+ { "content": [ { "type": "toolCall", "name": "python_repl", "arguments": {
"code": cell,
} } ] },
// The next assistant message echoes the request's system
diff --git a/crates/pa-core/README.md b/crates/pa-core/README.md
index 13287a8af7..9c437c2c38 100644
--- a/crates/pa-core/README.md
+++ b/crates/pa-core/README.md
@@ -13,7 +13,7 @@ server, token refresh; `login.rs`: login execution that persists the
endpoint-bound credential into the shared auth store and the
`wire_begin_login`/`McpOAuth` refresh integration hosts wire). The MCP
protocol itself runs kernel-side (Python
-stdio/HTTP); the engine never spawns MCP servers. Tools (bash, edit, ipython + internal rename/stdout), file mutation queue, truncation and rendering rules, RLM kernel lifecycle (IPython spawn/execute/revive), skills loading, system prompt assembly, compaction, harness refinement, settings/config, package manager (npm/git/local source install/remove/list/update against settings), session manager (persist/resume). Autonomous mode
+stdio/HTTP); the engine never spawns MCP servers. Tools (bash, edit, python_repl + internal rename/stdout), file mutation queue, truncation and rendering rules, RLM kernel lifecycle (IPython spawn/execute/revive), skills loading, system prompt assembly, compaction, harness refinement, settings/config, package manager (npm/git/local source install/remove/list/update against settings), session manager (persist/resume). Autonomous mode
(`autonomous`): runtime state with limit normalization, continuation and
gate-failure texts, shell quality gates with retry windows and git
worktree snapshotting, and the `AutonomousDriver` policy trait a turn
@@ -23,7 +23,7 @@ logic of its own). The RLM recursion host seam
`rlm.create_session`/`rlm.list_subagents`/`rlm.collect`/
`rlm.delete_subagent` host requests call into, with the roster/collect/
selector-error vocabulary the daemon implements over the supervisor link.
-Platform wall (`platform`): process control (signals/process groups, kernel exit waits), file locking, file permissions, and shell selection - every OS-specific behavior in the engine lives there behind cfg-gated implementations (the durable-write rename primitive is pa-telemetry's `rename_onto`, re-exported as `platform::rename_onto`). Scheduled jobs (`cron`, the `AgentCronJobStore` port of `core/cron-jobs.ts`): file-backed job state under session artifacts (`scheduled-jobs.json` partitions) with cross-process locking, plus the public read-only scan (`cron::store::read_scheduled_jobs_artifact`) the update flow's roster projection and boot re-arm read. Tools (bash, edit, ipython + internal rename/stdout), file mutation queue, truncation and rendering rules, RLM kernel lifecycle (IPython spawn/execute/revive), skills loading, system prompt assembly, compaction, harness refinement, settings/config, package manager (npm/git/local source install/remove/list/update against settings, plus `resolve()`: precedence-ranked session resource resolution over configured packages, settings arrays, auto-discovery, and bundled skills), session manager (persist/resume). origin/main
+Platform wall (`platform`): process control (signals/process groups, kernel exit waits), file locking, file permissions, and shell selection - every OS-specific behavior in the engine lives there behind cfg-gated implementations (the durable-write rename primitive is pa-telemetry's `rename_onto`, re-exported as `platform::rename_onto`). Scheduled jobs (`cron`, the `AgentCronJobStore` port of `core/cron-jobs.ts`): file-backed job state under session artifacts (`scheduled-jobs.json` partitions) with cross-process locking, plus the public read-only scan (`cron::store::read_scheduled_jobs_artifact`) the update flow's roster projection and boot re-arm read. Tools (bash, edit, python_repl + internal rename/stdout), file mutation queue, truncation and rendering rules, RLM kernel lifecycle (IPython spawn/execute/revive), skills loading, system prompt assembly, compaction, harness refinement, settings/config, package manager (npm/git/local source install/remove/list/update against settings, plus `resolve()`: precedence-ranked session resource resolution over configured packages, settings arrays, auto-discovery, and bundled skills), session manager (persist/resume). origin/main
Provider resilience policies in `session_engine`: the shared quick-retry
policy (TS `provider-retry.ts`: permanent-kind classification,
diff --git a/crates/pa-core/src/prompts/layers/core.md b/crates/pa-core/src/prompts/layers/core.md
index 5efc0b5a66..d9d371d27e 100644
--- a/crates/pa-core/src/prompts/layers/core.md
+++ b/crates/pa-core/src/prompts/layers/core.md
@@ -1,12 +1,12 @@
# prime-agent harness
-The prime-agent harness has one tool: `ipython`, a persistent CPython REPL. All other tools are "programmatic tools", functions inside the Python REPL called via "programmatic tool calling" (PTC). All programmatic tools are async unless described otherwise and can be run in the background. `await` works directly and globally in the REPL.
+The prime-agent harness has one tool: `python_repl`, a persistent CPython REPL. All other tools are "programmatic tools", functions inside the Python REPL called via "programmatic tool calling" (PTC). All programmatic tools are async unless described otherwise and can be run in the background. `await` works directly and globally in the REPL.
The harness often sends messages to the agent. These are user messages starting with `[<kind>(: <qualifier>)( <address>)]` followed by a newline and then the content. They are not user-generated.
## Core tools
-- `bash(command: str) -> BashHandle`: synchronous, returns immediately and runs the command in the background; when a command is finished outside the calling `ipython` block, a notification is sent to the agent; each `bash()` call is its own process, so shell state does not persist between calls
+- `bash(command: str) -> BashHandle`: synchronous, returns immediately and runs the command in the background; when a command is finished outside the calling `python_repl` block, a notification is sent to the agent; each `bash()` call is its own process, so shell state does not persist between calls
- `BashHandle`:
- `.pid: int`
- `.running: bool`
diff --git a/crates/pa-core/src/prompts/layers/usage.md b/crates/pa-core/src/prompts/layers/usage.md
index f9a4270dc1..8273651870 100644
--- a/crates/pa-core/src/prompts/layers/usage.md
+++ b/crates/pa-core/src/prompts/layers/usage.md
@@ -5,7 +5,7 @@ The following are mandatory rules, only to be overridden by clear user intent.
- Goals must only be created at a user's request.
- Agents run shell commands with `bash()`, not `subprocess`/`os.system`: subprocess calls block the kernel, show the user nothing while they run, and spawn processes the harness cannot see or stop.
- `bash("""...""")` should be used over `bash("...")` because it makes using quotation marks inside bash easy.
-- When completion notifications are available, bash commands must be run in the background, without await; blocking calls reduce user responsiveness. Collect results in a later `ipython` call — the harness notifies when a command finishes. Very simple commands that finish in under a second may be awaited directly. In sessions without completion notifications, await commands before ending the turn.
+- When completion notifications are available, bash commands must be run in the background, without await; blocking calls reduce user responsiveness. Collect results in a later `python_repl` call — the harness notifies when a command finishes. Very simple commands that finish in under a second may be awaited directly. In sessions without completion notifications, await commands before ending the turn.
- Shell state does not persist between calls, but agents can use `os.chdir(...)` for the working directory and `os.environ[...]` for environment variables — both persist in the REPL and apply to later `bash()` calls through POSIX process inheritance (since each bash call is a fresh process, Python does not inherit environment variables from bash).
- Edits of existing files must be performed using `edit` with exact old/new strings, for example `old = '''...'''; new = '''...'''; await edit(path="pkg/file.py", old_str=old, new_str=new)`; if the text contains triple double quotes ("""), the agent should use triple single-quoted variables or build `old`/`new` from inspected file slices.
- Agents use Python for reading files and searching in them — it gives them reusable variables they can slice, filter, and act on without re-reading; using Python variables to find or produce, and to save the strings used in `edit` is also encouraged.
diff --git a/crates/pa-core/src/prompts/system_prompt.rs b/crates/pa-core/src/prompts/system_prompt.rs
index a07e4e53ca..9af9e8cd6f 100644
--- a/crates/pa-core/src/prompts/system_prompt.rs
+++ b/crates/pa-core/src/prompts/system_prompt.rs
@@ -150,8 +150,8 @@ pub fn system_prompt_breakdown(options: &BuildSystemPromptOptions) -> SystemProm
let tools: Vec<&str> = options
.selected_tools
.clone()
- .unwrap_or_else(|| vec!["ipython"]);
- let has_ipython = tools.contains(&"ipython");
+ .unwrap_or_else(|| vec![pa_types::ai::PYTHON_TOOL_NAME]);
+ let has_ipython = tools.contains(&pa_types::ai::PYTHON_TOOL_NAME);
let has_file_access = has_ipython || tools.contains(&"bash");
segments.push(PromptSegment::dynamic_segment(
@@ -312,7 +312,7 @@ fn session_role_section(options: &BuildSystemPromptOptions, has_ipython: bool) -
}
if !has_ipython {
lines.push(
- "This session has no Python REPL (`ipython` tool): the programmatic tools described above are unavailable here."
+ "This session has no Python REPL (`python_repl` tool): the programmatic tools described above are unavailable here."
.to_string(),
);
}
diff --git a/crates/pa-core/src/session_engine/compaction_utils.rs b/crates/pa-core/src/session_engine/compaction_utils.rs
index 83cf356c7f..1964614c8d 100644
--- a/crates/pa-core/src/session_engine/compaction_utils.rs
+++ b/crates/pa-core/src/session_engine/compaction_utils.rs
@@ -38,7 +38,7 @@ const TOOL_RESULT_TAIL_CHARS: usize = 500;
pub fn extract_file_ops_from_message(message: &AgentMessage, file_ops: &mut FileOperations) {
match message {
AgentMessage::ToolResult(result) => {
- if result.tool_name != "ipython" {
+ if !pa_types::ai::is_python_tool_name(&result.tool_name) {
return;
}
let Some(details) = result.details.as_ref().and_then(|d| d.as_object()) else {
@@ -367,7 +367,7 @@ mod tests {
ops.read.insert("/tmp/other.rs".to_string());
let result = AgentMessage::ToolResult(pa_types::ai::ToolResultMessage {
tool_call_id: "c".to_string(),
- tool_name: "ipython".to_string(),
+ tool_name: "python_repl".to_string(),
content: vec![],
details: Some(serde_json::json!({
"diffs": [{ "path": "/pkg/lib.rs", "oldStr": "a", "newStr": "b" }]
diff --git a/crates/pa-core/src/session_engine/engine.rs b/crates/pa-core/src/session_engine/engine.rs
index ffcae34ba1..515d51bb89 100644
--- a/crates/pa-core/src/session_engine/engine.rs
+++ b/crates/pa-core/src/session_engine/engine.rs
@@ -8,6 +8,7 @@ use std::sync::Arc;
use pa_agent::agent::{Agent, AgentInitialState, AgentOptions};
use pa_agent::stream::StreamFn;
use pa_agent::types::{Model, ThinkingLevel};
+use pa_types::ai::PYTHON_TOOL_NAME;
use crate::resources::{load_resources, ResourceLoaderOptions};
use crate::session::manager::SessionManager;
@@ -430,7 +431,7 @@ pub async fn create_session(mut config: SessionEngineConfig) -> anyhow::Result<S
on_bootstrap_result,
);
let mut tools = config.tools.clone();
- if !tools.iter().any(|tool| tool.name() == "ipython") {
+ if !tools.iter().any(|tool| tool.name() == PYTHON_TOOL_NAME) {
let definition = crate::tools::ipython::create_ipython_tool_definition(
&cwd.to_string_lossy(),
super::runtime_wiring::ipython_tool_options(
@@ -449,7 +450,9 @@ pub async fn create_session(mut config: SessionEngineConfig) -> anyhow::Result<S
let prewarm_configured =
config.prewarm_ipython_kernel.unwrap_or(false) && config.rlm_depth.unwrap_or(0) == 0;
if (prewarm_configured || has_snapshot)
- && active_tool_names.iter().any(|name| name == "ipython")
+ && active_tool_names
+ .iter()
+ .any(|name| name == PYTHON_TOOL_NAME)
{
provisioner.prewarm();
// The MCP settle rides the same background posture (the
@@ -549,7 +552,9 @@ pub async fn create_session(mut config: SessionEngineConfig) -> anyhow::Result<S
let digest_context = super::harness_digest::HarnessDigestContext {
global_dir: crate::refinement::get_global_harness_state_dir(&config.agent_dir),
local_dir: local_harness_dir,
- include_ipython: active_tool_names.iter().any(|name| name == "ipython"),
+ include_ipython: active_tool_names
+ .iter()
+ .any(|name| name == PYTHON_TOOL_NAME),
include_shell_examples: active_tool_names.iter().any(|name| name == "bash"),
include_refine: resources.skills.iter().any(|skill| {
!skill.disable_model_invocation
diff --git a/crates/pa-core/src/session_engine/engine/tests.rs b/crates/pa-core/src/session_engine/engine/tests.rs
index 46ee099831..93e5a4787c 100644
--- a/crates/pa-core/src/session_engine/engine/tests.rs
+++ b/crates/pa-core/src/session_engine/engine/tests.rs
@@ -366,7 +366,7 @@ async fn create_session_registers_goal_and_heartbeat_handlers() {
.map(|tool| tool.name().to_string())
.collect();
assert!(
- names.iter().any(|name| name == "ipython"),
+ names.iter().any(|name| name == "python_repl"),
"tools: {names:?}"
);
}
diff --git a/crates/pa-core/src/session_engine/side_question.rs b/crates/pa-core/src/session_engine/side_question.rs
index 5a5d1cf241..e95edcc58e 100644
--- a/crates/pa-core/src/session_engine/side_question.rs
+++ b/crates/pa-core/src/session_engine/side_question.rs
@@ -25,7 +25,7 @@ use super::provider_retry::{
/// Returning `false` requests the run to abort.
pub type SideQuestionSink = Arc<dyn Fn(&str) -> bool + Send + Sync>;
-const SIDE_QUESTION_INSTRUCTION: &str = "The user asked this via `/btw` — a temporary side thread cloned from the main conversation to answer a question without interrupting the main work. Tools (including `ipython`) are deactivated in this side thread and return an error if called; answer using only the conversation context above. The user may send follow-up side questions. Nothing here is added to the main session, so don't start or plan main-session work from this thread.";
+const SIDE_QUESTION_INSTRUCTION: &str = "The user asked this via `/btw` — a temporary side thread cloned from the main conversation to answer a question without interrupting the main work. Tools (including `python_repl`) are deactivated in this side thread and return an error if called; answer using only the conversation context above. The user may send follow-up side questions. Nothing here is added to the main session, so don't start or plan main-session work from this thread.";
const SIDE_QUESTION_TOOL_BLOCKED: &str =
"Tools are deactivated in this side thread. Answer from the conversation context.";
diff --git a/crates/pa-core/src/session_engine/tests.rs b/crates/pa-core/src/session_engine/tests.rs
index 16722dc56d..520fcac9f6 100644
--- a/crates/pa-core/src/session_engine/tests.rs
+++ b/crates/pa-core/src/session_engine/tests.rs
@@ -826,6 +826,88 @@ async fn prompt_persists_tool_results() {
assert!(entry["timestamp"].as_str().is_some());
}
+/// Persisted `ipython`/`python` calls dispatch through `ToolDefinitionBridge`
+/// to the registered Python tool.
+#[tokio::test]
+async fn python_tool_aliases_dispatch_to_python_repl() {
+ let calls = Arc::new(std::sync::atomic::AtomicUsize::new(0));
+ let definition = crate::tools::tool_definition::ToolDefinition {
+ name: pa_types::ai::PYTHON_TOOL_NAME.to_string(),
+ label: "Python".to_string(),
+ description: "Echoes its input".to_string(),
+ prompt_snippet: String::new(),
+ parameters: serde_json::json!({ "type": "object" }),
+ execution_mode: None,
+ prepare_arguments: None,
+ execute: {
+ let calls = Arc::clone(&calls);
+ Arc::new(move |_id, params, _signal, _on_update| {
+ let text = params
+ .get("text")
+ .and_then(|t| t.as_str())
+ .unwrap_or_default()
+ .to_string();
+ calls.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
+ Box::pin(async move {
+ Ok(crate::tools::tool_definition::ToolExecutionResult::text(
+ format!("echo:{text}"),
+ ))
+ })
+ })
+ },
+ };
+ let provider = Arc::new(ScriptedProvider::new(test_model()));
+ provider.push_tool_call_turn(
+ Some("calling"),
+ vec![
+ ("call-1", "ipython", serde_json::json!({ "text": "a" })),
+ ("call-2", "python", serde_json::json!({ "text": "b" })),
+ ],
+ );
+ provider.push_text_turn("done");
+ let options = AgentOptions {
+ initial_state: AgentInitialState {
+ model: Some(test_model()),
+ ..Default::default()
+ },
+ stream_fn: Some(provider.stream_fn()),
+ ..Default::default()
+ };
+ let agent = Agent::new(options);
+ agent
+ .set_tools(vec![crate::session_engine::tool_bridge::bridge_tool(
+ definition,
+ )])
+ .await;
+ let tmp = tempfile::tempdir().unwrap();
+ let session = SessionManager::in_memory(tmp.path());
+ let engine = AgentSession::new(Arc::new(agent), session, vec![])
+ .await
+ .unwrap();
+ engine.prompt("go", PromptOptions::default()).await.unwrap();
+ engine.agent().wait_for_idle().await;
+ assert_eq!(calls.load(std::sync::atomic::Ordering::SeqCst), 2);
+ let entries = engine.entries().await;
+ let texts: Vec<&str> = entries
+ .iter()
+ .filter_map(|entry| match entry {
+ FileEntry::Message {
+ message: SessionAgentMessage::ToolResult(result),
+ ..
+ } => Some(result),
+ _ => None,
+ })
+ .map(|result| {
+ assert!(!result.is_error, "result: {result:?}");
+ match &result.content[..] {
+ [pa_types::ai::UserContentBlock::Text(text)] => text.text.as_str(),
+ _ => panic!("expected a single text block: {result:?}"),
+ }
+ })
+ .collect();
+ assert_eq!(texts, ["echo:a", "echo:b"]);
+}
+
/// A `toolResult` entry captured from a live TS session (read-only, from
/// the installed product's own session store) parses into the Rust
/// session types and re-serializes to the identical wire shape.
diff --git a/crates/pa-core/src/session_engine/tool_bridge.rs b/crates/pa-core/src/session_engine/tool_bridge.rs
index 1c2df3436f..86059bef6b 100644
--- a/crates/pa-core/src/session_engine/tool_bridge.rs
+++ b/crates/pa-core/src/session_engine/tool_bridge.rs
@@ -9,6 +9,7 @@ use pa_agent::types::{
AgentTool, AgentToolResult, AgentToolUpdateCallback,
ToolExecutionMode as LoopToolExecutionMode, ToolResultContent,
};
+use pa_types::ai::{is_python_tool_name, PYTHON_TOOL_NAME};
use crate::tools::tool_definition::{ExecutionMode, ToolDefinition, ToolExecutionResult};
@@ -68,6 +69,10 @@ impl AgentTool for ToolDefinitionBridge {
.map(|prepare| prepare(args.clone()))
}
+ fn accepts_alias(&self, name: &str) -> bool {
+ self.definition.name == PYTHON_TOOL_NAME && is_python_tool_name(name)
+ }
+
fn execute(
self: Arc<Self>,
tool_call_id: String,
diff --git a/crates/pa-core/src/skills/mod.rs b/crates/pa-core/src/skills/mod.rs
index 100d91ca3f..2b155f969f 100644
--- a/crates/pa-core/src/skills/mod.rs
+++ b/crates/pa-core/src/skills/mod.rs
@@ -216,7 +216,7 @@ pub fn format_skills_for_prompt(skills: &[Skill]) -> String {
}
let mut lines = vec![
"\n\nThe following skills provide specialized instructions for specific tasks.".to_string(),
- "Use ipython to inspect a skill's file when the task matches its description.".to_string(),
+ "Use python_repl to inspect a skill's file when the task matches its description.".to_string(),
"Skills with a python_import are prepared in the persistent Python kernel when available and can be called directly by that import name.".to_string(),
"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.".to_string(),
String::new(),
diff --git a/crates/pa-core/src/tools/ipython.rs b/crates/pa-core/src/tools/ipython.rs
index bc98eb9620..727a89645c 100644
--- a/crates/pa-core/src/tools/ipython.rs
+++ b/crates/pa-core/src/tools/ipython.rs
@@ -485,7 +485,7 @@ pub async fn execute_ipython(
})
}
-/// The `ipython` tool definition: exact name, schema, and description.
+/// The `python_repl` tool definition: exact name, schema, and description.
#[must_use]
pub fn create_ipython_tool_definition(_cwd: &str, options: IpythonToolOptions) -> ToolDefinition {
let options = Arc::new(options);
@@ -504,7 +504,7 @@ pub fn create_ipython_tool_definition(_cwd: &str, options: IpythonToolOptions) -
let code = params
.get("code")
.and_then(serde_json::Value::as_str)
- .ok_or_else(|| anyhow::anyhow!("ipython tool requires a code string"))?
+ .ok_or_else(|| anyhow::anyhow!("python_repl tool requires a code string"))?
.to_string();
execute_ipython(
&options,
@@ -518,11 +518,12 @@ pub fn create_ipython_tool_definition(_cwd: &str, options: IpythonToolOptions) -
})
};
ToolDefinition {
- name: "ipython".to_string(),
- label: "ipython".to_string(),
+ name: pa_types::ai::PYTHON_TOOL_NAME.to_string(),
+ label: pa_types::ai::PYTHON_TOOL_NAME.to_string(),
description: ipython_tool_description().to_string(),
prompt_snippet:
- "ipython - persistent Python REPL for code, state, and bash() orchestration".to_string(),
+ "python_repl - persistent Python REPL for code, state, and bash() orchestration"
+ .to_string(),
// The kernel is single-threaded; calls must not run in parallel.
execution_mode: Some(ExecutionMode::Sequential),
parameters: ipython_tool_schema(),
diff --git a/crates/pa-core/src/tools/tool_definition.rs b/crates/pa-core/src/tools/tool_definition.rs
index d684483556..79e708f8be 100644
--- a/crates/pa-core/src/tools/tool_definition.rs
+++ b/crates/pa-core/src/tools/tool_definition.rs
@@ -108,7 +108,7 @@ impl ToolDefinition {
#[must_use]
pub fn replay_built_in_tool_name(&self) -> Option<&str> {
match self.name.as_str() {
- "bash" | "edit" | "ipython" => Some(self.name.as_str()),
+ "bash" | "edit" | pa_types::ai::PYTHON_TOOL_NAME => Some(self.name.as_str()),
_ => None,
}
}
diff --git a/crates/pa-core/tests/abort_kernel_cell.rs b/crates/pa-core/tests/abort_kernel_cell.rs
index 6be04a4b8c..bc88e4d95e 100644
--- a/crates/pa-core/tests/abort_kernel_cell.rs
+++ b/crates/pa-core/tests/abort_kernel_cell.rs
@@ -134,7 +134,7 @@ async fn abort_during_a_kernel_cell_settles_the_turn_immediately() {
Some("running the wedge cell"),
vec![(
"call-1",
- "ipython",
+ "python_repl",
json!({ "code": wedge_cell(&started, &finished) }),
)],
);
diff --git a/crates/pa-core/tests/golden/corpus/schema.json b/crates/pa-core/tests/golden/corpus/schema.json
index 83e568f55e..1fdec91953 100644
--- a/crates/pa-core/tests/golden/corpus/schema.json
+++ b/crates/pa-core/tests/golden/corpus/schema.json
@@ -74,10 +74,10 @@
},
{
"tool": "ipython",
- "name": "ipython",
- "label": "ipython",
+ "name": "python_repl",
+ "label": "python_repl",
"description": "Execute Python code in a persistent Python REPL. Top-level `await` is supported. Variables, imports, and loaded data persist across calls, and are revived on a best-effort basis when a session is resumed (objects that cannot be serialized are dropped and reported). Run shell commands with `bash('cmd')` / `await bash('cmd')`. Project imports, tests, scripts, CLIs, and dependency checks should run through the target project's own environment.",
- "promptSnippet": "ipython - persistent Python REPL for code, state, and bash() orchestration",
+ "promptSnippet": "python_repl - persistent Python REPL for code, state, and bash() orchestration",
"executionMode": "sequential",
"parameters": {
"type": "object",
diff --git a/crates/pa-core/tests/kernel_mcp_settle.rs b/crates/pa-core/tests/kernel_mcp_settle.rs
index 102fe781e9..c6b0c4fedc 100644
--- a/crates/pa-core/tests/kernel_mcp_settle.rs
+++ b/crates/pa-core/tests/kernel_mcp_settle.rs
@@ -170,7 +170,7 @@ async fn a_kernel_needing_op_mid_boot_joins_the_in_flight_build_and_succeeds() {
Some("calling the kernel"),
vec![(
"cell-1",
- "ipython",
+ "python_repl",
json!({ "code": "print('JOINED_BOOT_OK')" }),
)],
)));
@@ -454,7 +454,11 @@ async fn the_first_python_cell_never_waits_behind_the_eager_mcp_status() {
provider.push_turn(ScriptedTurn::Events(tool_call_turn_steps(
&model,
Some("running the cell"),
- vec![("cell-1", "ipython", json!({ "code": "print('CELL_OK')" }))],
+ vec![(
+ "cell-1",
+ "python_repl",
+ json!({ "code": "print('CELL_OK')" }),
+ )],
)));
provider.push_text_turn("the turn settles");
diff --git a/crates/pa-core/tests/kernel_prewarm.rs b/crates/pa-core/tests/kernel_prewarm.rs
index 063df56b16..9cf79139ee 100644
--- a/crates/pa-core/tests/kernel_prewarm.rs
+++ b/crates/pa-core/tests/kernel_prewarm.rs
@@ -278,8 +278,8 @@ async fn subagent_sessions_stay_lazy_despite_the_prewarm_flag() {
.map(|tool| tool.name().to_string())
.collect();
assert!(
- tool_names.iter().any(|name| name == "ipython"),
- "the subagent keeps the lazy ipython tool: {tool_names:?}"
+ tool_names.iter().any(|name| name == "python_repl"),
+ "the subagent keeps the lazy python_repl tool: {tool_names:?}"
);
// Long enough for a wrongly-fired prewarm to boot and report; the lazy session reports nothing.
diff --git a/crates/pa-core/tests/kernel_snapshot_resume.rs b/crates/pa-core/tests/kernel_snapshot_resume.rs
index d32392ddd3..cf60e51687 100644
--- a/crates/pa-core/tests/kernel_snapshot_resume.rs
+++ b/crates/pa-core/tests/kernel_snapshot_resume.rs
@@ -91,7 +91,7 @@ fn ipython_tool_call_step(call_id: &str, code: &str) -> FauxResponseStep {
vec![pa_types::ai::AssistantContentBlock::ToolCall(
pa_types::ai::ToolCall {
id: call_id.to_string(),
- name: "ipython".to_string(),
+ name: "python_repl".to_string(),
arguments: serde_json::json!({ "code": code })
.as_object()
.cloned()
diff --git a/crates/pa-core/tests/prompt_guards.rs b/crates/pa-core/tests/prompt_guards.rs
index 0a9654cfc2..8e6eb8c980 100644
--- a/crates/pa-core/tests/prompt_guards.rs
+++ b/crates/pa-core/tests/prompt_guards.rs
@@ -83,7 +83,7 @@ fn cached_prefix_is_stable_across_sessions() {
messages_path: Some("/first/session.jsonl".to_string()),
model_prompt_extras: Some("model guidance."),
skills: sorted_bundled_skills(),
- selected_tools: Some(vec!["ipython"]),
+ selected_tools: Some(vec!["python_repl"]),
..Default::default()
};
let first = system_prompt_breakdown(&options);
@@ -552,7 +552,7 @@ fn generic_mcp_skill_renders_in_the_prompt_inventory() {
cwd: "/w".to_string(),
messages_path: Some("/log.jsonl".to_string()),
skills: sorted_bundled_skills(),
- selected_tools: Some(vec!["ipython"]),
+ selected_tools: Some(vec!["python_repl"]),
..Default::default()
};
let breakdown = system_prompt_breakdown(&options);
diff --git a/crates/pa-core/tests/turn_boundary_kernel.rs b/crates/pa-core/tests/turn_boundary_kernel.rs
index 0a885ae2ab..46d8a2d5a9 100644
--- a/crates/pa-core/tests/turn_boundary_kernel.rs
+++ b/crates/pa-core/tests/turn_boundary_kernel.rs
@@ -153,7 +153,7 @@ async fn turn_boundary_host_requests_round_trip_through_a_real_kernel() {
Some("running the harness cell"),
vec![(
"call-1",
- "ipython",
+ "python_repl",
json!({ "code": harness_cell(&receipt_path) }),
)],
);
diff --git a/crates/pa-daemon/src/acp/types.rs b/crates/pa-daemon/src/acp/types.rs
index 0b641bd4e5..25e92aa624 100644
--- a/crates/pa-daemon/src/acp/types.rs
+++ b/crates/pa-daemon/src/acp/types.rs
@@ -85,7 +85,8 @@ impl AcpToolKind {
/// secondary escape hatch.
pub fn of_tool(tool_name: &str) -> AcpToolKind {
match tool_name {
- "ipython" | "bash" => AcpToolKind::Execute,
+ name if pa_types::ai::is_python_tool_name(name) => AcpToolKind::Execute,
+ "bash" => AcpToolKind::Execute,
"read" => AcpToolKind::Read,
"edit" | "write" => AcpToolKind::Edit,
_ => AcpToolKind::Other,
@@ -432,7 +433,7 @@ mod tests {
#[test]
fn tool_kind_map_matches_the_ts_map() {
- assert_eq!(AcpToolKind::of_tool("ipython"), AcpToolKind::Execute);
+ assert_eq!(AcpToolKind::of_tool("python_repl"), AcpToolKind::Execute);
assert_eq!(AcpToolKind::of_tool("bash"), AcpToolKind::Execute);
assert_eq!(AcpToolKind::of_tool("read"), AcpToolKind::Read);
assert_eq!(AcpToolKind::of_tool("edit"), AcpToolKind::Edit);
diff --git a/crates/pa-daemon/src/acp/wire_events.rs b/crates/pa-daemon/src/acp/wire_events.rs
index b246b94686..855bd36d91 100644
--- a/crates/pa-daemon/src/acp/wire_events.rs
+++ b/crates/pa-daemon/src/acp/wire_events.rs
@@ -13,9 +13,6 @@ use serde_json::{json, Value};
use super::meta::{prime_agent_meta, PrimeAgentCompactionMeta, PrimeAgentSessionMeta};
use super::types::{AcpSessionUpdate, AcpToolKind, AcpToolStatus, TextBlock};
-/// The model-facing Python REPL tool.
-const IPYTHON_TOOL_NAME: &str = "ipython";
-
/// Correlates streamed chunks with their owning assistant message (the
/// daemon stream carries the delta on `assistantMessageEvent`) and bash
/// output chunks with the run that produced them.
@@ -142,12 +139,12 @@ pub fn wire_updates(event: &Value, state: &mut WireMappingState) -> Vec<AcpSessi
.unwrap_or_default()
.to_string();
let args = event.get("args").cloned().unwrap_or(Value::Null);
- let cell = if tool_name == IPYTHON_TOOL_NAME {
+ let cell = if pa_types::ai::is_python_tool_name(&tool_name) {
args.get("code").and_then(Value::as_str).map(str::to_string)
} else {
None
};
- let title = if tool_name == IPYTHON_TOOL_NAME {
+ let title = if pa_types::ai::is_python_tool_name(&tool_name) {
"Python cell".to_string()
} else {
tool_name.clone()
diff --git a/crates/pa-daemon/src/agent_engine/lifecycle.rs b/crates/pa-daemon/src/agent_engine/lifecycle.rs
index 02ad5de033..60012575cc 100644
--- a/crates/pa-daemon/src/agent_engine/lifecycle.rs
+++ b/crates/pa-daemon/src/agent_engine/lifecycle.rs
@@ -975,7 +975,7 @@ impl AgentSessionEngine {
model: Some(agent_model),
thinking_level: Some(map_thinking_level(self.effective_thinking())),
stream_fn: Some(stream_fn),
- // Model tools: `ipython` only; the engine adds the kernel-backed `ipython` tool itself.
+ // Model tools: `python_repl` only; the engine adds the kernel-backed `python_repl` tool itself.
tools: vec![],
custom_system_prompt: create_resources.system_prompt,
prompt_guidelines: create_resources.append_system_prompt,
diff --git a/crates/pa-daemon/src/agent_engine/tests/abort.rs b/crates/pa-daemon/src/agent_engine/tests/abort.rs
index 6036adfe76..7539e6484d 100644
--- a/crates/pa-daemon/src/agent_engine/tests/abort.rs
+++ b/crates/pa-daemon/src/agent_engine/tests/abort.rs
@@ -551,7 +551,7 @@ fn abort_in_flight_turn_cancels_a_running_kernel_cell() {
"responses": [
{"content": [
{"type": "text", "text": "Running the wedge cell."},
- {"type": "toolCall", "name": "ipython", "id": "toolu_wedge01",
+ {"type": "toolCall", "name": "python_repl", "id": "toolu_wedge01",
"arguments": {"code":
"import time\nopen('wedge-started', 'w').write('1')\ntime.sleep(300)\nopen('wedge-finished', 'w').write('1')\nprint('cell completed')"}}
]},
diff --git a/crates/pa-daemon/src/worker/tests/goal_tests.rs b/crates/pa-daemon/src/worker/tests/goal_tests.rs
index 7f3aa22c80..fd39faf0ae 100644
--- a/crates/pa-daemon/src/worker/tests/goal_tests.rs
+++ b/crates/pa-daemon/src/worker/tests/goal_tests.rs
@@ -210,7 +210,7 @@ async fn goal_turn_end_loop_runs_to_completion() {
"first pursuit turn",
"second pursuit turn",
{ "content": [
- { "type": "toolCall", "name": "ipython",
+ { "type": "toolCall", "name": "python_repl",
"arguments": { "code": "import goal; await goal.complete()" } },
] },
"wrap-up after the completion",
diff --git a/crates/pa-daemon/tests/abort_kernel_e2e.rs b/crates/pa-daemon/tests/abort_kernel_e2e.rs
index f83fb0bd23..90c96c033c 100644
--- a/crates/pa-daemon/tests/abort_kernel_e2e.rs
+++ b/crates/pa-daemon/tests/abort_kernel_e2e.rs
@@ -47,7 +47,7 @@ fn faux_script(dir: &Path) -> PathBuf {
"responses": [
{"content": [
{"type": "text", "text": "Running the wedge cell."},
- {"type": "toolCall", "name": "ipython", "id": "toolu_wedge01",
+ {"type": "toolCall", "name": "python_repl", "id": "toolu_wedge01",
"arguments": {"code":
"import time\nopen('wedge-started', 'w').write('1')\ntime.sleep(300)\nopen('wedge-finished', 'w').write('1')\nprint('cell completed')"}}
]},
diff --git a/crates/pa-daemon/tests/agent_family_e2e.rs b/crates/pa-daemon/tests/agent_family_e2e.rs
index aab2099de5..ea395fb76e 100644
--- a/crates/pa-daemon/tests/agent_family_e2e.rs
+++ b/crates/pa-daemon/tests/agent_family_e2e.rs
@@ -242,7 +242,7 @@ fn child_responses(receipts_dir: &Path) -> Value {
let cell = child_cell(receipts_dir);
let reply = json!([
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": { "code": cell } },
+ { "type": "toolCall", "name": "python_repl", "arguments": { "code": cell } },
] },
{ "text": "kid turn done" },
]);
@@ -599,7 +599,7 @@ fn record_cell(request: &str, name: &str, receipts_dir: &Path) -> String {
fn cell_turn(code: &str) -> Value {
json!([
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": { "code": code } },
+ { "type": "toolCall", "name": "python_repl", "arguments": { "code": code } },
] },
{ "text": "cell turn done" },
])
@@ -633,7 +633,7 @@ async fn family_edges_never_cross_families_end_to_end() {
"parent-a",
&json!([
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": { "code": parent_a_cell } },
+ { "type": "toolCall", "name": "python_repl", "arguments": { "code": parent_a_cell } },
] },
{ "text": "parent-a turn done" },
{ "text": "parent-a turn done" },
diff --git a/crates/pa-daemon/tests/kernel_dispose_e2e.rs b/crates/pa-daemon/tests/kernel_dispose_e2e.rs
index 9bd6794fe7..5bcdb1b3bf 100644
--- a/crates/pa-daemon/tests/kernel_dispose_e2e.rs
+++ b/crates/pa-daemon/tests/kernel_dispose_e2e.rs
@@ -247,7 +247,7 @@ fn write_faux_script(dir: &Path) -> PathBuf {
"engine": "faux",
"responses": [
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": {
+ { "type": "toolCall", "name": "python_repl", "arguments": {
"code": cell,
} },
] },
diff --git a/crates/pa-daemon/tests/mcp_product_path_e2e.rs b/crates/pa-daemon/tests/mcp_product_path_e2e.rs
index 10952bac7d..06e68c061b 100644
--- a/crates/pa-daemon/tests/mcp_product_path_e2e.rs
+++ b/crates/pa-daemon/tests/mcp_product_path_e2e.rs
@@ -272,7 +272,7 @@ fn settings_declared_stdio_server_round_trips_through_the_kernel_mcp_client() {
"engine": "faux",
"responses": [
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": {
+ { "type": "toolCall", "name": "python_repl", "arguments": {
"code": mcp_cell(&receipt),
} },
] },
@@ -408,7 +408,7 @@ fn begin_login_host_request_is_live_in_the_worker() {
"engine": "faux",
"responses": [
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": {
+ { "type": "toolCall", "name": "python_repl", "arguments": {
"code": cell,
} },
] },
diff --git a/crates/pa-daemon/tests/peer_messaging_e2e.rs b/crates/pa-daemon/tests/peer_messaging_e2e.rs
index 56b8942d7c..dfb49585c1 100644
--- a/crates/pa-daemon/tests/peer_messaging_e2e.rs
+++ b/crates/pa-daemon/tests/peer_messaging_e2e.rs
@@ -287,13 +287,13 @@ fn alpha_responses(receipts_dir: &Path) -> Value {
let receipt_path = receipts_dir.join("0.json");
json!([
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": {
+ { "type": "toolCall", "name": "python_repl", "arguments": {
"code": send_cell("hello from alpha", "beta", &receipt_path),
} },
] },
{ "text": "alpha turn done" },
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": {
+ { "type": "toolCall", "name": "python_repl", "arguments": {
"code": send_cell("hello from alpha", "beta", &receipt_path),
} },
] },
diff --git a/crates/pa-daemon/tests/readoption_wake_e2e.rs b/crates/pa-daemon/tests/readoption_wake_e2e.rs
index feae0e0a31..c1f559da7d 100644
--- a/crates/pa-daemon/tests/readoption_wake_e2e.rs
+++ b/crates/pa-daemon/tests/readoption_wake_e2e.rs
@@ -174,7 +174,7 @@ fn serve(mut stream: TcpStream, next: &AtomicUsize) -> std::io::Result<()> {
"id": "call-wake-1",
"type": "function",
"function": {
- "name": "ipython",
+ "name": "python_repl",
"arguments": "{\"code\": \"bash(\\\"sleep 12; echo RW_WAKE_DONE\\\")\\nprint('watcher armed')\"}"
}
}]
diff --git a/crates/pa-daemon/tests/replacement_kernel_e2e.rs b/crates/pa-daemon/tests/replacement_kernel_e2e.rs
index 00b1dbd8d7..9de08b9900 100644
--- a/crates/pa-daemon/tests/replacement_kernel_e2e.rs
+++ b/crates/pa-daemon/tests/replacement_kernel_e2e.rs
@@ -285,13 +285,13 @@ fn write_faux_script(dir: &Path) -> PathBuf {
"engine": "faux",
"responses": [
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": {
+ { "type": "toolCall", "name": "python_repl", "arguments": {
"code": seed_cell(dir, "seed"),
} },
] },
{ "text": "done" },
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": {
+ { "type": "toolCall", "name": "python_repl", "arguments": {
"code": probe_cell(dir, "probe"),
} },
] },
@@ -579,7 +579,7 @@ fn switch_session_rebinds_the_kernel_cwd_onto_the_target_session() {
"engine": "faux",
"responses": [
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": {
+ { "type": "toolCall", "name": "python_repl", "arguments": {
"code": format!(
"import os\nopen({receipt:?}, \"w\").write(os.getcwd())\nprint(\"cwd\")",
receipt = receipt.to_string_lossy(),
diff --git a/crates/pa-daemon/tests/rlm_children_parent_death_e2e.rs b/crates/pa-daemon/tests/rlm_children_parent_death_e2e.rs
index 8fe2341eb4..1cb52d7837 100644
--- a/crates/pa-daemon/tests/rlm_children_parent_death_e2e.rs
+++ b/crates/pa-daemon/tests/rlm_children_parent_death_e2e.rs
@@ -310,7 +310,7 @@ fn write_parent_script(dir: &Path, first_cell: &str) -> PathBuf {
"engine": "faux",
"responses": [
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": { "code": first_cell } },
+ { "type": "toolCall", "name": "python_repl", "arguments": { "code": first_cell } },
] },
{ "text": "spawn turn done" },
],
diff --git a/crates/pa-daemon/tests/rlm_children_replacement_e2e.rs b/crates/pa-daemon/tests/rlm_children_replacement_e2e.rs
index 4d6ed63a70..39e0bfc2f1 100644
--- a/crates/pa-daemon/tests/rlm_children_replacement_e2e.rs
+++ b/crates/pa-daemon/tests/rlm_children_replacement_e2e.rs
@@ -308,11 +308,11 @@ fn write_parent_script(dir: &Path, first_cell: &str, probe_cell: &str) -> PathBu
"engine": "faux",
"responses": [
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": { "code": first_cell } },
+ { "type": "toolCall", "name": "python_repl", "arguments": { "code": first_cell } },
] },
{ "text": "spawn turn done" },
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": { "code": probe_cell } },
+ { "type": "toolCall", "name": "python_repl", "arguments": { "code": probe_cell } },
] },
{ "text": "probe turn done" },
],
diff --git a/crates/pa-daemon/tests/rlm_quiescence_barrier_e2e.rs b/crates/pa-daemon/tests/rlm_quiescence_barrier_e2e.rs
index 48b7e80bb3..3a281b79b4 100644
--- a/crates/pa-daemon/tests/rlm_quiescence_barrier_e2e.rs
+++ b/crates/pa-daemon/tests/rlm_quiescence_barrier_e2e.rs
@@ -240,7 +240,7 @@ fn write_parent_script(dir: &Path, first_cell: &str) -> PathBuf {
"engine": "faux",
"responses": [
{ "content": [
- { "type": "toolCall", "name": "ipython", "arguments": { "code": first_cell } },
+ { "type": "toolCall", "name": "python_repl", "arguments": { "code": first_cell } },
] },
{ "text": "spawn turn done" },
{ "text": "notice seen" },
diff --git a/crates/pa-daemon/tests/steer_boundary_batch_e2e.rs b/crates/pa-daemon/tests/steer_boundary_batch_e2e.rs
index 0c11180dff..dc8980c5a5 100644
--- a/crates/pa-daemon/tests/steer_boundary_batch_e2e.rs
+++ b/crates/pa-daemon/tests/steer_boundary_batch_e2e.rs
@@ -67,7 +67,7 @@ fn faux_script(dir: &Path) -> PathBuf {
"responses": [
{"content": [
{"type": "text", "text": "Running the first sleep cell."},
- {"type": "toolCall", "name": "ipython", "id": "toolu_sleep01",
+ {"type": "toolCall", "name": "python_repl", "id": "toolu_sleep01",
"arguments": {"code":
"import time\nopen('sleep-one-started','w').write('1')\ntime.sleep(4)\nprint('slept one')"}}
]},
diff --git a/crates/pa-telemetry/src/events.rs b/crates/pa-telemetry/src/events.rs
index b5decee9fc..b98cb018b5 100644
--- a/crates/pa-telemetry/src/events.rs
+++ b/crates/pa-telemetry/src/events.rs
@@ -65,7 +65,7 @@ impl ToolCategory {
"grep" => Self::Grep,
"find" => Self::Find,
"ls" => Self::Ls,
- "ipython" => Self::Ipython,
+ "python" | "ipython" => Self::Ipython,
"mcp" => Self::Mcp,
"" => Self::Unknown,
_ => Self::Custom,
@@ -239,7 +239,7 @@ mod tests {
assert_eq!(ToolCategory::from_tool_name("bash"), ToolCategory::Bash);
assert_eq!(ToolCategory::from_tool_name("Edit"), ToolCategory::Edit);
assert_eq!(
- ToolCategory::from_tool_name("ipython"),
+ ToolCategory::from_tool_name("python_repl"),
ToolCategory::Ipython
);
assert_eq!(
diff --git a/crates/pa-tui/src/session_ui/apply.rs b/crates/pa-tui/src/session_ui/apply.rs
index ba828af16a..8f8955106d 100644
--- a/crates/pa-tui/src/session_ui/apply.rs
+++ b/crates/pa-tui/src/session_ui/apply.rs
@@ -920,7 +920,7 @@ impl SessionUi {
/// `tui ipython bash rendered`: the settled ipython card that renders
/// as bash reports its bash share, primitives only.
fn track_ipython_bash_rendered(&self, card: &crate::tool_card::ToolCallCard) {
- if card.name != "ipython" {
+ if !pa_types::ai::is_python_tool_name(&card.name) {
return;
}
let Some(stats) = crate::tool_card::ipython::bash_dominated_stats(card) else {
diff --git a/crates/pa-tui/src/snapshot/tests.rs b/crates/pa-tui/src/snapshot/tests.rs
index 1d2dee9eb5..de7e83a1a5 100644
--- a/crates/pa-tui/src/snapshot/tests.rs
+++ b/crates/pa-tui/src/snapshot/tests.rs
@@ -147,17 +147,17 @@ fn unnamed_streamed_tool_call_renders_code_once_named() {
apply_streamed_tool_card(
&mut view,
"call-1",
- "ipython",
+ "python_repl",
&json!({ "code": "fibonacci(23)" }),
);
let card = card_of(&view).expect("the named frame creates the card");
- assert_eq!(card.name, "ipython");
+ assert_eq!(card.name, "python_repl");
assert!(card.args.get("code").is_some(), "args stream into the card");
let rows = rendered_card_text(&view);
assert!(
rows.iter()
.any(|row| row.contains("python") && row.contains("fibonacci(23)")),
- "the ipython card renders the code preview: {rows:?}"
+ "the python_repl card renders the code preview: {rows:?}"
);
assert!(
rows.iter()
diff --git a/crates/pa-tui/src/tool_card/mod.rs b/crates/pa-tui/src/tool_card/mod.rs
index 13c6e4ccc0..597ee07cac 100644
--- a/crates/pa-tui/src/tool_card/mod.rs
+++ b/crates/pa-tui/src/tool_card/mod.rs
@@ -125,7 +125,9 @@ pub fn render_tool_card(
show_images: bool,
) -> Vec<Line> {
match card.name.as_str() {
- "ipython" => ipython::render(card, frame, detail, theme, width, show_images),
+ name if pa_types::ai::is_python_tool_name(name) => {
+ ipython::render(card, frame, detail, theme, width, show_images)
+ }
"bash" => bash::render(card, frame, detail, theme, width, show_images),
_ => generic::render(card, frame, detail, theme, width, show_images),
}
@@ -333,7 +335,9 @@ pub(crate) fn count_tool_card(
show_images: bool,
) -> usize {
match card.name.as_str() {
- "ipython" => ipython::count(card, frame, detail, theme, width, show_images),
+ name if pa_types::ai::is_python_tool_name(name) => {
+ ipython::count(card, frame, detail, theme, width, show_images)
+ }
"bash" => bash::count(card, frame, detail, theme, width, show_images),
_ => generic::count(card, frame, detail, theme, width, show_images),
}
diff --git a/crates/pa-tui/src/tree_display.rs b/crates/pa-tui/src/tree_display.rs
index 6962e24e24..9c9588f996 100644
--- a/crates/pa-tui/src/tree_display.rs
+++ b/crates/pa-tui/src/tree_display.rs
@@ -107,7 +107,7 @@ pub fn user_entry_text(entry: &FileEntry) -> Option<String> {
}
}
-/// One tool-call row: `[edit: ~/path]`, `[bash: cmd…]`, `[ipython: code…]`,
+/// One tool-call row: `[edit: ~/path]`, `[bash: cmd…]`, `[python_repl: code…]`,
/// or the truncated-JSON fallback (TS `formatToolCall`).
fn format_tool_call(theme: &Theme, name: &str, arguments: &Value) -> Line {
let shorten_path = |p: &str| -> String {
@@ -141,7 +141,9 @@ fn format_tool_call(theme: &Theme, name: &str, arguments: &Value) -> Line {
let text = match name {
"edit" => format!("[edit: {}]", shorten_path(&arg("path"))),
"bash" => format!("[bash: {}]", shorten(&arg("command"))),
- "ipython" => format!("[ipython: {}]", shorten(&arg("code"))),
+ python_name if pa_types::ai::is_python_tool_name(python_name) => {
+ format!("[{python_name}: {}]", shorten(&arg("code")))
+ }
_ => {
let serialized = serde_json::to_string(arguments).unwrap_or_default();
let truncated: String = serialized.chars().take(40).collect();
diff --git a/crates/pa-types/src/ai/mod.rs b/crates/pa-types/src/ai/mod.rs
index 938b700b0f..15439fe760 100644
--- a/crates/pa-types/src/ai/mod.rs
+++ b/crates/pa-types/src/ai/mod.rs
@@ -250,6 +250,13 @@ pub struct ImageContent {
pub rest: JsonMap,
}
+pub const PYTHON_TOOL_NAME: &str = "python_repl";
+
+#[must_use]
+pub fn is_python_tool_name(name: &str) -> bool {
+ matches!(name, PYTHON_TOOL_NAME | "python" | "ipython")
+}
+
/// Tool call content block (`type: "toolCall"`).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]