Skip to content

LLM response headers are discarded, preventing plugins from accessing proxy routing metadata #26091

@jtbnz

Description

@jtbnz

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When using a LiteLLM proxy with an auto router (complexity router, semantic router), the actual model selected by the router is returned in HTTP response headers like x-litellm-model-api-base and llm_provider-x-ms-deployment-name. The AI SDK captures these headers on the finish-step stream event (value.response.headers), but processor.ts only reads value.usage, value.providerMetadata, and value.finishReasonvalue.response is discarded entirely.

This means plugins cannot determine which model actually served a request when using proxy-based routing.

Expected behavior

Response headers from LLM provider HTTP responses should be available on the assistant message so plugins can access proxy routing metadata and other provider-specific response headers.

How to reproduce

  1. Configure OpenCode with a LiteLLM proxy using a complexity/semantic router
  2. Send a message through the router
  3. Write a plugin listening for message.updated events
  4. Observe that msg.responseHeaders does not exist — the plugin can only see the router alias in msg.modelID

OpenCode version

dev (latest)

Platform

macOS

Additional context

The APIError schema in the same file already has a responseHeaders field for error responses. This change extends the same pattern to successful responses.

Example plugin that would use this: https://github.com/jtbnz/opencode-routed-model

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions