feat: measure provider startup before adding prepared sessions - #17
Conversation
|
| /// Provider streams were attached, including HTTP readiness where required. | ||
| StreamsAttached, |
There was a problem hiding this comment.
Readiness boundary is overstated
StreamsAttached is documented as including required HTTP readiness, but OpenCode serve mode records it immediately after attach() returns, before the background bridge finishes polling /global/health. Consumers may therefore treat the provider as ready up to roughly ten seconds early and attribute the readiness delay to the wrong interval. The description should clarify that this boundary only means the stream carrier was installed.
| /// Provider streams were attached, including HTTP readiness where required. | |
| StreamsAttached, | |
| /// Provider streams were attached; HTTP readiness may still be pending. | |
| StreamsAttached, |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
|
||
| Licensed under either the Apache License, Version 2.0 or the MIT License, at | ||
| your option. | ||
|
|
There was a problem hiding this comment.
Fleet currently relaunches the SDK provider process for every turn: the retained client preserves session identity but reports
retained_process: false. Add optional startup observations so embedders can measure the delay before implementing true process retention and early preparation.AgentRuntimeBuilder::startup_observerreports payload-free monotonic boundaries for validation, concurrency admission, command/sandbox preparation, process spawn, initial stdin, stream attachment, first output, first nonempty assistant text, and completion/failure/cancellation/timeout/abandonment. Observers are disabled by default and do not modify provider events, remote protocols, prompts or process lifetime. Under unwinding builds, observer panics cannot fail the turn. Callbacks must remain nonblocking; the guide recommends bounded export.ADR 0004 proposes opt-in prepared provider processes and documents the Fleet adoption boundary: launch context and MCP credentials currently arrive at turn time, so context resolution and revocation must be reconciled before preparation is enabled. This PR is the measurement foundation; it does not implement
prepare()or claim faster sessions yet.Validation:
Live baseline (one two-turn pair per provider, macOS; pairs ran concurrently):
These are diagnostic samples, not controlled percentiles or Fleet end-to-end measurements. Most observed first-text time is after process creation; provider-ready and turn-accepted instrumentation is needed to separate initialization/MCP work from model latency before predicting preparation gains.
Review fixes:
event_delivery_elapsedalongside elapsed time. Include normal events, terminal warnings, and interrupted waits while preserving bounded event processing. Document first-text as consumer-observed, not pure provider latency.Evidence for the review fixes: