Skip to main content
Glama

run_cell

Execute Python code in a persistent IPython kernel, sharing variables and imports across cells. Supports custom directives for wait time and full output retrieval.

Instructions

向持久 IPython kernel 提交一个原始 IPython cell。

请你使用 IPython 的思想来优雅使用本系列工具。

输入

接受一段 loommux IPython cell 源码。普通 Python 文本使用默认策略;若作者 需要声明本次 cell 的观察策略,使用位于物理行首的 # loommux: 控制 注释。Loommux 在提交前验证并完全消费有效控制注释,因此它们不会进入 IPython history 或下游 cell-magic body。变量、导入和其他 namespace 状态会 与当前持久 IPython 会话中的后续 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 正文,不受默认 5,000-token 交付阈值限制::

# loommux: --full-output
print("\n".join(generate_manifest()))

--wait--full-output 可以组合为 # loommux: --wait 120 --full-output。这些选项只作用于本次 execution。有效控制注释在提交前被 Loommux 完全消费,不会进入 IPython history、cell magic body 或 execution 响应。在明确需要完整阅读某些信息, 例如阅读某些文件、资料时,使用该选项避免无意义的反复阅读开销。

图像展示

IPython display() 产生的 PNG、JPEG、WEBP 或单帧 GIF 图像会按输出 顺序直接交付给agent。普通 display(image) 使用高视觉细节;本次展示 需要整体确认或密集文字时,分别书写 display(image, metadata={"detail": "low"})display(image, metadata={"detail": "original"})detail 只作用于这一处 display() 调用。

执行编号与后续操作

每个已接受的提交都会获得一个连续递增的正整数 execution。后续工具 使用它定位当前持久 IPython 会话中的这次执行。若执行仍在运行,或未标记 --full-output 的 combined 输出超过 5,000 token,响应不携带完整输出 正文;行数、Unicode code point 字符数和 UTF-8 字节数描述同一份 normalized combined 文本。使用 wait 等待,使用 execution_status 查看状态,使用 read_outputsearch_output 读取或搜索保留的输出。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
freeformYes原始 IPython cell 源码文本。

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.13

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure, and it does so thoroughly. It discloses the default 10-second wait, how '--wait' overrides it, that control comments are fully consumed and do not enter history or cell-magic bodies, that waiting expiry does not interrupt a running cell, the 5,000-token output truncation threshold, the effect of '--full-output', image display behavior with detail metadata, and the execution numbering scheme. This is comprehensive transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but well-structured with clear sections (输入, 等待上限, 完整输出, 图像展示, 执行编号与后续操作). Every section adds essential information, and the main purpose is front-loaded in the first sentence. It could be slightly more concise, but the organization makes it easy to navigate.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with one parameter and no output schema, the description is exceptionally complete. It covers input format, control directives, wait behavior, output truncation and the full-output override, image display options, execution numbering, and explicitly mentions the sibling tools for subsequent operations. An agent has all the information needed to invoke run_cell correctly and understand its effects.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema only describes 'freeform' as '原始 IPython cell 源码文本' (raw IPython cell source text). The description adds significant meaning by explaining the 'loommux:' control comment syntax, including '--wait' and '--full-output' options, their combinations, validation behavior, and how they affect the execution. This goes far beyond the schema's minimal description, giving the agent actionable details for constructing valid input.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action: '向持久 IPython kernel 提交一个原始 IPython cell' (submit a raw IPython cell to a persistent kernel). It distinguishes itself from sibling tools by positioning itself as the submission entry point, with siblings like wait, execution_status, read_output, and search_output described as subsequent operations for handling the execution.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for using the tool, including when to use the '--full-output' option (when full reading of information like files or materials is needed to avoid repeated reading overhead) and how to combine options. It also implies that for checking status or reading output, one should use the sibling tools (wait, execution_status, read_output, search_output), but it doesn't explicitly state when not to use run_cell itself. The guidance is implicit but effective.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.