Expand description
Optional model discovery (capability-negotiated). RFC 0018 §5.4.
agentd may learn what an endpoint serves via a tiny handshake — off unless an endpoint looks discovery-capable, silent on failure, never fatal, never on the hot path, never at startup before a side effect (RFC 0018 decision 5).
The probe is one hand-rolled HTTP GET /v1/models over the EXISTING intel
transport (super::endpoints::Endpoint::discover_models) — no new client,
no streaming, zero new deps. For an OpenAI-compatible endpoint it parses
{ "data": [ { "id": "…" } ] }; the anthropic dialect has no list endpoint
→ it contributes nothing (the configured model is dialed regardless).
The SURFACE that consumes this — agentd://intelligence + the capabilities
manifest intelligence.models — is supervisor-side (RFC 0018 §4.4 / RFC 0015
§capabilities). The architecture adaptation of the RFC’s “lazy on first
complete_once” (a child-side hook) is to probe supervisor-side, lazily +
cached, on read of the served surface: those reads are infrequent and
operator-driven, so a cached probe there is the right seam, and it keeps the
additive discovery field off the control protocol. The cache + TTL live in
[crate::mcp::server::ServeCtx]; this module is the pure probe.
Structs§
- Discovery
Result - The discovery outcome for the served surface (RFC 0018 §5.4):
Constants§
- DEFAULT_
TIMEOUT - The default per-probe timeout (RFC 0018 §5.4 — “a SHORT timeout, it’s best-effort”). Discovery is off the hot path; a slow/wedged endpoint must not stall the operator-driven read that triggered the probe.
Functions§
- discover
- Probe every OpenAI-compatible endpoint in
listfor its served models and fold the result into aDiscoveryResult(RFC 0018 §5.4).modelis the configured model id, always unioned in (it is usable regardless of whether any endpoint answered discovery). Best-effort + silent: a per-endpoint probe that fails (404 / connection / non-JSON) simply contributes no models and does not flipdiscovery— it is NEVER fatal, NEVER a failover-class error (§5.4).