llm

package
v0.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPStatusFromError

func HTTPStatusFromError(err error) int

func IsContextOverflowError

func IsContextOverflowError(err error) bool

IsContextOverflowError reports context-length failures that should use compaction instead of retry.

func IsQuotaError added in v0.1.14

func IsQuotaError(err error) bool

IsQuotaError reports quota or billing failures that are not worth retrying on the same provider.

func IsRetryableError

func IsRetryableError(err error) bool

IsRetryableError reports whether an error looks transient and safe to retry. Context overflow and quota exhaustion are excluded.

func MustToolCall

func MustToolCall(name, args string) agentkit.ToolCall

func NewFallback added in v0.1.14

func NewFallback(cfg FallbackConfig, deps FallbackDeps) (agentkit.LLMProvider, error)

NewFallback registers llm/fallback: try alternate models or providers when the primary LLM call fails.

func NewOpenAI

func NewOpenAI(cfg OpenAIConfig, deps OpenAIDeps) (agentkit.LLMProvider, error)

NewOpenAI registers llm/openai-compatible: OpenAI-compatible provider, chat or responses API.

Best practices:

  • hostedTools (e.g. web_search) require api: responses and run on the provider side.
  • When using hosted web_search, remove tool/web-search-* from the agent tool list to avoid duplicate search.

func NewScripted

func NewScripted(cfg ScriptedConfig) (agentkit.LLMProvider, error)

NewScripted registers llm/scripted: Deterministic canned responses. For tests and offline smoke runs.

func SleepContext

func SleepContext(ctx context.Context, delay time.Duration) error

Types

type Fallback added in v0.1.14

type Fallback struct {
	// contains filtered or unexported fields
}

func (*Fallback) Name added in v0.1.14

func (f *Fallback) Name() string

func (*Fallback) Stream added in v0.1.14

type FallbackConfig added in v0.1.14

type FallbackConfig struct {
	// Models is the full ordered model chain when sharing one provider or pairing with deps.fallbacks.
	Models []string `json:"models,omitempty"`
	// FallbackModels are tried after the request model (from agent config) on the shared provider.
	FallbackModels []string `json:"fallbackModels,omitempty"`
	// FallbackOn selects which errors trigger failover: retryable (default), quota, or any.
	FallbackOn string `json:"fallbackOn,omitempty"`
}

type FallbackDeps added in v0.1.14

type FallbackDeps struct {
	Provider  agentkit.LLMProvider   `json:"provider,omitempty"`
	Fallbacks []agentkit.LLMProvider `json:"fallbacks,omitempty"`
}

type HostedToolConfig added in v0.1.12

type HostedToolConfig struct {
	// Type is the Responses API tool type, e.g. web_search or file_search.
	Type string `json:"type"`
	// Parameters are tool-specific options, e.g. search_context_size for web_search.
	Parameters map[string]any `json:"parameters,omitempty"`
}

type LLMRetryConfig

type LLMRetryConfig struct {
	Provider *ProviderRetrySettings `json:"provider,omitempty"`
}

type OpenAI

type OpenAI struct {
	// contains filtered or unexported fields
}

func (*OpenAI) Name

func (p *OpenAI) Name() string

func (*OpenAI) Stream

type OpenAIConfig

type OpenAIConfig struct {
	// Model is model name.
	Model string `json:"model"`
	// BaseURL is API base URL, e.g. https://api.openai.com/v1.
	BaseURL string `json:"baseUrl"`
	// APIKey is inline key. Prefer APIKeyRef so the secret stays out of the config file.
	APIKey string `json:"apiKey"`
	// APIKeyRef is credentials reference, e.g. env:OPENAI_API_KEY.
	APIKeyRef string `json:"apiKeyRef"`
	// API is chat or responses.
	API string `json:"api"`
	// HostedTools are OpenAI Responses API built-in tools (e.g. web_search) executed
	// server-side. Requires api: responses.
	HostedTools []HostedToolConfig `json:"hostedTools,omitempty"`
	// Reasoning is reasoning effort and summary settings, for models that support them.
	Reasoning *OpenAIReasoningConfig `json:"reasoning,omitempty"`
	// Retry is provider-level retry, separate from the agent's per-step retry.
	Retry *LLMRetryConfig `json:"retry,omitempty"`
}

type OpenAIDeps

type OpenAIDeps struct {
	Credentials credentials.Store `json:"credentials,omitempty"`
}

type OpenAIReasoningConfig

type OpenAIReasoningConfig struct {
	Effort          string `json:"effort,omitempty"`
	GenerateSummary string `json:"generateSummary,omitempty"`
}

type ProviderRetrySettings

type ProviderRetrySettings struct {
	MaxRetries      int `json:"maxRetries"`
	MaxRetryDelayMs int `json:"maxRetryDelayMs"`
}

type Scripted

type Scripted struct {
	// contains filtered or unexported fields
}

Scripted replays fixed assistant responses for tests. One instance can be shared by several sessions (a multiplex or concurrent-dispatch preset), so the step cursor is guarded.

func (*Scripted) Name

func (p *Scripted) Name() string

func (*Scripted) Stream

type ScriptedConfig

type ScriptedConfig struct {
	// Model is name reported back to callers.
	Model string `json:"model"`
	// Steps are replies in order: text, tool calls, or both.
	Steps []ScriptedStep `json:"steps"`
}

type ScriptedStep

type ScriptedStep struct {
	Text      string              `json:"text"`
	ToolCalls []agentkit.ToolCall `json:"toolCalls"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL