Skip to content
Closed
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/timeline-stuck.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Timeline window now lists the requests that have been waiting longest — the open handoffs, worst first, with how long each has waited — so a stuck Bot-to-Bot request can be spotted instead of only counted. Read-only, part of the existing `timeline/window` answer.
2 changes: 1 addition & 1 deletion docs/subsystems/timeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Everything in `plugins/timeline/`: the recorder, the trace file, the read model
| `plugins/timeline/src/adapter.js` | The only file that knows the `ctx.flybot` shape. |
| `plugins/timeline/src/recorder.js` | Feed events to compact trace records; rebuilds every field from a strict alphabet. |
| `plugins/timeline/src/store.js` | The trace: single writer, write-tmp + fsync + rename, capped segments. |
| `plugins/timeline/src/window.js` | Pure read model: records to lanes, turns, tools, arrows, edges, utilization, the token spend per Bot (#357) and per-Bot outcomes and recent failures (#471). |
| `plugins/timeline/src/window.js` | Pure read model: records to lanes, turns, tools, arrows, edges, utilization, the token spend per Bot (#357), per-Bot outcomes and recent failures (#471) and the open requests waiting longest (#469). |
| `plugins/timeline/client.js` | Browser entry (`@flybot/timeline`): the 2 s poller exposed as `ctx.flybot.timeline`, the geometry functions (`layoutSwimlanes`, `layoutMap`, `waitRows`, `utilizationRows`) and the panel (swimlanes, who waits on whom, utilization), opened from its `flybot.sidebar.section` row, the only entry (not in the + menu, #269). |
| `plugins/timeline/src/sanitize.js` | The cleaners for ids, labels, codes, times, counts. |
| `plugins/timeline/src/otel.js` | OTLP export: maps trace records to OpenTelemetry GenAI spans (`spansFrom`, `otlpPayload`) and a cursor exporter (`createExporter`). Off unless `config.exporter` is set. |
Expand Down
10 changes: 9 additions & 1 deletion plugins/timeline/src/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,20 @@ export function buildWindow(records, { now = Date.now(), to, windowMs, bots = []
.slice(0, FAILED_KEPT)
.map(turn => ({ id: turn.id, bot: turn.bot, at: turn.t1, outcome: turn.outcome, ...(turn.errorCode ? { code: cleanCode(turn.errorCode) } : {}) }))

// ---- waiting too long (#469): the open requests, worst first, so a stuck handoff surfaces
const STUCK_KEPT = 20
const stuck = exchanges
.filter(arrow => arrow.waiting === true && Number.isFinite(arrow.t))
.map(arrow => ({ id: arrow.id, from: arrow.from, to: arrow.to, role: arrow.role, waitedMs: Math.max(0, now - arrow.t) }))
.sort((a, b) => b.waitedMs - a.waitedMs)
.slice(0, STUCK_KEPT)

return {
version: 1,
now, from: lo, to: hi, windowMs: windowMsActual, live,
coverage: { oldest: oldest ?? null, newest: last || null, complete: oldest !== undefined && oldest <= lo },
trace: stats ?? null,
truncated,
lanes, turns: shapedTurns, rounds, exchanges, utilization, edges, usage, outcomes, failures,
lanes, turns: shapedTurns, rounds, exchanges, utilization, edges, usage, outcomes, failures, stuck,
}
}
8 changes: 8 additions & 0 deletions plugins/timeline/test/window.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,11 @@ test('outcomes: per-Bot turn endings and the recent failures (#357/#471)', () =>
assert.deepEqual(win.outcomes.find(entry => entry.lane === 'b').aborted, 1)
assert.deepEqual(win.failures.map(f => [f.id, f.bot, f.outcome, f.code]), [['b#1', 'b', 'aborted', undefined], ['a#2', 'a', 'error', 'RATE_LIMIT']])
})

test('stuck: open requests are listed worst-first (#469)', () => {
const win = build()
assert.ok(win.stuck.length >= 1)
assert.ok(win.stuck.some(entry => entry.id === 'x3'), JSON.stringify(win.stuck))
assert.ok(win.stuck.every(entry => entry.waitedMs >= 0))
for (let i = 1; i < win.stuck.length; i += 1) assert.ok(win.stuck[i - 1].waitedMs >= win.stuck[i].waitedMs)
})
Loading