You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AnthropicLanguageModel sends session instructions as a user message instead of top-level system #431
On AnyLanguageModel 1.3.0, an .instructions entry is sent to Anthropic's Messages API as the first user message. The text arrives, but the model receives it as something the user said rather than as an application instruction.
Reproduction
With an AnthropicLanguageModel and a recording HTTPTransport, inspect the body of the first non-streaming POST /v1/messages. No live API key or model response is needed to see the difference:
lethistory=Transcript(entries:[.instructions(.init(segments:[.text(.init(content:"Answer in French."))],toolDefinitions:[]))])letsession=LanguageModelSession(model:model,transcript:history)_=tryawaitsession.respond(to:"Hello!")
Actual (relevant fields): system is absent. messages starts with a user message containing Answer in French., followed by the actual user prompt Hello!.
Expected: the instruction appears once in the top-level system field, and messages starts with Hello!. Anthropic uses a top-level field, not a system role inside messages.
Hi @shura-v. Thanks for the clear report and reproduction! This is fixed in 1.4.1: AnthropicLanguageModel now sends instructions in the top-level system field (#433). GeminiLanguageModel had the same problem, and that's fixed too (#436).
Activity
mattt commentedon Nov 20, 2026
Hi @shura-v. Thanks for the clear report and reproduction! This is fixed in 1.4.1:
AnthropicLanguageModelnow sends instructions in the top-levelsystemfield (#433).GeminiLanguageModelhad the same problem, and that's fixed too (#436).