Code Mode for AI agents
An agent connected over MCP usually calls one tool at a time: list the flows, read the runs of each, pause each schedule… dozens of round trips, every answer passing through its context. With Code Mode it writes ONE program that does all of it, and calls code_mode_run once.
- When Code Mode is the better path
- What runs, as whom, and what comes back
- The limits and how to read the writes list
One program instead of many calls
- The agent reads the library
code_mode_referencegives the waiso library’s calls for the language it picks — every language Waiso runs. - It writes one program
Reads and writes alike: list, filter, change, return a summary.
- Waiso runs it
In the project’s sandbox (no network), as the token: every call is checked against the token’s scope and its owner’s access.
- Only the outcome comes back
The program’s result, its logs and
writes— every change it made, in order, even when it stops halfway.
There is nothing to turn on: Code Mode is two tools of the same MCP server, and the server’s own guide tells agents to prefer them for any job of several steps. You can still ask for it in words — “use Code Mode” — and the agent writes a program like this one.
import waiso
def main():
paused = []
for flow in waiso.api.flows.list()["flows"]:
runs = waiso.api.runs.list(target=f"flow:{flow['id']}", status="failed", limit=50)
if runs["total"] > 3:
for s in waiso.api.schedules.list()["schedules"]:
if s["target"].get("flowId") == flow["id"] and s["enabled"]:
waiso.api.schedules.update(s["id"], enabled=False)
paused.append(s["name"])
return {"paused": paused}When to use it, and when not
Code Mode pays off when a request means looking at many things and deciding: clean up runs, pause what keeps failing, rename a batch of scripts, collect a report across flows. The agent spends its tokens on the program and on the short answer, not on every list it would otherwise read. For a single action — run this script, show this flow — the MCP tool for it is just as good and easier to follow.
The program can only reach the platform, and only as the token: it has no network, no files outside its run, and a call outside the token’s scope raises the library’s error. A program that loops forever is stopped at its time limit; what it changed until then is still listed.
Limits and what you see
| Limit | Code Mode |
|---|---|
| Time | 60 s by default, up to the install’s script limit |
| Program | Up to 64 KiB, in Python, TypeScript, JavaScript, Go, PHP, Ruby, C, C++ or Bash |
| Result and logs | 64 KiB each, marked when cut |
| Cost | One run credit, like any script run |
| Network | None — the program reaches only the platform, through the library |
Every Code Mode run is in Runs as Code Mode with the token’s name; open it to see the program, the result and a Changes made table. Each change is also in the audit log, with the token and the run.