pub struct ObserverHandle {
pub session: Arc<RwLock<SessionMetrics>>,
/* private fields */
}Expand description
Handle to the background observer task.
Call shutdown to gracefully stop the observer and wait
for all pending metrics to be processed. Dropping without calling shutdown
detaches the task — metrics from the final turns may be lost.
Fields§
§session: Arc<RwLock<SessionMetrics>>Shared session metrics, readable for external use (e.g. CLI display).
Implementations§
Source§impl ObserverHandle
impl ObserverHandle
Sourcepub fn set_session_custom(&self, custom: Value)
pub fn set_session_custom(&self, custom: Value)
Send session-level custom data to the observer.
Sourcepub fn set_turn_custom(&self, custom: Value)
pub fn set_turn_custom(&self, custom: Value)
Set turn-level custom data for the NEXT turn that the observer processes.
Call this from an on_turn_end callback. The custom value will be
merged into that turn’s custom field in TurnMetrics.
agent.runtime().on_turn_end(move |_ctx| {
handle.set_turn_custom(json!({"check_quality_passed": true}));
});Sourcepub async fn shutdown(&mut self)
pub async fn shutdown(&mut self)
Shut down the observer gracefully and wait for all pending metrics to be processed. Returns once the observer task has exited.
After this call, session contains the final
accumulated metrics (minus any finalize() call, which the caller
should perform separately).