SpaceRouter, the AI flight surgeon

Inspiration

A radio signal from Mars takes between 3 and 22 minutes to reach Earth, depending on where the two planets sit in their orbits. At the far end of that range:

$$ t_{\text{one-way}} = \frac{d}{c} \approx \frac{4.01 \times 10^{11}\ \text{m}}{3.00 \times 10^{8}\ \text{m/s}} \approx 1340\ \text{s} \approx 22\ \text{min} $$

So a question to the flight surgeon and its answer can take up to 45 minutes. No control loop with a human in it works at that latency. Whoever's closest does the procedure, and they're probably not a doctor.

The longer we looked at it, the more it seemed like this problem already exists on Earth. Rural ERs, ambulances, cargo ships and oil rigs all have moments when the most skilled person in the room isn't a doctor and the link to one is slow or gone. We wanted to close that loop locally, on the hardware that's already in the room.

What it does

SpaceRouter is an AI flight surgeon. It talks a non-doctor through a procedure step by step, watches their hands on camera, and speaks up when something starts to go wrong. For the hackathon we built one procedure end to end: closing a cut on a suture practice pad with simple interrupted stitches.

It doesn't wait to be asked. Hand tracking runs on every frame, and when something looks off (a long pause, a hand over the wrong spot, a knot tied right on top of the cut) SpaceRouter checks that frame with one narrow question, like "Is the knot sitting to one side of the cut?" If the answer is no, it tells the user what to fix. After two failed checks on the same step, it tells them to stop and get help.

The router is where the name comes from. It decides, frame by frame, what runs on the laptop, what goes to the cloud, and what's worth sending home over a slow link. Cut the Wi-Fi and the session keeps going on local models. When the link comes back, the router sends the Earth flight surgeon a compressed handoff with the frames that matter most.

How we built it

The protocol is a state machine

The model never decides what to do next. We compiled a published suturing protocol into an eight-step finite state machine, and the model's only job is to evaluate one binary check \(c_k(f) \in \lbrace 0, 1 \rbrace\) for the current step \(k\) on frame \(f\). The machine advances on a pass and escalates after two fails on the same step:

$$ s \leftarrow s_{k+1} \ \text{ if } c_k(f) = 1, \qquad s \leftarrow \text{ESCALATE} \ \text{ if } \sum_{j} \big(1 - c_k(f_j)\big) \geq 2 $$

Every instruction a user hears traces back to a state in that machine. The worst thing SpaceRouter can do is tell someone to stop and get help.

Watching without being asked

MediaPipe Hand Landmarker gives us 21 landmarks per hand per frame, in the browser, with no network. From those we compute mean landmark speed and total path length:

$$ v_t = \frac{1}{21} \sum_{i=1}^{21} \frac{\lVert x_{i,t} - x_{i,t-1} \rVert_2}{\Delta t}, \qquad \ell = \sum_{t} v_t \, \Delta t $$

A frame gets flagged for a check when the hands stall mid-step or drift out of the region of interest \(R_k\) for the current step:

$$ \text{flag}(t) = \mathbb{1}\big[\, v_\tau < \epsilon \ \ \forall \tau \in [t - T_{\text{idle}}, t] \,\big] \ \lor \ \mathbb{1}\big[\, \bar{x}_t \notin R_k \,\big] $$

Path length is also the economy-of-motion signal surgical training programs use to grade skill, so every session ends with a score for free.

Routing as an expected-cost decision

Let \(p\) be the local model's confidence that its answer on a frame is right, \(p_c\) the cloud model's accuracy, \(C\) the cost of missing an error, and \(\lambda \Delta t\) the cost of waiting on the network. The expected cost of each route is

$$ \mathbb{E}[\text{cost}{\text{local}}] = (1 - p)\, C, \qquad \mathbb{E}[\text{cost}{\text{cloud}}] = (1 - p_c)\, C + \lambda \, \Delta t $$

so a frame should go to the cloud exactly when

$$ p < \tau, \qquad \tau = p_c - \frac{\lambda \, \Delta t}{C} $$

The nice part is that Mars mode falls out of the same equation. With the link down, \(\Delta t \to \infty\), so \(\tau \to -\infty\) and every frame stays local. This only holds if \(p\) is calibrated, which is why we tuned it on labeled photos of good and bad stitches.

The Earth link is a knapsack

When a link to Earth exists, it's slow and small. Given a byte budget \(B\), the router picks the set of frames \(S\) that tells the flight surgeon the most:

$$ \max_{S \subseteq F} \ \sum_{f \in S} u(f) \quad \text{subject to} \quad \sum_{f \in S} b(f) \leq B $$

where \(u(f)\) is high for frames tied to failed checks and step transitions, and \(b(f)\) is the compressed size. Knapsack is NP-hard in general, but greedy selection by \(u(f) / b(f)\) is plenty at a few hundred frames.

The stack

The frontend is React and Vite in Chrome. Online, voice runs on OpenAI's Realtime API with gpt-realtime, and we send single frames at checkpoints instead of streaming video. Offline, gpt-oss-20b runs through Ollama, whisper.cpp handles speech, and a small local vision model answers the frame checks.

Challenges we ran into

Memory was the hardest one. gpt-oss-20b is a mixture-of-experts model with about 21B parameters and 3.6B active per token, quantized so it fits in roughly 16 GB. It only reads text, though, so the frame checks needed a separate vision model running beside it, and on one laptop the two fight for RAM. Our fallback in Mars mode runs only the vision model and speaks scripted lines straight from the protocol.

Open-ended vision questions had far too much variance. "How does this stitch look?" got vague answers. Turning every checkpoint into a yes or no question about one visible feature made the checks much more consistent. Lighting mattered more than any prompt change. An overhead camera and a desk lamp did more for accuracy than anything we typed.

The voice also kept talking over the user mid-stitch, which is a bad moment to hear from anyone unless they're catching a mistake. So questions moved to push-to-talk, and interruptions are reserved for flagged errors.

What we learned

Mostly that the model is the easy part. Anyone can wire up a voice assistant that looks through a camera. What made SpaceRouter useful was everything around the model: a state machine it can't wander off, checks narrow enough to answer reliably, and a router that knows what's worth a slow link.

We also learned to measure. A catch rate from a few dozen runs is noisy, so we report the planted mistake's catch rate (\(k\) catches in \(n\) runs) with a 95% Wilson interval instead of a bare percentage:

$$ \hat{p} = \frac{k}{n}, \qquad \text{CI}_{95} = \frac{\hat{p} + \frac{z^2}{2n} \pm z \sqrt{\frac{\hat{p}(1 - \hat{p})}{n} + \frac{z^2}{4n^2}}}{1 + \frac{z^2}{n}}, \qquad z = 1.96 $$

What's next

More procedures first (ultrasound, splinting and bleeding control), then real users. EMS crews, offshore and maritime crews, and rural hospitals all hit this problem today, years before anyone needs it on Mars. We built SpaceRouter for Mars, and ambulances need it first.

Built With

Share this project:

Updates

Submission history