-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
feat: expose resolved backend model in session_status and agent runtime #51441
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.Auth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.Issue affects a taxonomy feature currently scored M4/M5.staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.Auth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.Issue affects a taxonomy feature currently scored M4/M5.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Priority
None yet
Problem
When using LiteLLM (or any routing proxy) as the LLM provider, agents only see the requested model alias (e.g.
litellm/complex) — not the actual backend model that was used (e.g.openai/gpt-5.4oranthropic/claude-sonnet-4-6).This creates a blind spot: agents can't answer "did a fallback happen?" or "what model actually served this response?" without log-diving.
Current behavior
session_statusreturns the configured/requested model. TheagentMeta.modelinrunResult.metais populated from CLI runners (claude-cli, codex, etc.) but not from the OpenAI-compatible path — so when LiteLLM routing is used,agentMeta.modelfalls through tofallbackModel ?? defaultModel(the configured alias, not the resolved backend).persistSessionUsageUpdatestoresmodelUsedandproviderUsedfromagentMeta, so this gap flows through to the session store.Requested feature
Capture
response.modelfrom OpenAI-compatible responses in the provider transport layer and expose it asagentMeta.resolvedModel/agentMeta.resolvedProviderAdd
resolvedModel,resolvedProvider,fallbackUsedfields toGatewaySessionRowand persist them viapersistSessionUsageUpdateExpose in
session_statustool output:Include in agent runtime text injection so agents can introspect routing decisions without tool calls
Optional: pass session/agent metadata as LiteLLM request tags so
/spend/logsentries can be correlated to specific agent sessionsWorkaround in use
We currently query
http://localhost:4000/spend/logsdirectly (LiteLLM's spend log API) to surface resolved model info. The fieldsmodel_group(= requested tier) andmodel(= actual backend) are both present there. This works but requires a separate API call and is not surfaced to the agent in-band.Files involved
dist/agents/steerable-provider-transport.js— captureresponse.modelfrom API responsesdist/auto-reply/reply/session-usage.js+.d.ts— add new fields topersistSessionUsageUpdatedist/auto-reply/reply/agent-runner.js+followup-runner.js— pass resolved fields to usage updatedist/gateway/session-utils.types.d.ts+ session store — addresolvedModel,resolvedProvider,fallbackUsedtoGatewaySessionRowdist/agents/tools/session-status-tool.js— expose in tool outputdist/commands/status.summary.js— expose in CLI status outputImpact
High — any deployment using LiteLLM, OpenRouter, or any routing proxy is blind to actual model routing. Debugging fallbacks requires log access rather than in-band observability.