Files
Matt Toohey 4889539ebb feat(observability): trace provider/model at every reply hand-off
- Always populate Message.metadata.inference in reply_internal so the
  client has a per-message ground truth even when fetch_model_info()
  cannot resolve a canonical model (resolved_model: None is now a
  legitimate carried value).
- Add gen_ai.provider and gen_ai.request.model fields to the existing
  tracing::instrument on stream_response_from_provider, which wraps
  every Provider::stream call. (Instrumenting the trait method
  directly is not possible: it has no body for tracing-attributes to
  wrap and the in-tree comment at base.rs explicitly forbids it.)
- Add structured tracing::info! at the four reply hand-off points,
  tagged with session.id for end-to-end correlation:
  * /reply entry, after the session is loaded
    (goose-server/src/routes/reply.rs)
  * restore_provider_from_session, with provider_source and
    model_source = "session" | "config_default"
    (goose/src/agents/agent.rs)
  * update_provider, with source = "explicit_update"
    (goose/src/agents/agent.rs)
  * just before provider.stream(...)
    (goose/src/agents/reply_parts.rs)
  * MessageEvent::Message emit, with the message's inference metadata
    (goose-server/src/routes/reply.rs)
- ACP path: add symmetric entry and emit logs in
  GooseAcpAgent::on_prompt (goose/src/acp/server.rs). The actual LLM
  call site is shared via Agent::reply, so the agent-level changes
  cover both /reply and ACP.

Together these allow correlating one log chain per session and
locating where the requested model and the actually-used model
diverge.

Verified: cargo build -p goose -p goose-server, cargo clippy
--all-targets -p goose -p goose-server -- -D warnings, and
cargo test -p goose --lib conversation:: all pass. Pre-existing
sqlx-runtime-feature test failures under cargo test -p goose --lib
are unrelated to this change (confirmed via git stash).

Signed-off-by: Matt Toohey <contact@matttoohey.com>
2026-06-01 10:33:02 +10:00
..