Documentation
¶
Overview ¶
Package anthropic adapts Anthropic's Messages API to agent.Model. It translates the provider-neutral []agent.Message/Part model to Anthropic content blocks (text, thinking+signature, tool_use, tool_result), declares tools, opens the SSE stream, and normalizes Anthropic's event types into agent's Event taxonomy. Zero external deps — net/http + stdlib.
Native Anthropic is exactly what Google ADK Go still lacks (#225/#1097); this is a wedge. Streaming tool-call args arrive as input_json_delta fragments — the canonical case the agent core's finalize() json.Valid gate handles.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is an Anthropic Messages API adapter implementing agent.Model.
type Option ¶
type Option func(*Model)
func WithBaseURL ¶
func WithHTTPClient ¶
func WithMaxTokens ¶
func WithPromptCache ¶
func WithPromptCache() Option
WithPromptCache turns on Anthropic prompt caching: cache_control breakpoints are placed on the system prompt and the tool definitions — the large, constant prefix an agent loop resends every turn — so repeat turns are billed at the cache-read rate. Cache hits/writes surface in agent.Usage (CacheReadTokens / CacheWriteTokens).
func WithToolResultCodec ¶ added in v0.2.0
func WithToolResultCodec(c agent.ToolResultCodec) Option
WithToolResultCodec encodes tool results sent to the model with c instead of raw JSON (for example GCF, to cut tokens on structured output). The journal keeps the JSON form; only what the model reads changes. Default is JSON.