Engineering · November 2026

How Fibo knows an agent is waiting for you, without changing the agent

When Claude Code or Codex stops on an approval prompt, it tells nobody. Session logs, hooks, the screen, program reports and processes each have blind spots, and any one alone gets some cases wrong. Fibo layers all five onto one session card in a fixed order, decides the state in one place, core’s status::of, and keeps it there with a test that counts every other place trying to decide it.

What Fibo is: a native, open-source (MIT) workbench for coding agents such as Claude Code and Codex. Agents run in real terminals Fibo opens, and Fibo shows in the sidebar, the board, the menu bar and on your phone which session is waiting for you. Install: download the DMG, or brew install --cask majiayu000/tap/fibo.

01 The problem: there is no API for "waiting on you"

With five or six agents open at once, most of the time goes into flipping through tabs to see who is stuck on an approval prompt and who has already finished. For a workbench to watch them for you, it has to know what each session is doing right now.

Agent CLIs have no interface for this. Claude Code and Codex do not tell other programs "I am sitting on an approval prompt", and Fibo does not change their model or loop; it runs them as they are, in a real terminal (PTY). All it can use are the traces they leave anyway: session logs on disk, hooks the user may choose to install, the text drawn in the terminal, escape sequences a program prints, and processes in the operating system.

Fibo gives every session one of 10 states. Their words, glyphs and grouping are defined once, by Status in crates/fibo-core/src/status.rs, and spelled nowhere else:

StateWhenNeeds youSounds
◐ RunningA turn is under way, or it ended while a background job or subagent still works for itnono
◆ Waiting for youAn approval, a question or a plan confirmation is on screenyesyes
✕ ErrorThe turn failed, or the terminal's process exited non-zeroyesyes
◇ Ready for reviewThe turn ended; whether the work is done is yours to judgeyesno
◔ In backgroundThe turn ended and only a scheduled wakeup or a monitor is left, which will wake it lateryesno
○ NewAn agent is open and has not started a turnnono
‖ StoppedYou interrupted it, or the agent left without finishingnono
◷ SnoozedYou snoozed it until a set timenono
· IdleUntouched past the configured number of daysnono
✓ DoneYou marked it complete or abandoned itnono

"Needs you" is a group of states: Waiting for you, Error, Ready for review and In background (Status::needs_you). Only the first two play a sound and color the counter orange or red (Status::blocked), because the agent cannot continue without you. This was settled on 11-03; before that the sidebar counted four states while the top bar and the board counted two, so the same moment could read "Needs you 5" and "Needs you 2".

02 Five sources, each with blind spots

The background host, fibo serve, owns every terminal and collects five kinds of evidence for each session. Each one alone gets some cases wrong, so it uses all five.

SourceWhat it seesHow fastWhere it is reliableWhen it fails
Session log
jsonl under ~/.claude, Codex's logs, etc.
A turn starting, ending, being interrupted; what was said and which tools ran. All chat content comes from hereRead when the file changesThe CLI's own record: an end or an interruption written there is a factSome things are written only after you answer: Claude's question dialog is absent from the log until then. Reading only the tail of a long session misses the start of the current turn
Hooks
optional; 6 events for Claude
UserPromptSubmit starts a turn, PermissionRequest and Notification wait, Stop ends it and lists background shellsWhen the event happensKnows about approvals and questions before the log does; Stop carries the background task listNothing at all on machines without hooks; another process that inherited the terminal's environment can send hooks too (see 06)
Screen
terminal contents and title
The approval, choice or plan menu on screen now; a spinner in the title, a timer line in the outputRead once the screen has been quiet for 1 s; while output flows, checked every second for the timer lineThe only source that knows "now" when the log lagsA CLI that changes its wording or layout is no longer recognized; narrow windows wrap a question onto two lines (see 06)
Program report
OSC 7501
A program says working, blocked, done or error with one escape sequenceAs soon as it printsThe program's own word, not a guessNeeds the program to print it; scripts and builds get it with one printf
Processes
process tree, listening ports
Whether shells left after a turn are still alive and whether they listen on a portEvery 5 sTells jobs that will end from servers that will notOnly indirect: it reads ports and age, not what a command means (see 05)

Two more signals only settle dialogs: Claude's claude agents --json and the read-only status interface of Codex's shared daemon. The code notes they can lag both the log and the hooks, so they may end or confirm a wait but never start or end a turn (official in content/mod.rs).

Hooks must not slow the agent down either. The command Fibo writes into settings.json reads stdin into a variable, hands it to fibo hook in the background and exits 0 at once; its 5-second timeout only bounds a stuck shell. Outside a Fibo terminal (the environment variable Fibo sets is missing) the command exits immediately and the CLI is unaffected.

03 Layering order: whose word counts

The five sources do not each reach a verdict. They are layered onto one session card (Content), which records the turn's phase (turn), what is left in the background (background) and what it waits on (waiting). The log and hooks feed the same parser and form the base; each time the host sends the workspace to the window and phones, it layers runtime observations on top in a fixed order (overlay in host/snapshot.rs).

Session log start, end, interrupt, what was said Hooks start, approval, question, end + shells Base: the session card, Content turn · background · waiting · signal 1 Processes: background shells split into jobs and servers A job (tests, a build) keeps an ended turn running; a server does not 2 Spinning title, timer line on screen Can only turn "not running" into "running", and only if first seen after the recorded end 3 Approval, choice or plan menu on screen Waiting for you before the log catches up, marked as read from the screen 4 Program report, OSC 7501 The program's own word outranks every guess above (idle, working start no turn) status::of: the only place a state is decided plus your decisions: marked done, snoozed sidebar · panes · board · menu bar · phone cards · fibo list · plugin events all read this one result
Layering order; later steps outrank earlier ones. Steps 2 and 3 only move a session toward "busier" or "waiting"; step 4 is the program's own word. The order lives in host/snapshot.rs, the decision in fibo-core/src/status.rs.

Three principles sit behind the order:

After layering, a single function decides. This is the branch for a live session (simplified, parameter types left out):

fn live(w, s, c, now) -> Status {
    match turn {
        Turn::Waiting => return Status::Waiting,
        Turn::Running => return Status::Running,
        // subagents or a job still work for it: not over
        Turn::Completed if background.keeps_working() => return Status::Running,
        _ => (),
    }
    if let Some(d) = decided(w, s, now) { return d; } // marked done, snoozed
    if fresh(c) { return Status::Fresh; }
    match turn {
        Turn::Error => Status::Error,
        // only what wakes it; a server wakes nothing
        _ if background.wakes() => Status::Background,
        Turn::Interrupted => Status::Paused,
        _ => Status::Review,
    }
}

Note the order: your decision comes after "waiting" and "running". If you marked a session done and then woke the agent with another message, it shows Running; only once the turn ends does your decision apply.

04 A finished turn is ready for review, not done

An agent saying "all done" does not mean the work is done. So the end of a turn only reaches Ready for review, and only you can mark a session Done (settled on 11-02). When the agent's reply claims completion, the card's next-step hint becomes "check each item of the request against mechanical evidence before accepting" (completed_claim); the state stays the same.

New 1st message Running Needs you (4 states) Waiting for youapproval, question, plan · sounds Errorfailed, non-zero exit · sounds Ready for reviewturn ended, even with a server left In backgrounda wakeup or monitor is left answered · sent again · woken Stopped interrupted ✓ Done only you mark it done
Session state machine (simplified: Snoozed and Idle are not drawn). A turn that ends while a background job or subagent still runs does not move right; it stays Running.

Keeping Ready for review apart from Done has a practical effect. A session ready for review stays in the Needs you count, so ⌘J jumps to it, and it can be walked through in the review queue: read what the agent said last, then mark it done or send it back (sessions with a server left are kept out of the queue, because their Enter would close the terminal). If a finished turn counted as done, this step would disappear and unchecked changes would mix into the done column.

05 A server is not waiting: four versions of the background-shell rule

The hardest case is a session whose turn ended with background shells still alive. Claude's Stop hook lists them but does not say whether they will end. Some will (tests, builds, CI polling), and Claude is woken when they do; some will not (http.server, a relay, tail -f). The rule went through four versions:

VersionRuleWhat it got wrongSource
EarliestAny background shell means RunningA session with http.server open spun forever11-03 decision record
11-03 afternoonBackground shells only: always In background, counted in Needs youTests and builds still running after the turn were reported as needing you1058984
11-03 eveningRead the process tree: listening on a fixed port (< 49152) or running for 2 hours makes a server, anything else a job; switching takes two looks in a row, 5 s apartOn 11-04: an ephemeral port a render script opened for headless Chrome; a fixed-port relay a script started for itself3fb2791, 1ab8b0f
11-07Same judgment; a server now shows Ready for review with a note, "1 server left · port 5569"(current)decision record a-server-is-not-waiting

The last version came from the label In background holding two things: monitors and scheduled wakeups really do wake the agent; a resident server never brings anything back. A user saw Codex shown as "In background · 1h" and asked what it was waiting for; the answer was a preview server nobody had connected to. Now only what will wake the agent is called In background. A turn that leaves only a server is over: it is Ready for review, with the server in the note.

The current rules are tried in order and the first match decides (judge in background_shells.rs, excerpt):

What it seesCounts asWhy
Within 2 minutes of a host restart, not looked at yetjobShowing Running for a few seconds too long beats calling you for nothing
Running for 2 hoursserverBackstop: no wrong guess spins forever
Another process in the same tree connects to a fixed port in the treejobThe server is a part of the script and exits with it
Listening on a fixed port (< 49152), seen twice in a rowserverIt waits for someone outside to connect
Only an ephemeral port (≥ 49152), or nonejobEphemeral ports are a tool's own

Tried and dropped: guessing from the command text (something called relay may be a resident server or a part of a script), and treating anything wrapped in a script as a job (npm run dev is wrapped too). Each misjudgment adds a row to the decision record's case table and to the known_cases test, which has 13 cases now; a rule change may not turn any of them red.

06 Cases it got wrong

Each of these turned up on a real device or a real CLI; the fake agents in the tests did not expose them. Each left a test that fails when the fix is undone.

SymptomWhy it was misjudgedFixSource
Tapping Stop on the phone: Claude's log recorded the interruption at 14:43:42; at 14:43:49 Fibo still replied "it did not stop"A spinning title and timer line left from before the end outranked the end already written in the logA busy cue remembers when it was first seen and which end was known then; only cues first seen after the end can start a new turn, and within one second it checks whether the host had seen that end first1b25e159 (#646)
Some sessions sat in Ready for review yet dropped out of Needs youA memory tool's Stop hook started a claude -p outside the process tree; it inherited the terminal's environment and terminal id, the hook bound it as that terminal's current conversation, and the real one stopped being currentRefuse the binding when the terminal already has a current conversation of the same kind and the hook cannot be traced to the terminal's process tree; a conversation switch in place is let through by SessionStart's sourcebf2a58ca (#640)
On a machine without hooks, a plan confirmation menu stayed Running and the phone could not approve itClaude Code 2.1.326 put a statement before the plan question; the approval rule only took questions starting with "Would you like to"A separate "plan" screen rule; kept apart from approvals because the plan menu's option 1 switches to auto-accept everything, so pressing Allow would open up the whole session46895365 (#593)
Codex stopped on an approval in a 31-column split; the phone did not recognize it, and a second message was typed into the prompt and its Enter approved a commandThe narrow window wrapped the question onto two lines; the rule required it on one line ending in ?Join wrapped lines before reading the screen; and while a cursor menu whose option 1 is Yes or Trust is open at the bottom, no message is typed in, recognized or not#387
Claude asked a three-way question; the phone showed only "CLI requests tool approval" and an EscThat Claude Code version wrote the question to the log only after it was answered; before that there was only the PermissionRequest hookRead the question and choices from the hook's tool_input11-08 device log
A session rendering a video was judged In backgroundThe render script opened a system-assigned ephemeral port for headless ChromeOnly fixed ports (< 49152) make a server1ab8b0f

That is why screen rules are data, not code: the bundled claude.json has 3 rules (approval, choice, plan) and codex.json has 2. Each hangs on one anchor line and the numbered menu beside it; any other shape counts as no evidence, never a guess. The rules are tested against saved screens: 28 for Claude and 18 for Codex, 19 of them recorded from the real CLI and 17 of them look-alikes that must not match, such as an already answered menu, options mentioned in prose, or text typed into the input box (counted 11-28 in crates/fibo-host/tests/fixtures/screens).

Without Fibo, you can still get the "stopped" signal: Claude Code hooks run a command you write when an event happens and pass the event's JSON on stdin. Put this in ~/.claude/settings.json to get a system notification when a turn ends or a permission is requested (macOS shown; on Linux use notify-send):

{
  "hooks": {
    "Stop": [{ "hooks": [{
      "type": "command", "timeout": 5,
      "command": "osascript -e 'display notification \"Turn finished\"'"
    }] }],
    "Notification": [{ "hooks": [{
      "type": "command", "timeout": 5,
      "command": "osascript -e 'display notification \"Waiting for you\"'"
    }] }]
  }
}

stdin carries hook_event_name, session_id and transcript_path; Notification also has notification_type (for example permission_prompt). Two lessons: return at once and push slow work to the background; and Stop only says the turn ended, so check separately whether background shells remain (since Claude Code 2.1.317 the Stop JSON has background_tasks).

07 Decided in one place, and kept there by a test

Layering five sources is complex enough; if every surface also worked the state out on its own, they would disagree. That is what happened in Fibo's predecessor repository: unifying the state words was fixed by hand 4 times, and each time it drifted apart again (docs/single-source, from reading the old repository's 697 commits on 11-03). Two read-only audits on 11-03 found 78 places where one fact had two sources, for example:

Unifying by hand drifts back, so a machine guards it now, in two steps:

  1. Let the compiler make the list. Temporarily making the key fields pub(crate), the compiler reported 420 direct reads and writes outside core: about 200 writes from the observation layer (fine) and 146 reads that made decisions. Those reads were changed one by one to call core's owners: status::of, Status::label, status::needs_you, session_title, session_updated.
  2. A ratchet against drift. Rust cannot tell reads from writes, so the fields cannot stay private. Instead crates/fibo-core/tests/guard.rs uses regular expressions to count two things per file: raw field reads outside core (.turn, .background, .turn_started and others), and state words written by hand outside status.rs (drifted spellings included). Any difference from tests/guard-baseline.txt fails; up or down, the file has to be rewritten, so a reviewer sees it.

Measured 11-28: adding, at the top of a file in fibo-host, a function that reads c.turn and returns "在跑" (the Chinese word for Running), cargo test -p fibo-core --test guard fails with (the hint in the first line shortened):

raw reads or hand-written state words changed (...):
field turn	crates/fibo-host/src/pictures.rs: new, 1
word 在跑	crates/fibo-host/src/pictures.rs: new, 1

The same line added after the inline #[cfg(test)] mod tests at the end of the file is not counted: the guard treats what follows an inline test module as test code.

The baseline does go up. Summing the baseline at every version in git history (measured 11-28 over the 52 commits on git log --first-parent that changed it):

50 60 70 80 90 11-03 11-07 11-11 11-15 11-19 11-23 11-27 80 68: Needs you made one group phone v2 merged UI words moved to t!() audit merge 68 70 hand-written state words raw reads outside core
The vertical axis starts at 50. Each line is the sum of that category in tests/guard-baseline.txt, drawn as steps by commit time. Two categories added later (shortcut hints, large opaque surfaces) are not shown.
CategoryFirst baseline, 11-03Latest baseline, 11-26Change
Hand-written state words8068−12
Raw field reads outside core6670+4 (peak 80)
Hard-coded ⌘ shortcut hints (added 11-03)2426+2
Large opaque surfaces (added 11-04)1615−1

The biggest single drop in state words came on 11-03, when Needs you became one group: 9 fewer in one commit. Raw field reads went up a few times; on 11-06, for example, splitting Codex's background commands into jobs and servers added 5. The guard does not forbid an increase; it makes each one part of a commit that gets reviewed.

The guard only stops second owners from appearing; it does not check that results agree. That is tests/one_owner.rs: one sample covering 16 states and naming cases, asserting the tab and the sidebar use the same name, then 200 random sequences of edits (renaming a tab, renaming in the sidebar, a new conversation in the same terminal, marking done), each step checked for one name and one state. The host's fibo list, phone cards and plugin events are also compared with core field by field.

Limits: what it does not do yet

Summary: three practices