Documentation / guides
Overview
Assemble a provider-neutral request and validate optional features before encoding.
inference.Request is the complete provider-neutral input to Client.Invoke or Client.Stream. It keeps model identity, per-agent instructions, ordered messages, tools, structured output, tool choice, and per-call sampling in one value.
Request surface
type Request struct {
Model model.Model
System string
Messages content.AgenticMessages
TransientMessages int
Tools []Tool
Output *OutputSchema
ToolChoice ToolChoice
Override *model.Sampling
}
| Field | Ownership and behavior |
|---|---|
Model | Secret-free descriptor; validate before use |
System | Per-call system instruction, separate from message history |
Messages | Ordered sealed conversation turns |
Tools | Tool definitions exposed to the model |
Output | Optional portable JSON object contract |
TransientMessages | Count of trailing messages excluded from cache breakpoints |
ToolChoice | Automatic, required, or named tool behavior |
Override | Optional per-call replacement for model sampling |
request := inference.Request{
Model: model.CustomModel(model.ProviderName("acme"), model.APIFormatOpenAI, "https://api.example.test", "chat-1"),
System: "Answer with evidence.",
Messages: content.AgenticMessages{&content.UserMessage{Message: content.Message{
Role: content.RoleUser,
Blocks: []content.Block{&content.TextBlock{Text: "What changed?"}},
}}},
}
if err := inference.ValidateRequestFeatures(request); err != nil {
panic(err)
}
The Harness model request step is the canonical consumer path when a request is produced inside a Harness loop.
Proof
- Source:
inference/client.go,inference/output.go - Tests:
inference/client_test.go
Related: Model selection, Conversation input, Feature validation.