Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3282.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A workflow start the host could not finish saying had one sentence — "the host did not create the run Bots within 60s" — with no node and no reason, so a lane whose node Bots were simply slower than the deadline looked like a silent hang and the same task was dispatched three times; the refusal now names the node the host never answered, the Bots it did create with how long each took, and, when the lane's node count no longer fits the deadline at that host's speed, the seconds it needs (a six-node line at about eleven seconds per Bot reads "needs about 66s … past the 60s deadline"), while a node Bot the host refuses carries the node and the host's own reason — an unavailable model, a taken Bot name, a full tree, or the host's error text — and `workflow/assign` reports a refused start as a failed answer (`ok: false` with `error.code` `bot/refused` and `error.details` naming the node) instead of a value inside the success envelope, so a caller cannot mistake a failed dispatch for a started run ([#3282](https://github.com/ThinkFlowLab/FlyBot/issues/3282)).
2 changes: 1 addition & 1 deletion docs/subsystems/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Everything in `plugins/workflow/`: the graph rules, the run store, the matcher,
| --- | --- |
| `plugins/workflow/index.js` | Plugin entry (`flybot-workflow`). Endpoints, `run_workflow`, `define_workflow`, the board listener, and the reply middleware that ingests a step result and denies delivery to persistent Bot chats. |
| `plugins/workflow/src/graph.js` | Nodes, edges, positions, and named inputs and outputs. A node starts when its forward predecessors are settled and a taken edge reaches it. Same-rank nodes run together. A forward cycle is refused. A loop edge is the only cycle for success paths. A `when` edge chooses a branch; the other is skipped. A required input with no upstream provider is refused before a run starts. An `onFail` edge provides failure recovery: when a node fails with recoveries remaining, the workflow resets the body from the upstream target through the failing node and re-runs it in order (tracked by `failAttempts` per edge, with `max` counting recoveries, 1–8, default 3). After the recoveries are used, the node fails permanently. |
| `plugins/workflow/src/service.js` | The store, lanes (active runs, FIFO queue, terminal history), `maxConcurrent`, `rename`, `delete`, `saveGraph`, `define`, `runNamed`, `ingest`, `stepResult`. `rename` updates a workflow's name and optional description; `delete` removes the workflow, releases ephemeral Bots, and cleans logs/runs/routes and the task claims that named it — a claim is judged on its own record (`kind === 'workflow'` and that id), not by the route map, which its own cleanup has already emptied (#1632); a run Bot whose release failed is kept in the store's own `orphans` list — not in a variable — and the load-time `reap` retries it, once per id, capped, so deleting a workflow whose Bot will not go does not strand that Bot under a name nothing can reach (the #1616 contract). Factory template ids (e.g. `delivery`) are normal saved rows and may be deleted. A spawn hook makes one run Bot per node. Disposing the plugin ends every live run still marked `running` (nodes in flight are failed, the run is archived) and then releases every run Bot and drops those ids from the saved record only once the release has finished, handing the release back as a promise the host awaits, so a shutdown cannot persist a run as `running` with no ephemeral map and cannot leave hidden Bots that no state names, for every live run in a lane rather than only the one archived last (#1387, #1414, #1472). A released run Bot also gives its runner name back to the allocator instead of keeping it for the lifetime of the process. A dispatch that does not land is not marked handed: it is retried twice with a short backoff, and a step still unanswered after its workflow's `stepTimeoutMinutes` (45 minutes by default) fails the run and releases its Bots (#1530, #1580). A stored claim keeps a task only while the card names nothing new: when the card's own fields name another live workflow or Bot, the claim and its route are dropped and the card is matched again, and `rematch: true` on `ingest` drops that one claim first (#1647). `workflow/state` carries, per workflow, the ids it holds — `heldTasks`, a page of 20 sorted ids beside the whole `heldTaskCount` — and a Bot claim is not listed there (#1647); the read takes a `heldLimit` — 20 by default and 200 at most, read through `Number()` and kept only when it is a positive integer, so `'10'` reads 10 and `true` reads 1 while `0`, `-5`, `3.5`, `'many'` and `null` fall back to 20 — so a reader can ask for the rest of the page without turning the poll into a full read (#2256, #2260). Each public run also carries `finishedAt` (`null` while the run is live, else the moment it ended) and `currentStep` (`{ id, name }` of the node it walks now, else `null`) — pure additions for the Inbox, which reads them off `workflow/state` (#1706); a paused run keeps `status: 'running'` with `paused: true`, so it is not finished and still names its node. An assignment carries its instruction: `assign` reads `brief` — multi-line, up to 8000 characters, kept whole rather than flattened into the 300-character title — onto `task.brief`, and resolves it from the card first: a call that omits `brief` keeps the card's stored facts, a call that passes one stores it on a card that has none, and re-dispatching the same card to another workflow keeps the same facts, records `task.handoff` `{from, to, at, reason}` naming the lane it moved from and to, and hands the next node the stored facts (a brief input in `resolveInputs` falls back to the title only when the card has none; #2468). A call that passes `brief` is the latest word — `brief: ''` clears the card's facts instead of falling back to the cached ones — and deleting a lane drops the facts it cached, so a later dispatch records no handoff from a lane that no longer exists (#2475). It, a parked card keeps it in `workflow/state` and in `workflows.json`, and `stepBody` hands the node `task.brief`, falling back to the title only when there is none; before #1869 the node received the title twice and the brief never. `runNamed` gives a brief the same meaning and derives the title from its first line, and a field `assign` does not read comes back in `ignored` instead of disappearing (#1869). A call that omits `task` generates a random `task-<hex>` id (`idOf`), so two `run_workflow` calls in one millisecond start two runs instead of the second being answered `already: true` against the first one's id and losing its brief; an explicitly repeated `task` is still de-duplicated (#2662). A store whose `version` is higher than the `STORE_VERSION` (1) this build writes was written by a newer FlyBot, and is neither read as a store nor written over ([#2681](https://github.com/ThinkFlowLab/FlyBot/issues/2681)): `workflow/state` answers `ok: false` with `code: 'store-newer-version'`, the file and the version it carries, instead of the fixture list, and every write is refused before its first byte, so `workflows.json` stays byte-identical and no `.broken-<stamp>` copy is made — that copy belongs to a store this build is about to replace ([#2603](https://github.com/ThinkFlowLab/FlyBot/issues/2603)). A store at this build's version, one below it, or one that does not parse keeps the #2603 answer (`store-unreadable`, the fixture for every other endpoint, the bytes kept aside on the first write). |
| `plugins/workflow/src/service.js` | The store, lanes (active runs, FIFO queue, terminal history), `maxConcurrent`, `rename`, `delete`, `saveGraph`, `define`, `runNamed`, `ingest`, `stepResult`. `rename` updates a workflow's name and optional description; `delete` removes the workflow, releases ephemeral Bots, and cleans logs/runs/routes and the task claims that named it — a claim is judged on its own record (`kind === 'workflow'` and that id), not by the route map, which its own cleanup has already emptied (#1632); a run Bot whose release failed is kept in the store's own `orphans` list — not in a variable — and the load-time `reap` retries it, once per id, capped, so deleting a workflow whose Bot will not go does not strand that Bot under a name nothing can reach (the #1616 contract). Factory template ids (e.g. `delivery`) are normal saved rows and may be deleted. A spawn hook makes one run Bot per node. Disposing the plugin ends every live run still marked `running` (nodes in flight are failed, the run is archived) and then releases every run Bot and drops those ids from the saved record only once the release has finished, handing the release back as a promise the host awaits, so a shutdown cannot persist a run as `running` with no ephemeral map and cannot leave hidden Bots that no state names, for every live run in a lane rather than only the one archived last (#1387, #1414, #1472). A released run Bot also gives its runner name back to the allocator instead of keeping it for the lifetime of the process. A refused start also says where it was: the deadline sentence names the node the host never answered, the Bots it did create and how long each took, and — when the lane's node count no longer fits the deadline at that host's speed — the seconds it needs, so a six-node line on a host that spends about eleven seconds per Bot reads `a lane of 6 nodes needs about 66s on this host at 11.0s per Bot, past the 60s deadline` instead of a bare timeout; a node Bot the host refuses carries the node and the host's own reason (an unavailable model, a taken Bot name, a full tree, or the host's error text) on the sentence and, for a machine reader, as `nodeId`/`reason` (#3282). `workflow/assign` reports a refused start the way the Bots API can: the endpoint throws, so `api/bot` answers `{ ok: false, error: { code: 'bot/refused', message, details: { workflowId, taskId, nodeId, nodeName, reason } } }` instead of `{ ok: true, value: { ok: false } }`, and the canvas reads that refusal through `settledCall`; `assign()` itself keeps its `{ ok: false }` answer for the in-process callers — the drain, `ingest`, `runNamed` and the tools (#3282). A dispatch that does not land is not marked handed: it is retried twice with a short backoff, and a step still unanswered after its workflow's `stepTimeoutMinutes` (45 minutes by default) fails the run and releases its Bots (#1530, #1580). A stored claim keeps a task only while the card names nothing new: when the card's own fields name another live workflow or Bot, the claim and its route are dropped and the card is matched again, and `rematch: true` on `ingest` drops that one claim first (#1647). `workflow/state` carries, per workflow, the ids it holds — `heldTasks`, a page of 20 sorted ids beside the whole `heldTaskCount` — and a Bot claim is not listed there (#1647); the read takes a `heldLimit` — 20 by default and 200 at most, read through `Number()` and kept only when it is a positive integer, so `'10'` reads 10 and `true` reads 1 while `0`, `-5`, `3.5`, `'many'` and `null` fall back to 20 — so a reader can ask for the rest of the page without turning the poll into a full read (#2256, #2260). Each public run also carries `finishedAt` (`null` while the run is live, else the moment it ended) and `currentStep` (`{ id, name }` of the node it walks now, else `null`) — pure additions for the Inbox, which reads them off `workflow/state` (#1706); a paused run keeps `status: 'running'` with `paused: true`, so it is not finished and still names its node. An assignment carries its instruction: `assign` reads `brief` — multi-line, up to 8000 characters, kept whole rather than flattened into the 300-character title — onto `task.brief`, and resolves it from the card first: a call that omits `brief` keeps the card's stored facts, a call that passes one stores it on a card that has none, and re-dispatching the same card to another workflow keeps the same facts, records `task.handoff` `{from, to, at, reason}` naming the lane it moved from and to, and hands the next node the stored facts (a brief input in `resolveInputs` falls back to the title only when the card has none; #2468). A call that passes `brief` is the latest word — `brief: ''` clears the card's facts instead of falling back to the cached ones — and deleting a lane drops the facts it cached, so a later dispatch records no handoff from a lane that no longer exists (#2475). It, a parked card keeps it in `workflow/state` and in `workflows.json`, and `stepBody` hands the node `task.brief`, falling back to the title only when there is none; before #1869 the node received the title twice and the brief never. `runNamed` gives a brief the same meaning and derives the title from its first line, and a field `assign` does not read comes back in `ignored` instead of disappearing (#1869). A call that omits `task` generates a random `task-<hex>` id (`idOf`), so two `run_workflow` calls in one millisecond start two runs instead of the second being answered `already: true` against the first one's id and losing its brief; an explicitly repeated `task` is still de-duplicated (#2662). A store whose `version` is higher than the `STORE_VERSION` (1) this build writes was written by a newer FlyBot, and is neither read as a store nor written over ([#2681](https://github.com/ThinkFlowLab/FlyBot/issues/2681)): `workflow/state` answers `ok: false` with `code: 'store-newer-version'`, the file and the version it carries, instead of the fixture list, and every write is refused before its first byte, so `workflows.json` stays byte-identical and no `.broken-<stamp>` copy is made — that copy belongs to a store this build is about to replace ([#2603](https://github.com/ThinkFlowLab/FlyBot/issues/2603)). A store at this build's version, one below it, or one that does not parse keeps the #2603 answer (`store-unreadable`, the fixture for every other endpoint, the bytes kept aside on the first write). |
| `plugins/workflow/src/ephemeral.js` | Builds each node's run Bot from its prompt, role, model and tools, and releases the ids the host returns. `node.tools` names the connectors that node may call: `spawn` passes the cleaned list to `fb.bot.create`, the host records it as `stepTools`, and `connector-access.js` allows only the connectors it names (`github` covers `mcp__github__*`, `composio` covers `mcp__composio__*`) — a node that names none reaches none. File and shell rights do not come from that list: every node Bot gets the `danger-full-access` preset a normal sidebar Bot has, and `EPHEMERAL_DENIED_TOOLS` still refuses the team tools at the guard and approval layers. The list is also stored in `fields.tools` for the UI. |
| `plugins/workflow/src/match.js` | Which open card matches a Workflow or a local Bot. |
| `plugins/workflow/src/template.js` | Factory delivery/weekly graphs plus `EARLY_END_GUIDANCE` for Claim/Verify/Triage early-end markers; 发布交付流水线 (a parallel branch) and the weekly report, each node with the inputs and outputs that edge carries. |
Expand Down
11 changes: 9 additions & 2 deletions plugins/workflow/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ window.__ModuleLoader__.load({
// silently either. Same shape as readWorkflows()/workflowCallError() in
// core/src/client/workflows.js, kept here because this page reads the plugin's own calls.
const CALL_TIMEOUT_MS = 10000
// A start waits for its node Bots before it answers, and the host refuses it at its own
// 60 s deadline (`SPAWN_DEADLINE_MS`), so cutting the call at 10 s would report a failure
// for a dispatch that then starts (#3282).
const ASSIGN_TIMEOUT_MS = 70000
function callError(failure, fallback) {
if (typeof failure === 'string' && failure.trim()) return failure.trim()
const message = typeof failure?.message === 'string' ? failure.message.trim() : ''
Expand Down Expand Up @@ -2284,7 +2288,10 @@ window.__ModuleLoader__.load({
setError('')
if (String(target).startsWith('bot:')) {
const botId = String(target).slice(4)
const value = await call('workflow/assign', { botId, taskId: task.id, title: task.title })
// #3282: the host reports a refused start as a failed answer (`ok: false`), which
// `call()` throws, so this dialog reads it through `settledCall` — the same
// `{ ok: false, error }` it already knows how to show.
const value = await settledCall(call, 'workflow/assign', { botId, taskId: task.id, title: task.title }, 'Could not assign this task', ASSIGN_TIMEOUT_MS)
if (value?.ok === false) { setError(value.error ?? ''); return }
const host = globalThis.__flybot__?.host
if (typeof host === 'function') {
Expand All @@ -2299,7 +2306,7 @@ window.__ModuleLoader__.load({
// #2495: hand the card's own facts over, and say so explicitly even when it holds none —
// an omitted `brief` keeps whatever an earlier call cached under this task id.
const brief = typeof task.brief === 'string' ? task.brief : ''
const value = await call('workflow/assign', { workflowId: target, taskId: task.id, title: task.title, brief })
const value = await settledCall(call, 'workflow/assign', { workflowId: target, taskId: task.id, title: task.title, brief }, 'Could not assign this task', ASSIGN_TIMEOUT_MS)
if (value?.ok === false) { setError(value.error ?? ''); return }
setPack(value)
setOpenId(target)
Expand Down
5 changes: 4 additions & 1 deletion plugins/workflow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@
fb.api.handle('workflow/create', body => service.create(body)),
fb.api.handle('workflow/rename', body => service.rename(body)),
fb.api.handle('workflow/delete', body => service.delete(body)),
fb.api.handle('workflow/assign', body => service.assign(body)),
// #3282: a refused start throws, so the Bots API reports it as `{ ok: false, error }` instead
// of putting `{ ok: false }` inside the success envelope a caller reads first (service.js
// `assignEndpoint`). Every other endpoint keeps answering its value.
fb.api.handle('workflow/assign', body => service.assignEndpoint(body)),
fb.api.handle('workflow/concurrency', body => service.setConcurrency(body)),
fb.api.handle('workflow/step-timeout', body => service.setStepTimeout(body)),
fb.api.handle('workflow/set-model', body => service.setModel(body)),
Expand All @@ -165,7 +168,7 @@
task: { type: 'string', description: 'Task id, such as #1280. Omitted ids are generated.' },
},
// fb.tools.register hands the calling Bot to execute() as the second argument's botId (#1544).
execute: (args, ctx) => service.runNamed({ ...(args ?? {}), ...(ctx?.botId ? { callerBotId: ctx.botId } : {}) }),

Check warning on line 171 in plugins/workflow/index.js

View workflow job for this annotation

GitHub Actions / plugins (workflow)

unicorn(no-useless-fallback-in-spread)

Empty fallbacks in spreads are unnecessary
}))
offs.push(fb.tools.register({
name: 'define_workflow',
Expand All @@ -177,7 +180,7 @@
edges: { type: 'array', required: true, description: 'Hand-offs { from, to }. A fork is two edges out; a join is two edges in. A condition is when: { output, eq } or { else: true }. A loop is loop: true with max (1–8, default 3) and optional until: { output, eq }.' },
stepTimeoutMinutes: { type: 'number', description: 'How long one step may wait for its Bot before the run fails, 1–120. Omit for the 45-minute default.' },
},
execute: (args, ctx) => service.define({ ...(args ?? {}), ...(ctx?.botId ? { callerBotId: ctx.botId } : {}) }),

Check warning on line 183 in plugins/workflow/index.js

View workflow job for this annotation

GitHub Actions / plugins (workflow)

unicorn(no-useless-fallback-in-spread)

Empty fallbacks in spreads are unnecessary
}))
}
if (typeof fb.bot?.send?.use === 'function') {
Expand Down
Loading
Loading