Workflows
A workflow groups the steps of an app that makes several kinds of model call: one agent and one key per step. A workflow only groups and observes; it never blocks a call.
Why one key per app is a problem
When one agent credential serves a whole app:
- One model serves every call. The agent's configured model serves every call made with its key, whatever model the call asks for.
- The hardest step blocks savings. Routing doesn't recommend a cheaper model if any kind of task would get worse, so one hard step vetoes a cheaper model for all of them.
- Evidence is pooled. The routing window, recommendation, canary and budget cover the whole agent, so a regression in one step is averaged away.
With one agent per step, each step is judged, approved, canaried and budgeted on its own.
When to split a step
Give a step its own agent and key when it:
- needs a different model from the other steps;
- is a different kind of work, for example grading versus drafting;
- makes roughly 200 or more calls per routing window, enough for a confident recommendation.
Keep small steps that share a model and kind of work on one agent. A step with a handful of calls never gets a confident recommendation.
Register a workflow
Each method creates the workflow, one agent per step, and the edges between steps in one go. If any part fails, nothing is created.
Console
The console's Workflows tab and registration form require workflows to be
enabled in the deployment. For self-hosting, build the console with
NEXT_PUBLIC_WORKFLOWS_ENABLED=true; it defaults to off. The REST and SDK
workflow APIs remain available under their normal permissions.
Open the register form
Go to Agents and choose Register workflow, on the Workflows tab or beside Register agent on the Inventory.
Name it and pick the owner
The owner is accountable for every new step's agent.
Add the steps
For each step choose New agent (a step name and a model) or Existing agent (pick one from your inventory; it keeps its model, key, budget and routing history). A new agent's budget and token cap are under Budget and limits.
Connect them
Under Connections, say which step comes next: then when your app calls one step after another, sends tasks to when one agent hands work to another. The sentence under the list reads the flow back.
Create it and copy the keys
Choose Create workflow. Keys are shown once, and only for new agents.
Workflows are listed under the Workflows tab. A workflow's page shows this month's spend and calls, the Flow of its steps, each step's routing state in plain words with a link to review it, the Connections between steps and how often each was seen, and Health checks with their fixes.
The Flow draws chains, branches, hand-back loops and full teams the same way: callers first (left to right when it fits, top to bottom when it does not), one line for each pair of steps, a curve for a line that goes back. It opens on the connections that were Used, counted one way each, and tells you how many allowed ones are hidden, with Show them to draw them dashed. Point at a step or tab to it and its connections stay strong while the rest fade; the panel under the flow says who it calls and who calls it.
The flow's cards can be dragged. The arrangement is saved for the whole workspace (per workflow and environment, and per environment on the Graph tab), so everyone sees the same picture, and lines follow the cards. With a card focused, Shift and an arrow key move it. Reset layout returns the automatic layout. Dragging needs permission to edit agents; without it you still see the saved arrangement. On a phone the steps stack and the arrangement is not used.
REST
POST /v1/workflows:
{
"name": "Question paper",
"slug": "question-paper",
"owner_identity_id": "<identity uuid>",
"steps": [
{"name": "grading", "model": "mock-gpt"},
{"name": "retry", "model": "mock-gpt"}
],
"edges": [{"from": "grading", "to": "retry", "kind": "sequence"}],
"issue_credential": true
}The response has the workflow and one credential per step. Keys are shown
once. Set issue_credential to false to register the agents without keys
and claim them later. A step can also set
allowed_models, description and monthly_budget_usd. A workflow has at
most 25 steps and 100 edges.
To use an agent you already have, give the step agent_id instead of model:
"steps": [
{"agent_id": "<existing agent id>", "name": "grading"},
{"name": "retry", "model": "mock-gpt"}
]Attaching never issues or rotates a key: that step's credential is null and
the agent's existing key keeps working. The step name defaults to the agent's
name. You must own the agent or be an admin, and it can't be retired or already
in another workflow. An attached agent's spend and routing evidence include any
traffic it serves outside the workflow.
| Endpoint | What it does |
|---|---|
GET /v1/workflows | List workflows with step count, month spend and calls. |
GET /v1/workflows/{slug} | One workflow: steps, routing status, spend, declared and observed edges. |
PATCH /v1/workflows/{slug} | Rename or re-describe it. |
DELETE /v1/workflows/{slug} | Archive it. Every agent, key and binding stays as it was. |
POST /v1/workflows/{slug}/steps | Add a step: register a new agent, or attach an existing one by agent_id. |
DELETE /v1/workflows/{slug}/steps/{step} | Detach a step. Its agent and bindings stay as they were. |
POST /v1/workflows/{slug}/edges | Declare an edge. |
DELETE /v1/workflows/{slug}/edges/{edge_id} | Remove an edge. |
GET /v1/workflows/{slug}/checks | Is it wired, threaded and seeing traffic? See Checks. |
MCP
Plan
forgebench_workflowswithaction: registerreturns a change plan without creating anything.Apply
Apply the plan with
forgebench_apply_plan. Each new step's agent is created without a key; a step withagent_idattaches an existing agent and keeps its key. A plan with task edges, or with more agents than your workspace allows in one apply, needs confirming in the console.Claim the keys
Claim each step's key with
forgebench_agentsissue_credential. The key is revealed once, in the browser.Wire and verify
forgebench_integratewithaction: workflowgives per-step code.forgebench_integratewithaction: verifyandworkflowset checks the wiring.
See Forgebench MCP for connecting the server.
SDKs
The Python, TypeScript and Java SDKs register workflows and run them with one key per step:
created = client.workflows.register(
name="Question paper",
owner_identity_id=client.whoami().identity_id,
steps=[{"name": "grading", "model": "mock-gpt"},
{"name": "retry", "model": "mock-gpt"}],
edges=[{"from": "grading", "to": "retry", "kind": "sequence"}],
)
# An attached step's credential is None: use the key that agent already has.
keys = {c["step"]: c["credential"]["api_key"] for c in created["credentials"] if c["credential"]}
with client.workflow("question-paper", keys=keys).run() as run:
run.step("grading").chat(model="mock-gpt", messages=[...])
run.step("retry").chat(model="mock-gpt", messages=[...]) # parent = grading's callconst run = forgebench.workflow("question-paper", keys).run();
await run.step("grading").chat({ model: "mock-gpt", messages });
await run.step("retry").chat({ model: "mock-gpt", messages }); // parent = grading's callWorkflow.Run run = client.workflow("question-paper", Map.of("grading", keyA, "retry", keyB)).run();
run.step("grading").chat(request);
run.step("retry").chat(request); // parent = grading's callOWNER=$(curl -s https://api.forgebench.ai/v1/auth/whoami \
-H "Authorization: Bearer $FORGEBENCH_API_KEY" | jq -r .identity_id)
CREATED=$(curl -s -X POST https://api.forgebench.ai/v1/workflows \
-H "Authorization: Bearer $FORGEBENCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Question paper",
"owner_identity_id": "'"$OWNER"'",
"steps": [{"name": "grading", "model": "mock-gpt"},
{"name": "retry", "model": "mock-gpt"}],
"edges": [{"from": "grading", "to": "retry", "kind": "sequence"}]
}')
GRADING_KEY=$(echo "$CREATED" | jq -r '.credentials[] | select(.step == "grading") | .credential.api_key')
RETRY_KEY=$(echo "$CREATED" | jq -r '.credentials[] | select(.step == "retry") | .credential.api_key')
# Each step calls with its own key; the first call of a run is its root.
CALL_ID=$(curl -s -X POST https://api.forgebench.ai/v1/chat/completions \
-H "Authorization: Bearer $GRADING_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "mock-gpt", "messages": [{"role": "user", "content": "..."}]}' | jq -r .call_id)
curl -s -X POST https://api.forgebench.ai/v1/chat/completions \
-H "Authorization: Bearer $RETRY_KEY" \
-H "X-Parent-Call: $CALL_ID" \
-H "Content-Type: application/json" \
-d '{"model": "mock-gpt", "messages": [{"role": "user", "content": "..."}]}' # parent = grading's callEach step call uses that step's own key and sends the previous call's id as
X-Parent-Call. The first call of a run is its root. The Java helper covers
chat completions only, not streaming. See the
Python, TypeScript
and Java SDK pages for more.
Edges: sequence and task
An edge records how two steps relate. ForgeBench does not execute the app's sequence or pass data between steps. Your application does that work.
sequence: the app runs step A, then step B, and passes A's call id to B. Forgebench checks this against the lineage it observes.task: agent A sends tasks to agent B (agent-to-agent). This creates an agent-to-agent binding. It is approved immediately when the granting person can approve for the callee, and pending otherwise. The binding governs task calls even though the workflow grouping adds no gate.
Removing a task edge or detaching a step keeps the binding. To revoke it too,
pass revoke_binding=true on DELETE /v1/workflows/{slug}/edges/{edge_id}.
Lineage
- Every governed response returns
call_idin the body, andX-Call-Idas a header. A stream gets it from the header. - Send that id as
X-Parent-Callon the next call. - Forgebench records the call's parent and the root of its run.
Lineage is self-reported by the caller and not verified. Use it to see the shape of a run, not to audit who did what. See Call lineage.
To see lineage on the agent graph, call
GET /v1/agents/graph?include_lineage=true. Add workflow=<slug> to limit it
to one workflow.
Routing per step
A workflow adds no routing of its own: each step is an ordinary agent, routed like any other.
- Every call with the step's key is served the step agent's model.
- A shadow-routing watch on the step replays samples of its real traffic on cheaper models and judges the answers.
- If a cheaper model is as good for every kind of task the step handles, the step gets a recommendation with its monthly saving.
- The owner approves it on the step's routing page; the new model goes live on a canary and reverts on its own if quality drops.
The split is what helps: a cheaper model for an easy step no longer waits on the hardest one. The workflow page adds up spend, calls and savings across steps, but never pools their evidence. A model change only happens after approval, for the whole step at once, so a step that runs a multi-turn tool loop never switches model mid-session.
Environments
A workflow can run in dev, staging and prod, with separate steps, connections, keys and routing in each. See Environments. Pro and Enterprise only.
Discover an existing workflow
The Workflows view can suggest groups from scanned code and observed traffic.
Accepting a suggestion attaches the existing agents as steps without creating
agents or keys. Dismissing it keeps that suggestion hidden. The REST routes are
GET /v1/workflows/suggestions and
POST /v1/workflows/suggestions/{fingerprint}/accept or /dismiss.
Viewing workflows uses Agents read permission. Registration and edits use Agents write permission and ownership checks. An agent can be attached to only one live workflow. Archiving releases its steps and preserves agents, credentials, and task bindings.
One live key per agent
Claiming or issuing a key on an agent that already has one rotates it: the old key stops working. For a second caller, create a second agent.
Checks
GET /v1/workflows/{slug}/checks (or forgebench_workflows with
action: checks, or workflows.checks in the SDKs) reports whether the
workflow is wired, threaded and seeing traffic:
| Check | Level | Meaning | What to do |
|---|---|---|---|
edge_refused | fail | A task in the last 30 days was refused for lack of a live binding. | Approve the pending binding, or declare the task edge so the binding is created. |
edge_unused_30d | warn | A declared edge saw no traffic in 30 days. | Remove the edge if the flow changed. Otherwise check the caller sends X-Parent-Call or opens tasks. |
lineage_missing | warn | Both steps of a sequence edge have traffic, but the second step's calls carry no X-Parent-Call from the first. | Pass the previous call's call_id as X-Parent-Call. |
step_no_traffic | warn | A step made no calls in 7 days. | Send a call with that step's key, or detach the step. |
step_too_small | warn | A step has fewer than 200 calls in 30 days, so its routing verdict is low-confidence. | Wait for traffic before acting on that step's recommendation, or merge it with a sibling. |

