Skip to content

Identify Posit Assistant in Bedrock, Vertex, and local model requests - #139

Merged
wch merged 1 commit into
mainfrom
feat/product-user-agent-all-providers
Oct 13, 2026
Merged

wch merged 1 commit into
mainfrom
feat/product-user-agent-all-providers

Conversation

@wch

@wch wch commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

This PR adds the Posit Assistant product User-Agent to every chat and model-list request sent to Amazon Bedrock, Google Vertex AI, Ollama, and LM Studio, so that administrators can tell Posit Assistant traffic apart from other tools, for example by searching CloudTrail for PositAssistant. (Direct providers that use API keys have sent this identity since #113; these four did not, because their credentials had nowhere to carry the header.)

A Bedrock chat request now arrives with a User-Agent like this, the same format the other providers already use:

PositAssistant/1.4.1 posit_positron/2026.10.0 (linux) ai-sdk/amazon-bedrock/4.0.165 ...

The provider registry already adds the product identity before it sets up each request. It now does this for every kind of credential except OAuth sign-ins, so a future credential type gets the identity by default. Each of the four providers passes the header through to both its chat client and its model listing. The change applies to every host that uses the bridge: Positron, RStudio, the TUI, standalone, desktop, and Connect.

Edge and fallback behavior:

  • A User-Agent that a user or administrator sets explicitly still takes precedence, as before.
  • The official Ollama client replaces any User-Agent it is given with its own. The product identity is therefore added just before the request leaves, ahead of Ollama's ollama-js/... token rather than replacing it.
  • AWS SDK model listing accepts only a user-agent suffix, and it escapes spaces and parentheses. Those discovery calls carry a normalized form such as PositAssistant/1.4.1-posit_positron/2026.10.0--linux-, which still matches a search for PositAssistant.
  • The header is never saved with stored AWS credentials. Saving now copies only the documented AWS fields, so a credential that carries the header can't write it to disk.

Part of posit-dev/assistant#2685

Verification

New wire tests capture the outgoing request on each route and check the URL, the request count, and the product token: Bedrock Converse, Bedrock Anthropic, Mantle chat and responses, AWS SDK model listing, Mantle model listing, Vertex Gemini and Anthropic chat, Vertex model listing, Ollama chat, Ollama model list and model details, and LM Studio chat and model list. Each test also checks the authorization scheme, which confirms the request took the intended auth path.

Unit tests can't prove that Bedrock still accepts the signed request with the added header. A live Bedrock call from Positron is still pending and will happen before this merges.

Not included

  • Copilot and external agent engines (Claude Agent SDK, Codex, ACP): their own processes send the requests.
  • User-configured custom headers for Bedrock, Vertex, and local providers: the transports would now honor them, but passing them through from the provider config is a separate feature.
  • An administrator-supplied User-Agent suffix (the optional ask in posit-dev/assistant#2685).

The registry now injects the default product User-Agent into every
credential variant except OAuth, so Bedrock, Vertex, Ollama, and LM
Studio requests (chat and model discovery) identify Posit Assistant.
AWS, Google Cloud, and local credentials gain an optional customHeaders
field that the registry populates; credential shaping never sets it,
and the AWS store branch now projects its documented fields so injected
headers cannot be persisted.

Ollama's client restores its own User-Agent over supplied headers, so
OllamaClient merges the identity in a fetch wrapper instead. AWS SDK
model listing uses customUserAgent; Mantle discovery signs the header.

Part of posit-dev/assistant#2685
@wch
wch merged commit 5c841c1 into main Oct 13, 2026
4 checks passed
@wch
wch deleted the feat/product-user-agent-all-providers branch October 13, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant