Skip to main content
Glama

yade_execute_code

Synchronously execute Python code in the YADE simulation environment to inspect or modify state in real time, with immediate output.

Instructions

Execute Python code synchronously in the running YADE process.

Returns stdout immediately. Code runs in the YADE Python environment where yade modules are already imported; side effects persist.

This tool remains responsive EVEN WHILE a simulation task is running (submitted via yade_execute_task). Use it as a live REPL to inspect simulation state in real time — no need to pre-script print statements.

Typical uses:

  • Query simulation state: O.bodies count, current iteration

  • Create/modify bodies, engines, interactions

  • Read or set material properties

  • Live inspection during a running simulation (e.g. check stress tensor, coordination number, energy balance, or capture viewport screenshots when GUI is available)

  • Development and REPL-style testing

Unlike yade_execute_task, this tool is fire-and-return: the response contains the full output. It is NOT tracked by yade_list_tasks and cannot be interrupted or polled.

Timeout behaviour: on timeout the bridge attempts to abort the running code via an async exception injection. Two outcomes:

  • status="terminated" — abort succeeded; the pump thread is free, but YADE state may be partially modified by the code that ran before the abort fired. Inspect state before retrying.

  • status="timeout" — abort failed (code stuck in a C extension, or nested inside a running task's PyRunner tick); the bridge may still be blocked. Restart if unresponsive.

WARNING: For anything expected to take more than a few seconds, use yade_execute_task instead — it has proper cancellation via yade_interrupt_task and does not leave state drift on timeout. Also, do NOT write except BaseException: in your code; it defeats bridge-initiated cancellation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesPython code to execute in YADE process
timeoutNoConsole execution timeout in seconds

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

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

With no annotations provided, the description carries full burden. It discloses that the tool is fire-and-return, not tracked by yade_list_tasks, cannot be interrupted, and details two timeout outcomes (terminated vs timeout) with consequences for YADE state. It warns about state drift and blockages, providing full behavioral transparency.

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

Conciseness5/5

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

The description is well-structured with clear sections, bullet points, and front-loaded purpose. Every sentence serves a purpose, providing necessary details without redundancy. It is concise but comprehensive given the tool's complexity.

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?

Given the tool's complexity (interactive execution, integration with simulation), the description is complete. It explains return values implicitly (stdout, status) and covers typical use cases, timeout behavior, and warnings. An output schema exists, but the description adequately complements it.

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 description adds significant meaning beyond the input schema, which only provides basic descriptions. It explains that code runs in the YADE environment with pre-imported modules and that side effects persist. Timeout behavior is explained in depth, covering abort mechanics and possible outcomes.

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 purpose: 'Execute Python code synchronously in the running YADE process.' It specifies that it returns stdout immediately and differentiates itself from sibling tools like yade_execute_task by highlighting its fire-and-return nature and real-time inspection capability.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool (live REPL, inspection, state modification) and when not to (long-running tasks). It directs users to yade_execute_task for longer executions, offers alternatives, and warns against patterns that defeat cancellation (e.g., except BaseException).

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yusong652/yade-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server