m2_evaluate
Evaluate Macaulay2 code in a persistent session, returning output while preserving state across calls and including errors without breaking the session.
Instructions
Evaluate Macaulay2 code in the persistent session and return its output.
State (rings, variables, ideals, ...) persists across calls. M2 errors
are included in the returned text and do not break the session.
Separate statements with newlines: a trailing ";" suppresses that
statement's result (use an explicit "print" to force output).
Args:
code: Macaulay2 code, e.g. "R = QQ[x,y,z]
I = ideal(x^3 - y, x^4 - z) print generators (gb I)" timeout_s: Author-set safety limit (default 120, max 3600). Raise it for heavy computations (large Groebner bases, Hilbert polynomials, ...). On timeout the session is restarted, so the retried code must include all setup again. With stop_on_error=True the budget applies PER INPUT. stop_on_error: Default False = REPL semantics (an error does not stop later lines from running). True sends the code input by input and halts at the first error, leaving later inputs unexecuted. Requires each line to be a self-contained statement (do not break a line after a binary operator). show_memory: True (default) appends one line naming the kernel's memory (resident + peak; swap when it is paging) to the result; False omits it. The values are recorded in the journal either way.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeout_s | No | ||
| show_memory | No | ||
| stop_on_error | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |