Normandy.LLM.Request (normandy v2.2.0)

View Source

One call to a model: what Normandy.Agents.Model.converse/3 and Normandy.Agents.Model.stream/3 receive.

  • :model - the model id
  • :system - the system prompt, or nil. :messages never holds a "system" message.
  • :output_schema_prompt - the # OUTPUT SCHEMA section that tells the model the answer's JSON Schema, or nil. It is not in :system: an adapter sends it after :system on every call whose output it does not constrain to that schema, and may leave it out of one it does (ClaudioAdapter with structured outputs, AX-19).
  • :context_prompt - the context providers' # Context section, or nil: the part of the system prompt that can change from call to call, sent last (ClaudioAdapter puts it after the cached system block, AX-20).

A Normandy.Agents.Model implementation sends system_prompt/1 as its system prompt.

  • :messages - the conversation, oldest first, as Normandy.Components.Message structs
  • :response_model - an empty struct of the shape the caller expects back (see "Response content" in Normandy.Agents.Model), or nil for the answer as text
  • :output_format - on a tool-loop call (response_model: %ToolCallResponse{}) or a stream, the output-schema struct the final answer's text must match, or nil. An adapter that supports constrained decoding sends it (ClaudioAdapter, as output_config.format); others ignore it. Never set for the chat schema.
  • :temperature - nil leaves it unset (Opus 4.7+ reject sampling parameters)
  • :max_tokens - required by the Messages API
  • :tools - tool schemas, %{name:, description:, input_schema:} maps; a tool with a provider-defined type also has :native (Normandy.Tool.native_definition/1), which an adapter that supports it sends instead; any other adapter sends the three keys
  • :mcp_servers - MCP server configs for server-side MCP, or nil
  • :task_budget_remaining - the remaining task budget after in-turn compaction, or nil
  • :tool_choice - nil (the provider's default) or :none: tools stay listed, but the model may not call one. BaseAgent sets :none on the call after the last tool round (max_tool_iterations); a client without tool choice may ignore it

Summary

Functions

The system prompt for a call whose output the adapter does not constrain: :system, :output_schema_prompt and :context_prompt, the ones that are set, a blank line apart. nil when none is. Takes a request, or a map with those three keys.

Types

t()

@type t() :: %Normandy.LLM.Request{
  context_prompt: String.t() | nil,
  max_tokens: pos_integer(),
  mcp_servers: [struct() | map()] | nil,
  messages: [Normandy.Components.Message.t()],
  model: String.t(),
  output_format: struct() | nil,
  output_schema_prompt: String.t() | nil,
  response_model: struct() | nil,
  system: String.t() | nil,
  task_budget_remaining: non_neg_integer() | nil,
  temperature: float() | nil,
  tool_choice: :none | nil,
  tools: [map()]
}

Functions

system_prompt(map)

@spec system_prompt(t() | %{system: s, output_schema_prompt: s, context_prompt: s}) ::
  String.t() | nil
when s: String.t() | nil

The system prompt for a call whose output the adapter does not constrain: :system, :output_schema_prompt and :context_prompt, the ones that are set, a blank line apart. nil when none is. Takes a request, or a map with those three keys.