Skip to content
Changelog

Report a bug

Test Automations

Test a managed agent automation before you use it for recurring work. The test is different for each kind of automation.

Instruction automationCode automation
How you testSelect Test or Test automation in the editor.Write fixtures in fixtures.json, or run one fixture with type-cli automations test-code.
What runsThe managed agent follows the saved instructions in a private thread.The entry stage of one subscription runs with a fixed event and fixed responses.
When it runsWhen you select the button.During each CLI deploy, or when you run test-code.

A private test runs the automation in a private thread in its channel. Only you can see the thread. The thread has the name of the automation, and it links back to the automation editor. Read the response, then change the instructions in the editor.

  1. For a scheduled automation, open the automation from Automations in the sidebar.
  2. Save your changes. The test uses the saved instructions and model settings, so save first.
  3. Select Test.

For an event automation, open the event automation editor and select Test automation.

  • A private test does not wait for a real schedule, webhook, Slack event, or RSS item. Use it to examine the instructions and the behavior of the managed agent before you use live events.
  • The test runs as the person who selects Test. A scheduled run uses the execution identity, model provider credentials, and model billing context of the automation creator.
  • Each test makes a new preview in its private thread. This also occurs if the automation already delivered a result that day.
  • A test ignores delivery checkpoints and duplicate-delivery checks.
  • A test keeps the access requirements of the source.
  • A test does not change external delivery, delivery checkpoints, or recorded automation data.
  • A test can save authorized account choices. When new account choices are on for your workspace, another member’s private test can save a shared Team connection. That member must have access in the test Space, and the automation creator must have access in every destination Space. See Choose a connected account.

Use this checklist when you test with a real trigger event:

  1. Make sure that the Space has the connections that it needs.
  2. Send a typical trigger event, or wait for one.
  3. Open the thread that the run made.
  4. Examine the response and the tool calls of the managed agent.
  5. Change the automation instructions if it is necessary.
  6. Make sure that the correct people get a notification.

A fixture is a test case. It gives one subscription a fixed event and fixed responses for each call. You can run fixtures in two ways:

  • At deploy. type-cli automations deploy runs every fixture in fixtures.json. If one fails, the deploy fails and the active code does not change. A deploy from Type AI with create_task has no fixtures.
  • On saved code. type-cli automations test-code runs one fixture against the saved code of an automation, whether it is on or paused. Any member of its Space can run the fixture test. From Type AI, test_automation_code can also test draft code that isn’t saved yet; the automation keeps running its saved version. The command uses a fixture rather than a real event. It does not enable the automation, but a passing test can complete a pending Enable request.
Terminal window
type-cli automations test-code <automation-id> --space <space> --arguments-file ./fixture.json --json

For test-code, the fixture has subscriptionId and payload, and can have checkpoint, matcher, environment, toolResponses, and integrationResponses. It cannot have name, expectedOutput, or expectedError. Read the result in the command output. A test counts as evidence for enabling only when the stage ran and the fixture includes toolResponses or integrationResponses. Use "toolResponses": [] when the stage makes no calls.

A fixture runs one stage: the entry stage of its subscription. What happens next depends on the decision that the entry stage returns:

The entry stage returnsIn the fixture
complete(value)The fixture ends. expectedOutput is compared with value.
blocked(reason, value)The fixture ends. expectedOutput is compared with value.
blocked(reason)The fixture ends with no output.
next(stage, input)Type checks input against the destination stage and records the transition. The destination stage does not run. There is no output.
An ErrThe fixture fails, unless expectedError matches the error.

A fixture never starts an agent stage, and it never runs the onResult stage of an agent. Later code stages also do not run. To check what the entry stage passes on, read transition in the test-code result. To test a later stage, call it locally with runAutomationDefinition (see Run a stage in a local test), or test it in a live run.

For example, this automation sends weekdays to an agent stage and finishes weekends in its entry stage:

src/main.ts
import {
agent,
agentResult,
automation,
code,
complete,
next,
recurringEventSchema,
} from "@type-dot-com/sdk/automations";
import { z } from "zod";
// What the agent stage gets, and what it must submit.
const day = z.object({ day: z.string() });
const incidentSummary = z.object({ summary: z.string().min(1) });
export default automation({
output: z.object({ day: z.string(), summary: z.string().nullable() }),
deployment: {
subscriptions: {
daily: {
title: "Daily incident summary",
description: "Summarize incidents on weekdays",
source: {
kind: "recurring",
schedule: { kind: "interval", everySeconds: 86400 },
},
entry: "start",
},
},
},
stages: {
// 1. Code: finish weekends here. Send weekdays to the agent.
start: code({
input: recurringEventSchema,
transitions: ["review"],
run({ input }) {
const date = input.scheduledAt.slice(0, 10);
const weekday = new Date(input.scheduledAt).getUTCDay();
const isWeekend = weekday === 0 || weekday === 6;
if (isWeekend) {
return complete({ day: date, summary: null });
}
return next("review", { day: date });
},
}),
// 2. Agent: summarize the day's incidents.
review: agent({
input: day,
output: incidentSummary,
instructions:
"Summarize the incidents that this Space discussed on the given day in two sentences.",
onResult: "record",
}),
// 3. Code: complete the run with the summary.
record: code({
input: agentResult({ input: day, output: incidentSummary }),
transitions: [],
run({ input }) {
return complete({ day: input.taskInput.day, summary: input.result.summary });
},
}),
},
});

Its fixtures cover both paths of the entry stage. The weekday fixture has no expectedOutput, because the entry stage returns next():

fixtures.json
[
{
"name": "skips weekends",
"subscriptionId": "daily",
"payload": { "scheduledAt": "2026-10-10T09:00:00.000Z" },
"toolResponses": [],
"expectedOutput": { "day": "2026-10-10", "summary": null }
},
{
"name": "sends weekdays to the agent",
"subscriptionId": "daily",
"payload": { "scheduledAt": "2026-10-12T09:00:00.000Z" },
"toolResponses": []
}
]

If you add expectedOutput to the weekday fixture, even null, the fixture fails with “Fixture output did not match expectedOutput”. When you run the weekday fixture with test-code, result.output in the command output shows the transition:

{
"stage": "start",
"transition": {
"kind": "next",
"next": "review",
"input": { "day": "2026-10-12" }
},
"fixtureExecuted": true
}

Fixtures never read saved Space variables or secrets. Supply fake user values in the optional environment map to exercise code that reads process.env:

{
"subscriptionId": "tick",
"payload": { "scheduledAt": "2026-10-07T12:00:00.000Z" },
"environment": { "SERVICE_TOKEN": "synthetic-test-token" },
"toolResponses": []
}

Use synthetic values only. Fixture files are source-controlled and can appear in test diagnostics. Type removes reserved variable names from the map. Source validation also receives no saved variables; check required configuration inside the stage that runs, after the module has loaded.

Put a fixtures.json file in the project root. It contains an array of fixtures:

fixtures.json
[
{
"name": "records the scheduled time",
"subscriptionId": "hourly",
"payload": { "scheduledAt": "2026-10-07T12:00:00.000Z" },
"toolResponses": [],
"expectedOutput": { "checkedAt": "2026-10-07T12:00:00.000Z" }
}
]
  • name is unique in the file.
  • subscriptionId is the key of a subscription in deployment.subscriptions. The fixture runs that subscription’s entry stage.
  • payload is the event, in the same shape as a live event.
  • expectedOutput is the exact value that the entry stage gives to complete() or blocked().

For all fields, see Project Files.

Fixtures can answer two kinds of calls: integration tool calls and Custom API requests. Each of these calls needs a response in the fixture. Use the real request and the real response envelope. This fixture is for an entry stage that runs printf automation-ready with managed-sandbox exec_command, fails with “Workspace check failed” if the tool returns an error, and completes with the text:

{
"name": "command output uses the text envelope",
"subscriptionId": "check",
"payload": { "scheduledAt": "2026-10-07T00:00:00.000Z" },
"toolResponses": [
{
"request": {
"service": "managed-sandbox",
"name": "exec_command",
"arguments": { "command": "printf automation-ready" }
},
"response": { "content": [{ "type": "text", "text": "automation-ready" }] }
}
],
"expectedOutput": { "text": "automation-ready" }
}
Your code callsPut the response inRequest fieldsResponse shape
ctx.tools.call, ctx.read.call, ctx.write.calltoolResponsesservice, name, arguments, organizationIntegrationId, rawSlug{ content, structuredContent?, isError? }
ctx.read.request, ctx.write.requestintegrationResponsesorganizationIntegrationId, method, path, query, headers, body{ connection, data, headers, status, statusText, success, truncated }

Rules:

  • The request must match the call exactly, field by field. Leave out the fields that your code does not send.
  • Effect keys are not part of the request. Do not put effectKey or automationEffectKey in a fixture.
  • Type uses each response one time. Two equal calls need two responses.
  • A call with no matching response fails the fixture with “Unexpected fixture tool call” or “Unexpected fixture integration request”. No live request is sent.
  • A response that your code does not use fails the fixture with “Unused fixture tool response” or “Unused fixture integration response”.
  • For ctx.read.call and ctx.write.call, the response must have structuredContent. JSON in content[].text does not count. A response with "isError": true returns an error to your code.
  • For ctx.read.request and ctx.write.request, a response with "success": false returns an error to your code.
  • If your stage makes no calls, set "toolResponses": [].

In a fixture, Type rejects calls to other Type APIs. The run fails with “Unexpected fixture API request; only declared tool or integration calls are available”.

CallIn a fixture
ctx.tools.call, ctx.read.call, ctx.write.callSupported. Give the response in toolResponses.
replyInSlackThreadSupported. It writes with slack_post_message; reactions first read slack_get_thread_replies. Supply both responses in toolResponses.
ctx.read.request, ctx.write.requestSupported. Give the response in integrationResponses.
ctx.action, ctx.mutativeActionSupported. Type records the steps in the test result.
ctx.saveCheckpointSupported. The test result shows the value as nextCheckpoint. Type does not save it.
next() to a code or agent stageSupported. Type records the transition but does not run the next stage.
ctx.write.sendMessageNot supported.
ctx.read.dataNot supported.
ctx.read.searchNot supported.
ctx.tools.find, ctx.tools.servicesNot supported.
Sandbox toolsSupported only as recorded toolResponses. A test never starts the sandbox.

For code that uses an unsupported call:

  • Write fixtures for the paths that end before the call. For example, test a filtered event or an error for bad data.
  • Test the path with the call in a live run. Use a test repository, a test channel, or a narrow filter. Then read the run with type-cli automations history --space <space> --run <run-id> --include-activity.
  • To post in Slack instead of the Space, use replyInSlackThread or a Slack tool through ctx.write.call. Fixtures can answer those calls.

Use expectedError to make sure that a bad response fails the stage:

{
"name": "provider error is a failed operation",
"subscriptionId": "check",
"payload": { "scheduledAt": "2026-10-07T00:00:00.000Z" },
"toolResponses": [
{
"request": { "service": "managed-sandbox", "name": "exec_command", "arguments": { "command": "printf automation-ready" } },
"response": { "content": [{ "type": "text", "text": "Workspace unavailable" }], "isError": true }
}
],
"expectedError": "Workspace check failed"
}
  • expectedError passes if the error message contains the text.
  • If the stage succeeds, the fixture fails.
  • A fixture error, such as a missing or unused response, fails the fixture even if its message contains the text.
  • An event that does not match the subscription schema fails with Invalid subscription event: .... You can test it with expectedError.
  • Do not set both expectedOutput and expectedError in one fixture.

For an event that a matcher or a resources filter skips, omit both expectedOutput and expectedError. The entry stage does not run, so there is no output. No output is not the same as null. Do not supply responses; an empty toolResponses array is fine. A filtered fixture with responses fails with “Unused fixture responses: the subscription matcher skipped this event”.

For AI questions, give the result in matcher. Type does not call the model in a fixture:

{ "matcher": { "decision": "skip" } }

If your entry stage filters the event itself and returns complete(value), test it like any other output, with expectedOutput.

Set checkpoint to the value that ctx.checkpoint.value has at the start of the stage:

{ "name": "stays quiet when nothing changed", "subscriptionId": "check", "checkpoint": "open", "payload": { "scheduledAt": "2026-10-07T00:00:00.000Z" }, "toolResponses": [] }

A fixture does not save checkpoints. Each fixture starts with its own checkpoint, or with null if you omit it.

Write one fixture for each different path in your entry stage:

  • the normal case, with extra provider fields and null optional fields,
  • each transition to another stage,
  • a filtered event,
  • a provider error or a response that does not match your schema,
  • a missing or wrong required ID.

Do not write many fixtures for the same path.

  • 20 fixtures in each fixtures.json file. Names have 1 to 120 characters.
  • 128 tool responses and 128 integration responses in each fixture.
  • All fixtures in a deploy share a 4-minute limit. Type runs 4 fixtures at a time.
  • A test-code run also has a 4-minute limit.

A test that passes does not prove that a live run will succeed.

Private tests of an instruction automation

Section titled “Private tests of an instruction automation”
  • A private test does not prove that real events arrive. It does not verify a webhook signature, an email address, or feed availability. Test real event delivery separately.
  • A successful test by another person does not prove that the automation creator has the same credentials or permissions.

After you enable the automation, examine the next run in Run history.

  • Fixtures test entry stages only. They do not run later code stages, agent stages, or onResult stages.
  • Fixtures do not call real APIs. They do not prove that your credentials work, or that the provider sends the response that you wrote.
  • Fixtures do not start the sandbox.
  • Fixtures do not call the model for AI questions in a matcher. To examine the answers of the model, send real example events.
  • Fixtures do not prove that events reach Type.

After the deploy, watch the first live runs with type-cli automations history --space <space> --automation <automation-id>.