Skip to main content
A script is what the model writes and Rewind runs: one TypeScript module whose default export is the entry point. This page is for you, to prompt the model well and to read its scripts; the agent tools already describe the format to the model.
  • One module. Its default export is async function main(input). Input and output are JSON.
  • Three imports. rewind:tools (the toolset’s tools), rewind:workflows (the workflows it pins) and rewind (the standard library). No npm packages, no relative imports, no dynamic import().
  • Strict TypeScript. The script is type-checked against the toolset’s declarations before it runs.

Prompting the model

Put the toolset’s declarations in the system prompt, and say how you want the model to work:
What helps in practice:
  • Ask for one script per task, which returns only what the conversation needs. Intermediate data stays in the run.
  • Mention retry_run. A failed run is fixed by a fork that does not repeat its calls, rather than by a new run that does.
  • Describe your host tools well. Their description is the model’s only documentation, and so are your MCP servers’ tool descriptions.
  • Give output schemas to host tools. MCP tools without one get observed types after their first results.

Patterns

Tool calls are promises: run independent ones together. A run has at most 16 calls in flight; the others wait for a slot.
A failed call throws a ToolError. Catch it where the script can do something better than fail.
error.outcomeUnknown is true when the call was interrupted and may have taken effect: check before calling again.
The harness, or the model with signal_run, sends the signal. See Human in the loop.
console.log lines are journaled, shown in the dashboard next to their line, and returned with the run: the model sees the last ones.
See Workflows.

Mistakes Rewind catches