Expand description
The advisor runtime — drives the advisor agent from primary transcript
deltas. Ported from omp AdvisorRuntime (runtime.ts).
Each primary turn, the host calls AdvisorRuntime::on_turn_end with the
(new) transcript. The runtime renders a delta (messages added since the
last drain) and feeds it to the advisor agent’s prompt(). Accepted advice
flows back through the host’s enqueue_advice callback (the host owns the
crate::advisor::emission_guard::AdvisorEmissionGuard and the delivery
channel decision).
§Concurrency
omp’s drain loop is safe only because JS’s event loop serializes the
synchronous segment between “queue empty? stop” and “release the busy flag”.
tokio’s multithreaded runtime breaks that: a concurrent on_turn_end on
another worker can push + spawn a drain in the gap, and that spawned drain
bails (busy still set) leaving the queue non-empty with no drain running —
a lost-wakeup stall. The fix folds the “draining” role into the same lock
that guards the pending queue, so “decide-to-stop” and “push-new-work +
spawn” are each one atomic critical section (design doc §9.2). The
catchup-waiter path has the same race and the same fix (register + check
backlog under one lock).
§Attribution
Translated to Rust from omp (oh-my-pi), MIT licensed.
Structs§
- Advisor
Runtime - Drives the advisor agent. Construct via
AdvisorRuntime::new, wrap inArc, then callAdvisorRuntime::install_selfso it can self-spawn its drain task.
Traits§
- Advisor
Agent - Minimal slice of an agent the runtime drives. omp
AdvisorAgent. Satisfied byoxicode_agent::Agentvia a host adapter; tests hand-roll a fake. - Advisor
Runtime Host - Host callbacks the runtime needs. omp
AdvisorRuntimeHost.