Skip to content
Workflow Agents

Workflow Agents

Create, test, publish and run a fixed JavaScript workflow through the console or API.

On this pageCreate in the consoleCreate and publish through the APIVersions and updatesProgram and toolsStreaming, failures and cancellationAPI referenceGenerate through the API

A Workflow Agent executes a saved JavaScript program directly. It accepts JSON input, streams progress and returns a JSON result. It has no outer model deciding what to do next. Your code can still call tools, including an MCP tool that calls another model.

Dynamic Workflow generates a temporary program during a Managed Agent conversation. A Workflow Agent is a separate, versioned resource with an explicit test and publication lifecycle.

Create in the console

Open Workflow Agents and select Create Workflow Agent.

  1. Describe the job and select Generate draft, or write JavaScript directly. Review the code, input schema and tool configuration. Rebyte's shared Workflow Builder Managed Agent generates code; generation is a platform-funded feature.
  2. Optionally preview unsaved code, then select Create draft to save version 1.
  3. Select Test version with example input. Inspect streamed progress and the final result. Testing uses real tools and can perform real actions.
  4. Select Publish version after the test succeeds. External API requests now execute this fixed version.
  5. Use Edit as new version to make changes. New drafts do not affect the published version. Test and publish the new version when ready.

A successful test covers the input you tested; it does not prove correctness for all inputs. Publication is organization-scoped, not public anonymous access. The API enforces the same test requirement as the console.

Create and publish through the API

Use an organization API key with tasks:read and tasks:write. The base is https://api.rebyte.ai/v1/workflow-agents. No Agents beta header is required. This API is separate from /v1/agents; existing SDK Agent methods do not create Workflow Agents. Use HTTP, as in this complete Node.js example:

js
const base = 'https://api.rebyte.ai/v1/workflow-agents';
const key = process.env.REBYTE_API_KEY;
if (!key) throw new Error('Set REBYTE_API_KEY');
async function post(path, body) {
  const response = await fetch(base + path, {
    method: 'POST',
    headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
  });
  const value = await response.json();
  if (!response.ok) throw new Error(JSON.stringify(value));
  return value;
}
const agent = await post('', {
  name: 'Order total',
  code: `async (input, emit) => {
    await emit({ phase: 'calculating' });
    return { total: input.quantity * input.price };
  }`,
  input_schema: {
    type: 'object',
    properties: { quantity: { type: 'number' }, price: { type: 'number' } },
    required: ['quantity', 'price'],
    additionalProperties: false,
  },
});
// agent.latest_version === 1; agent.published_version === null
const test = await post(`/${agent.id}/test`, {
  version: 1, input: { quantity: 3, price: 7 },
});
if (test.status !== 'completed' || test.result.total !== 21)
  throw new Error(JSON.stringify(test));
await post(`/${agent.id}/publish`, { version: 1, test_run_id: test.id });
const run = await post(`/${agent.id}/runs`, {
  input: { quantity: 4, price: 7 },
});
if (run.status !== 'completed') throw new Error(JSON.stringify(run));
console.log(agent.id, run.result); // { total: 28 }

The example creates a persistent Agent and two run records in your organization. Delete resources you no longer need using the endpoints below.

/runs defaults to published_version. An explicit version must have been published before. /test requires an explicit version and permits drafts. Unpublished execution returns 409 not_published. Publication requires a successful, non-deleted test of that exact Agent/version in the same organization. An unsaved /preview run does not satisfy that requirement.

Versions and updates

Source and execution configuration are immutable within a version. To create a new draft while retaining its private tool configuration:

http
POST /v1/workflow-agents/wfa_.../versions
Content-Type: application/json
Authorization: Bearer <organization-api-key>

{
  "base_version": 1,
  "code": "async input => ({total: input.quantity * input.price, currency: 'USD'})",
  "input_schema": {
    "type": "object",
    "properties": {"quantity": {"type": "number"}, "price": {"type": "number"}},
    "required": ["quantity", "price"],
    "additionalProperties": false
  }
}

Alternatively, submit a full definition to /versions with code, input_schema, tools, environment and vault_ids. Omitted configuration is initialized to empty tools/vaults and environment: {type: "none"}; it does not inherit. Public read responses omit connection secrets and private environment setup.

Test version 2, then publish it using its successful test run ID. Until that explicit publication, callers continue using version 1. To roll back, test and publish an earlier version. Existing runs retain the version selected when they started. Publication updates a pointer; it does not regenerate or execute code.

Program and tools

Use a function expression, normally async (input, emit) => { ... }. Return JSON-compatible data and use await emit(value) for progress. Input must match input_schema; validation does not coerce values or insert defaults. Admission checks source syntax; the isolated runtime determines whether it is callable and whether its logic succeeds. Invalid code is not automatically repaired or retried.

Every invocation uses a fresh Cloudflare V8 isolate. JavaScript cannot access Node.js, the filesystem, subprocesses or the network directly. The configured server tools are available as tools.NAME(arguments) through the same Tool Registry used by Managed Agents. Customer credentials stay in the service that owns the tool; they are not embedded in program source.

Supported tool configuration includes saved MCP servers, platform connections and web search. An openai_hosted environment exposes command, stdin, patch and image tools. Client-side functions and nested run_code are not supported here. Custom functions and calls to other language models can be exposed through MCP. For example, with a configured DeepWiki server:

js
async () => {
  await tools.search_tools({server: 'deepwiki', query: 'read_wiki_structure'});
  const result = await tools.call_tool({
    server: 'deepwiki', name: 'read_wiki_structure',
    arguments: {repoName: 'modelcontextprotocol/python-sdk'},
  });
  if (result.error !== null) throw new Error(JSON.stringify(result.error));
  return result.output;
}

Its tools entry is:

json
{"type":"mcp","server_label":"deepwiki","connection_origin":"service","required":true,"allowed_tools":["read_wiki_structure"],"transport":{"type":"http","server_url":"https://mcp.deepwiki.com/mcp"}}

The program has a 300-second execution limit, shared with its Redis authorization expiry. It allows 32 tool calls, 32,768 JavaScript source code units, 512 KiB JSON input/output and a 20 MiB execution stream. Preparation of MCP/environment resources has its own bounded deadline before program execution. Authority expires without being extended by tool calls, and is revoked when the run ends. Persistent definitions, versions and run history are product records; execution credentials and temporary call receipts live in Redis.

Streaming, failures and cancellation

Set stream: true on /test, /runs or /preview for Server-Sent Events. Events include workflow.run.created, .started, .output, .tool.started, .tool.completed, .tool.failed and terminal .completed, .failed, .cancelled. The terminal event carries run.status, run.result and run.error. Without streaming, the request waits and returns a run resource. A 201 response means a run was created: always inspect status for program success.

Run events are persisted. GET /runs/:runId/events?after=<sequence> replays and follows them; the sequence is also the SSE id:. Disconnecting the original execution request cancels the run. Disconnecting an event-only subscription does not. You can also POST {} to /runs/:runId/cancel. Cancellation does not undo completed tool side effects.

Use Idempotency-Key on preview, test and execution requests. An identical retry returns the original run without executing the program again, even if the default published version changed. A conflicting or deleted run key returns 409. Tool providers are not guaranteed exactly-once side effects.

This release has no durable JavaScript continuation or automatic replay after a service restart. A later read marks an expired active run failed. To retry a failed run deliberately, use a new request/key and consider any completed actions.

API reference

All paths below are relative to /v1/workflow-agents.

MethodPathPurpose
POST/Create Agent and draft version 1
GET/List Agents; limit, after
GET / DELETE/:idRead / delete Agent
POST/:id/versionsAppend an immutable draft
GET/:id/versionsList versions; limit, before
GET/:id/versions/:versionRead a version
POST/:id/testTest {version, input, stream?}
POST/:id/publishPublish {version, test_run_id}
POST/:id/runsExecute {input, version?, stream?}
POST/previewExecute an unsaved definition plus input, stream?
POST/generateGenerate or revise a draft
GET/runsList runs; limit, after
GET / DELETE/runs/:runIdRead / delete a terminal run and its environment
GET/runs/:runId/eventsReplay/follow events; after sequence
POST/runs/:runId/cancelCancel with {}

Deleting an Agent prevents new use; existing run records remain. Explicitly delete terminal runs to clean up their tool environments. Agent and run access is organization-scoped. UI management requires organization administrator access.

Generate through the API

POST /generate with prompt and optional tools, environment, vault_ids. The non-streaming response is {draft: {name, summary, code, input_schema, input}}. For revision include that draft and optionally preview_error. With stream: true, events are generation.started, .delta, .completed; errors use an error event. Generation does not execute customer tools or publish.

Rebyte's official Managed Agent owns generation Sessions and model charges. Saved Workflow Agents, tests and execution belong to your organization. The Agent receives tool descriptions rather than connection credentials. No authoring service API key is exposed to the client.