run_python
Execute Python code in a persistent IPython kernel, sharing variables and state across cells. Control execution with directives for wait time and full output.
Instructions
向持久 IPython kernel 提交一个原始 Python cell。
请你使用 IPython 的思想来优雅使用本系列工具。
输入
接受一段 loommux IPython cell 源码。普通 Python 文本使用默认策略;若作者
需要声明本次 cell 的观察策略,使用位于物理行首的 # loommux: 控制
注释。变量、导入和其他 namespace 状态会与同一服务器会话中的后续 cell
共享。
等待上限
本次调用默认最多等待 10 秒。# loommux: 的 --wait 正有限十进制
值只覆盖本次调用的等待上限::
# loommux: --wait 120
build_report()# loommux: --wait 120 与 # loommux: --full-output 可写在同一条
或不同的控制注释中。重复选项、未知选项、缺少值或非正值会返回
invalid_loommux_directive,不会分配 execution 或提交 kernel。等待
到期不会中断仍在运行的 cell;directive 不改变 Python runtime 或后续
调用的等待上限。
完整输出
若任一有效 # loommux: 控制注释包含 --full-output,该 execution
在终态时直接交付完整 combined 正文,不受默认 300 行交付阈值限制::
# loommux: --full-output
print("\n".join(generate_manifest()))--wait 与 --full-output 可以组合为
# loommux: --wait 120 --full-output。这些选项只作用于本次
execution,且 authored directive line 保留在原始 source 中。在明确需要
完整阅读某些信息,例如阅读某些文件、资料时,使用该选项避免无意义的
反复阅读开销。
图像展示
IPython display() 产生的 PNG、JPEG、WEBP 或单帧 GIF 图像会按输出
顺序直接交付给agent。普通 display(image) 使用高视觉细节;本次展示
需要整体确认或密集文字时,分别书写 display(image, metadata={"detail": "low"}) 或 display(image, metadata={"detail": "original"})。detail 只作用于这一处 display() 调用。
执行编号与后续操作
已接受的提交会分配一个正整数 execution,它在服务器进程存续
期间严格递增。若执行仍在运行,或未标记 execution 的 combined 输出
超过 300 行,响应不携带完整输出正文;使用 wait_python 等待,使用
python_execution_status 查看状态,使用 read_python_output
或 search_python_output 读取或搜索保留的输出。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| freeform | Yes | 要提交的原始 Python cell 源码文本;可用 ``# loommux:`` 控制注释声明本次初始等待与完整输出策略。 |