v0.10.5

Agent Contract

Last updated


Agent is the only interface every provider implements; every other capability is reached by type assertion.

The Agent interface


  1. type Agent interface {
  2. Name() string
  3. Send(ctx context.Context, messages []Message, toolDefs []Tool, reasoning Reasoning, mode Mode) (*Output, int, error)
  4. }

Send returns the upstream HTTP status as its second value, so callers branch on a status code rather than on error strings.

Optional capabilities


An agent without a capability fails the assertion.
Optional interfaceMethodImplemented by
StreamAgentSendStreamevery provider except claude-code; cloudflare always returns ErrStreamUnsupported
ReasoningAgentReasoningLimitsevery provider except deepseek, cloudflare, compat, and claude-code
ImageAgentGenerateImageopenai, codex, gemini, grok, grok-oauth, openrouter
STTAgentTranscribeopenai, gemini, openrouter
TTSAgentSpeakopenai, gemini, openrouter
DecisionAgentDecideopenrouter; typesafe agents from router.NewDecision implement only this interface

Why interfaces instead of flags


The split exists so capability differences live in the type system: one assertion answers "can this agent do it", and no lookup table of vendor features has to be maintained by hand.

中文