Documentation
¶
Overview ¶
Package llmkit defines contracts for routing LLM calls across accounts and models.
llmkit helps host applications choose a model and account for a task based on task profile, model capability, cost, latency, concurrency, and audit needs. It owns routing, account/model policy, and audit contracts, but it does not store API keys. Implementations should refer to keys through host-owned environment variables, secret stores, or aliases.
llmkit is an optional adapter/capability module in the goagents workspace. It is not part of github.com/eruca/goagents/goagent core, and goagent must not import it.
Index ¶
- Constants
- Variables
- func CountsTowardProviderHealth(class ErrorClass) bool
- func ProviderHealthKey(accountAlias, modelAlias, provider string) string
- func ResolveHome(cwd string, getenv func(string) string, mode HomeMode) (string, error)
- func WriteModelStats(home string, stats ModelStats) error
- type AccountConfig
- type AuditConfig
- type AuditFilter
- type BusinessOutcome
- type Candidate
- type CandidateScore
- type CapabilityLevel
- type Complexity
- type Config
- type ContextWindowClass
- type ErrorClass
- type FailureCost
- type HealthPolicy
- type HealthStore
- type HomeMode
- type JSONLRecorder
- type LatencyClass
- type LatencyRequirement
- type MemoryHealthStore
- func (s *MemoryHealthStore) Acquire(ctx context.Context, candidate Candidate) error
- func (s *MemoryHealthStore) RecordOutcome(ctx context.Context, outcome TaskOutcome) error
- func (s *MemoryHealthStore) Release(_ context.Context, candidate Candidate) error
- func (s *MemoryHealthStore) Set(entry ProviderHealthEntry)
- func (s *MemoryHealthStore) Snapshot() ProviderHealthSnapshot
- type ModelCapability
- type ModelConfig
- type ModelStats
- type ModelStatsEntry
- type PriceClass
- type PrivacyLevel
- type ProfileDefaults
- type ProfileSource
- type ProviderAvailability
- type ProviderHealthEntry
- type ProviderHealthSnapshot
- type Recorder
- type RouteAuditRecord
- type RouteDecision
- type RoutePolicy
- type RouteTrace
- type RoutingConfig
- type RoutingRule
- type SuccessSignal
- type TaskOutcome
- type TaskProfile
Constants ¶
const ModelStatsHalfLife = 7 * 24 * time.Hour
ModelStatsHalfLife is the age at which an outcome counts half as much as a fresh one in RecentOutcomes and RecentFailures.
Variables ¶
var ErrProviderBusy = errors.New("provider cannot take another call now")
ErrProviderBusy is wrapped by HealthStore.Acquire when a provider cannot take another call right now. It is not a provider failure: callers move on to another candidate and record no outcome.
Functions ¶
func CountsTowardProviderHealth ¶
func CountsTowardProviderHealth(class ErrorClass) bool
CountsTowardProviderHealth reports whether a failure says something about the provider. Failures the caller caused, such as cancelling the request or sending one that is too large or over budget, leave provider health alone. An unclassified failure counts, which keeps the conservative default.
func ProviderHealthKey ¶
func ResolveHome ¶
ResolveHome resolves llmkit's configuration home without creating it.
func WriteModelStats ¶
func WriteModelStats(home string, stats ModelStats) error
WriteModelStats writes model-stats.json under home with private permissions.
Types ¶
type AccountConfig ¶
type AccountConfig struct {
Alias string `yaml:"alias,omitempty" json:"alias,omitempty"`
Provider string `yaml:"provider,omitempty" json:"provider,omitempty"`
BaseURL string `yaml:"base_url,omitempty" json:"base_url,omitempty"`
APIKeyEnv string `yaml:"api_key_env,omitempty" json:"api_key_env,omitempty"`
APIKey string `yaml:"api_key,omitempty" json:"-"`
MaxConcurrency int `yaml:"max_concurrency,omitempty" json:"max_concurrency,omitempty"`
}
AccountConfig names a provider account without storing credentials.
type AuditConfig ¶
type AuditConfig struct {
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
RouteEventsFile string `yaml:"route_events_file,omitempty" json:"route_events_file,omitempty"`
OutcomesFile string `yaml:"outcomes_file,omitempty" json:"outcomes_file,omitempty"`
}
AuditConfig controls host-side audit file behavior.
type AuditFilter ¶
type AuditFilter struct {
TaskID string
}
AuditFilter limits read-side audit queries.
type BusinessOutcome ¶
type BusinessOutcome string
const ( BusinessOutcomeSuccess BusinessOutcome = "success" BusinessOutcomeFailure BusinessOutcome = "failure" BusinessOutcomePartial BusinessOutcome = "partial" BusinessOutcomeUnknown BusinessOutcome = "unknown" )
type Candidate ¶
type Candidate struct {
Model ModelCapability `json:"model"`
AccountAlias string `json:"account_alias,omitempty"`
AccountRateLimited bool `json:"account_rate_limited,omitempty"`
AccountMaxConcurrency int `json:"account_max_concurrency,omitempty"`
AccountCurrentConcurrency int `json:"account_current_concurrency,omitempty"`
ProviderAvailability ProviderAvailability `json:"provider_availability,omitempty"`
ProviderInFlight int `json:"provider_in_flight,omitempty"`
ProviderMaxConcurrency int `json:"provider_max_concurrency,omitempty"`
ProviderQuotaRemaining int `json:"provider_quota_remaining,omitempty"`
ProviderQuotaExhausted bool `json:"provider_quota_exhausted,omitempty"`
ProviderFailureStreak int `json:"provider_failure_streak,omitempty"`
ProviderCooldownUntil time.Time `json:"provider_cooldown_until,omitempty"`
}
Candidate is one routable model/account option.
func ApplyModelStats ¶
func ApplyModelStats(stats ModelStats, profile TaskProfile, candidates []Candidate) []Candidate
ApplyModelStats returns a candidate copy enriched with task-specific history. Hosts call this explicitly when they want model-stats.json to influence route scoring through ModelCapability recent reliability fields.
func ApplyProviderHealth ¶
func ApplyProviderHealth(snapshot ProviderHealthSnapshot, candidates []Candidate) []Candidate
type CandidateScore ¶
type CandidateScore struct {
Alias string `json:"alias,omitempty"`
AccountAlias string `json:"account_alias,omitempty"`
Available bool `json:"available"`
Score int `json:"score,omitempty"`
ScoreBreakdown map[string]int `json:"score_breakdown,omitempty"`
Reason string `json:"reason,omitempty"`
}
CandidateScore records why a candidate was accepted, rejected, or ranked.
type CapabilityLevel ¶
type CapabilityLevel string
CapabilityLevel describes the broad capability tier of a model.
const ( CapabilitySimple CapabilityLevel = "simple" CapabilityBalanced CapabilityLevel = "balanced" CapabilityAdvanced CapabilityLevel = "advanced" )
type Complexity ¶
type Complexity string
Complexity describes how much model capability a task needs.
const ( ComplexitySimple Complexity = "simple" ComplexityMedium Complexity = "medium" ComplexityHard Complexity = "hard" )
type Config ¶
type Config struct {
Home string `yaml:"home,omitempty" json:"home,omitempty"`
Audit AuditConfig `yaml:"audit,omitempty" json:"audit,omitempty"`
Accounts []AccountConfig `yaml:"accounts,omitempty" json:"accounts,omitempty"`
Models []ModelConfig `yaml:"models,omitempty" json:"models,omitempty"`
Routing RoutingConfig `yaml:"routing,omitempty" json:"routing,omitempty"`
}
Config is the host-owned llmkit configuration loaded from LLMKIT_HOME. It intentionally stores API key environment variable names, not key values.
func LoadConfig ¶
LoadConfig reads config.yaml from home and validates the host-owned config.
func LoadConfigFromEnv ¶
LoadConfigFromEnv resolves LLMKIT_HOME in production mode and loads config.yaml from that directory.
func (Config) Candidates ¶
Candidates converts configured models and accounts into route candidates.
func (Config) DefaultTaskProfile ¶
func (c Config) DefaultTaskProfile() TaskProfile
DefaultTaskProfile returns routing defaults from config, with library defaults filling omitted fields.
type ContextWindowClass ¶
type ContextWindowClass string
ContextWindowClass describes relative context-window size.
const ( ContextShort ContextWindowClass = "short" ContextMedium ContextWindowClass = "medium" ContextLong ContextWindowClass = "long" )
type ErrorClass ¶
type ErrorClass string
const ( ErrorClassTransient ErrorClass = "transient_error" ErrorClassRateLimited ErrorClass = "rate_limited" ErrorClassTimeout ErrorClass = "timeout" ErrorClassInvalidJSON ErrorClass = "invalid_json" ErrorClassToolCallInvalid ErrorClass = "tool_call_invalid" ErrorClassCapabilityMismatch ErrorClass = "capability_mismatch" ErrorClassPolicyBlocked ErrorClass = "policy_blocked" ErrorClassAuth ErrorClass = "auth_error" ErrorClassCanceled ErrorClass = "canceled" ErrorClassConfiguration ErrorClass = "configuration_error" ErrorClassBudgetExceeded ErrorClass = "budget_exceeded" ErrorClassPostCall ErrorClass = "post_call_error" ErrorClassRequestTooLarge ErrorClass = "request_too_large" ErrorClassResponseTooLarge ErrorClass = "response_too_large" ErrorClassUsageMissing ErrorClass = "usage_missing" ErrorClassRedirectBlocked ErrorClass = "redirect_blocked" ErrorClassInvalidResponse ErrorClass = "invalid_response" // ErrorClassProviderBusy marks a candidate HealthStore.Acquire turned // away; no call was made. ErrorClassProviderBusy ErrorClass = "provider_busy" ErrorClassUnknown ErrorClass = "unknown" )
type FailureCost ¶
type FailureCost string
FailureCost describes the user-visible cost of choosing a weak model.
const ( FailureCostLow FailureCost = "low" FailureCostMedium FailureCost = "medium" FailureCostHigh FailureCost = "high" )
type HealthPolicy ¶
type HealthPolicy struct {
FailureCooldownThreshold int
CooldownDuration time.Duration
MaxCooldownDuration time.Duration
Now func() time.Time
}
HealthPolicy configures the circuit breaker. Reaching FailureCooldownThreshold consecutive provider failures opens it for CooldownDuration; each further failure, such as a failed recovery probe, doubles the cooldown up to MaxCooldownDuration. A degraded provider whose last failure is CooldownDuration old is available again: being ranked below healthy providers, it might otherwise never get the success that clears it.
type HealthStore ¶
type HealthStore interface {
// Acquire atomically admits one call to the candidate's provider. It
// returns an error wrapping ErrProviderBusy while the circuit is open,
// while a recovery probe is in flight (half-open admits exactly one call),
// when quota is exhausted, or when the provider's or the account's
// concurrency limit is reached. Each successful Acquire is closed by
// exactly one RecordOutcome or Release.
Acquire(context.Context, Candidate) error
// Release closes an Acquire whose call never reached the provider.
Release(context.Context, Candidate) error
RecordOutcome(context.Context, TaskOutcome) error
Snapshot() ProviderHealthSnapshot
}
type HomeMode ¶
type HomeMode string
HomeMode controls whether ResolveHome may use development conveniences.
type JSONLRecorder ¶
type JSONLRecorder struct {
// contains filtered or unexported fields
}
JSONLRecorder appends one JSON object per line under its configured home.
func NewJSONLRecorder ¶
func NewJSONLRecorder(home string) (*JSONLRecorder, error)
NewJSONLRecorder creates a JSONL recorder and ensures its target directory exists. It writes route-events.jsonl and outcomes.jsonl under home.
func (*JSONLRecorder) RecordOutcome ¶
func (r *JSONLRecorder) RecordOutcome(ctx context.Context, outcome TaskOutcome) error
RecordOutcome appends a sanitized task outcome to outcomes.jsonl.
func (*JSONLRecorder) RecordRoute ¶
func (r *JSONLRecorder) RecordRoute(ctx context.Context, trace RouteTrace) error
RecordRoute appends a sanitized routing trace to route-events.jsonl.
type LatencyClass ¶
type LatencyClass string
LatencyClass describes observed or configured model latency.
const ( LatencySlowClass LatencyClass = "slow" LatencyNormalClass LatencyClass = "normal" LatencyFastClass LatencyClass = "fast" )
type LatencyRequirement ¶
type LatencyRequirement string
LatencyRequirement describes how strongly routing should prefer lower latency. It is a task-side requirement, not a model measurement.
const ( LatencyNone LatencyRequirement = "none" LatencyNormal LatencyRequirement = "normal" LatencyUrgent LatencyRequirement = "urgent" )
type MemoryHealthStore ¶
type MemoryHealthStore struct {
// contains filtered or unexported fields
}
func NewMemoryHealthStore ¶
func NewMemoryHealthStore(policy HealthPolicy) *MemoryHealthStore
func (*MemoryHealthStore) Acquire ¶
func (s *MemoryHealthStore) Acquire(ctx context.Context, candidate Candidate) error
func (*MemoryHealthStore) RecordOutcome ¶
func (s *MemoryHealthStore) RecordOutcome(ctx context.Context, outcome TaskOutcome) error
func (*MemoryHealthStore) Release ¶
func (s *MemoryHealthStore) Release(_ context.Context, candidate Candidate) error
func (*MemoryHealthStore) Set ¶
func (s *MemoryHealthStore) Set(entry ProviderHealthEntry)
func (*MemoryHealthStore) Snapshot ¶
func (s *MemoryHealthStore) Snapshot() ProviderHealthSnapshot
type ModelCapability ¶
type ModelCapability struct {
Alias string `json:"alias,omitempty"`
Provider string `json:"provider,omitempty"`
IsLocal bool `json:"is_local,omitempty"`
CapabilityLevel CapabilityLevel `json:"capability_level"`
SupportsTools bool `json:"supports_tools,omitempty"`
SupportsJSON bool `json:"supports_json,omitempty"`
ContextWindowClass ContextWindowClass `json:"context_window_class"`
PriceClass PriceClass `json:"price_class"`
LatencyClass LatencyClass `json:"latency_class"`
EstimatedCents int `json:"estimated_cents,omitempty"`
MaxConcurrency int `json:"max_concurrency,omitempty"`
CurrentConcurrency int `json:"current_concurrency,omitempty"`
// RecentOutcomes and RecentFailures are outcome counts, optionally
// weighted by age (see ModelStatsEntry), that drive reliability scoring.
RecentOutcomes float64 `json:"recent_outcomes,omitempty"`
RecentFailures float64 `json:"recent_failures,omitempty"`
RecentFailureRate float64 `json:"recent_failure_rate,omitempty"`
RecentLatencyMillis int `json:"recent_latency_ms,omitempty"`
}
ModelCapability is the static and current-runtime capability surface needed by deterministic routing. Task 4 will own route scoring and selection.
func (ModelCapability) Matches ¶
func (m ModelCapability) Matches(profile TaskProfile) bool
Matches reports whether the model can legally handle the profile. It only applies hard capability filters; preference and scoring are routing concerns.
type ModelConfig ¶
type ModelConfig struct {
Alias string `yaml:"alias,omitempty" json:"alias,omitempty"`
ModelName string `yaml:"model,omitempty" json:"model,omitempty"`
Provider string `yaml:"provider,omitempty" json:"provider,omitempty"`
AccountAlias string `yaml:"account_alias,omitempty" json:"account_alias,omitempty"`
IsLocal bool `yaml:"is_local,omitempty" json:"is_local,omitempty"`
CapabilityLevel CapabilityLevel `yaml:"capability_level,omitempty" json:"capability_level,omitempty"`
SupportsTools bool `yaml:"supports_tools,omitempty" json:"supports_tools,omitempty"`
SupportsJSON bool `yaml:"supports_json,omitempty" json:"supports_json,omitempty"`
ContextWindowClass ContextWindowClass `yaml:"context_window_class,omitempty" json:"context_window_class,omitempty"`
PriceClass PriceClass `yaml:"price_class,omitempty" json:"price_class,omitempty"`
LatencyClass LatencyClass `yaml:"latency_class,omitempty" json:"latency_class,omitempty"`
EstimatedCents int `yaml:"estimated_cents,omitempty" json:"estimated_cents,omitempty"`
MaxConcurrency int `yaml:"max_concurrency,omitempty" json:"max_concurrency,omitempty"`
Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"`
}
ModelConfig describes one configured model/account route candidate.
type ModelStats ¶
type ModelStats struct {
GeneratedAt time.Time `json:"generated_at"`
Models map[string]ModelStatsEntry `json:"models"`
}
ModelStats is the generated summary of routing and outcome audit records.
func BuildModelStats ¶
func BuildModelStats(home string) (*ModelStats, error)
BuildModelStats reads audit JSONL files and aggregates route/outcome facts.
func LoadModelStats ¶
func LoadModelStats(home string) (*ModelStats, error)
LoadModelStats reads model-stats.json from home.
func RefreshModelStats ¶
func RefreshModelStats(home string) (*ModelStats, error)
RefreshModelStats rebuilds model-stats.json from route-events.jsonl and outcomes.jsonl under home.
type ModelStatsEntry ¶
type ModelStatsEntry struct {
TaskType string `json:"task_type,omitempty"`
AccountAlias string `json:"account_alias,omitempty"`
ModelAlias string `json:"model_alias,omitempty"`
Provider string `json:"provider,omitempty"`
RouteAttempts int `json:"route_attempts"`
OutcomeCount int `json:"outcome_count"`
PendingOutcomes int `json:"pending_outcomes"`
Successes int `json:"successes"`
Failures int `json:"failures"`
SuccessRate float64 `json:"success_rate"`
FailureRate float64 `json:"failure_rate"`
// RecentOutcomes and RecentFailures weight each outcome by its age,
// halving every ModelStatsHalfLife, so routing reacts to how a model
// behaves now rather than over its whole history.
RecentOutcomes float64 `json:"recent_outcomes"`
RecentFailures float64 `json:"recent_failures"`
AvgLatencyMillis int `json:"avg_latency_ms,omitempty"`
AvgInputTokens int `json:"avg_input_tokens,omitempty"`
AvgOutputTokens int `json:"avg_output_tokens,omitempty"`
AvgEstimatedCents int `json:"avg_estimated_cents,omitempty"`
LastSeen *time.Time `json:"last_seen,omitempty"`
}
ModelStatsEntry summarizes one task/model/account/provider route bucket.
type PriceClass ¶
type PriceClass string
PriceClass describes the relative cost of using a model.
const ( PriceFree PriceClass = "free" PriceLow PriceClass = "low" PriceMedium PriceClass = "medium" PriceHigh PriceClass = "high" )
type PrivacyLevel ¶
type PrivacyLevel string
PrivacyLevel describes whether a task may leave the host machine.
const ( PrivacyLocalPreferred PrivacyLevel = "local_preferred" PrivacyCloudAllowed PrivacyLevel = "cloud_allowed" PrivacyLocalOnly PrivacyLevel = "local_only" )
type ProfileDefaults ¶
type ProfileDefaults struct {
Complexity Complexity `yaml:"complexity,omitempty" json:"complexity,omitempty"`
Latency LatencyRequirement `yaml:"latency_requirement,omitempty" json:"latency_requirement,omitempty"`
FailureCost FailureCost `yaml:"failure_cost,omitempty" json:"failure_cost,omitempty"`
Privacy PrivacyLevel `yaml:"privacy_level,omitempty" json:"privacy_level,omitempty"`
}
ProfileDefaults maps routing defaults to TaskProfile fields.
type ProfileSource ¶
type ProfileSource string
ProfileSource records whether the host provided the task profile or llmkit filled in defaults.
const ( ProfileSourceDefault ProfileSource = "default" ProfileSourceHost ProfileSource = "host" )
type ProviderAvailability ¶
type ProviderAvailability string
const ( ProviderAvailable ProviderAvailability = "available" ProviderDegraded ProviderAvailability = "degraded" )
type ProviderHealthEntry ¶
type ProviderHealthEntry struct {
AccountAlias string `json:"account_alias,omitempty"`
ModelAlias string `json:"model_alias,omitempty"`
Provider string `json:"provider,omitempty"`
Availability ProviderAvailability `json:"availability,omitempty"`
InFlight int `json:"in_flight,omitempty"`
MaxConcurrency int `json:"max_concurrency,omitempty"`
QuotaRemaining int `json:"quota_remaining,omitempty"`
QuotaExhausted bool `json:"quota_exhausted,omitempty"`
FailureStreak int `json:"failure_streak,omitempty"`
LastFailureAt time.Time `json:"last_failure_at,omitempty"`
CooldownUntil time.Time `json:"cooldown_until,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
type ProviderHealthSnapshot ¶
type ProviderHealthSnapshot struct {
GeneratedAt time.Time `json:"generated_at,omitempty"`
Entries map[string]ProviderHealthEntry `json:"entries,omitempty"`
}
type Recorder ¶
type Recorder interface {
RecordRoute(context.Context, RouteTrace) error
RecordOutcome(context.Context, TaskOutcome) error
}
Recorder persists routing and outcome audit records.
type RouteAuditRecord ¶
type RouteAuditRecord struct {
Route RouteTrace `json:"route"`
Outcome *TaskOutcome `json:"outcome,omitempty"`
}
RouteAuditRecord joins one route trace with its outcome when present.
func ReadRouteAudits ¶
func ReadRouteAudits(home string, filter AuditFilter) ([]RouteAuditRecord, error)
ReadRouteAudits reads route audit records from home and joins matching outcomes by route_id and attempt. It is a read-only helper for host observability APIs.
type RouteDecision ¶
type RouteDecision struct {
Selected Candidate `json:"selected"`
SelectedAlias string `json:"selected_alias,omitempty"`
Score int `json:"score"`
ScoreBreakdown map[string]int `json:"score_breakdown,omitempty"`
Reason string `json:"reason,omitempty"`
Candidates []CandidateScore `json:"candidates"`
}
RouteDecision is the deterministic routing result and its traceable explanation.
type RoutePolicy ¶
RoutePolicy selects a candidate using hard filters followed by stable deterministic scoring.
func (RoutePolicy) Select ¶
func (p RoutePolicy) Select(profile TaskProfile, candidates []Candidate) (RouteDecision, error)
Select returns the best candidate for profile, or a clear error when no candidate can legally handle the task.
type RouteTrace ¶
type RouteTrace struct {
RouteID string `json:"route_id,omitempty"`
TaskID string `json:"task_id,omitempty"`
Attempt int `json:"attempt,omitempty"`
RecordedAt time.Time `json:"recorded_at,omitempty"`
TaskType string `json:"task_type,omitempty"`
TaskProfile *TaskProfile `json:"task_profile,omitempty"`
AccountAlias string `json:"account_alias,omitempty"`
ModelAlias string `json:"model_alias,omitempty"`
Provider string `json:"provider,omitempty"`
Selected bool `json:"selected,omitempty"`
Reason string `json:"reason,omitempty"`
Score int `json:"score,omitempty"`
ScoreBreakdown map[string]int `json:"score_breakdown,omitempty"`
CandidateModelAliases []string `json:"candidate_model_aliases,omitempty"`
Candidates []CandidateScore `json:"candidates,omitempty"`
FallbackMaxAttempts int `json:"fallback_max_attempts,omitempty"`
}
RouteTrace is the allowlisted audit record for a routing decision. It stores aliases and routing explanations only; host-owned secrets must not be added.
type RoutingConfig ¶
type RoutingConfig struct {
Intent map[string]string `yaml:"intent,omitempty" json:"intent,omitempty"`
Defaults ProfileDefaults `yaml:"defaults,omitempty" json:"defaults,omitempty"`
Rules []RoutingRule `yaml:"rules,omitempty" json:"rules,omitempty"`
}
RoutingConfig stores declarative routing defaults and host-owned rule text. The current library consumes Defaults; concrete rule evaluation is future work.
type RoutingRule ¶
type RoutingRule struct {
When map[string]string `yaml:"when,omitempty" json:"when,omitempty"`
Prefer []string `yaml:"prefer,omitempty" json:"prefer,omitempty"`
}
RoutingRule preserves host-owned declarative preferences from config.yaml.
type SuccessSignal ¶
type SuccessSignal string
const ( SuccessSignalSchemaPassed SuccessSignal = "schema_passed" SuccessSignalTestsPassed SuccessSignal = "tests_passed" SuccessSignalHumanAccepted SuccessSignal = "human_accepted" SuccessSignalToolCompleted SuccessSignal = "tool_completed" )
type TaskOutcome ¶
type TaskOutcome struct {
RouteID string `json:"route_id,omitempty"`
TaskID string `json:"task_id,omitempty"`
Attempt int `json:"attempt,omitempty"`
RecordedAt time.Time `json:"recorded_at,omitempty"`
TaskType string `json:"task_type,omitempty"`
AccountAlias string `json:"account_alias,omitempty"`
ModelAlias string `json:"model_alias,omitempty"`
Provider string `json:"provider,omitempty"`
Success bool `json:"success"`
BusinessOutcome BusinessOutcome `json:"business_outcome,omitempty"`
SuccessSignal SuccessSignal `json:"success_signal,omitempty"`
FailureReason string `json:"failure_reason,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
ErrorClass ErrorClass `json:"error_class,omitempty"`
LatencyMillis int `json:"latency_ms,omitempty"`
InputTokens int `json:"input_tokens,omitempty"`
OutputTokens int `json:"output_tokens,omitempty"`
EstimatedCents int `json:"estimated_cents,omitempty"`
}
TaskOutcome is the allowlisted audit record for the result of an LLM task. It records outcome metadata, not prompts, responses, API keys, or headers.
type TaskProfile ¶
type TaskProfile struct {
TaskType string `json:"task_type,omitempty"`
Source ProfileSource `json:"source,omitempty"`
Complexity Complexity `json:"complexity"`
Latency LatencyRequirement `json:"latency_requirement"`
FailureCost FailureCost `json:"failure_cost"`
Privacy PrivacyLevel `json:"privacy_level"`
MaxEstimatedCents int `json:"max_estimated_cents,omitempty"`
NeedsReasoning bool `json:"needs_reasoning,omitempty"`
NeedsTools bool `json:"needs_tools,omitempty"`
NeedsJSON bool `json:"needs_json,omitempty"`
NeedsLongContext bool `json:"needs_long_context,omitempty"`
}
TaskProfile is the host-provided or default task description used by later routing steps.
func DefaultTaskProfile ¶
func DefaultTaskProfile() TaskProfile
DefaultTaskProfile returns the conservative baseline profile used when the host does not provide a more specific task profile.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
adapters
|
|
|
goagent
Package goagent adapts llmkit routing to goagent's LLMClient port.
|
Package goagent adapts llmkit routing to goagent's LLMClient port. |
|
examples
|
|
|
goagent-routing
command
|