Documentation
¶
Overview ¶
Package agentkit runs LLM agents on top of llmkit: typed tools generated from Go structs, a budgeted tool-calling loop with streaming events and hooks, conversation memory, and multi-agent composition.
weather := agentkit.Func("weather", "Current weather for a city",
func(ctx context.Context, in struct {
City string `json:"city" jsonschema:"city name"`
}) (string, error) {
return lookup(in.City), nil
})
agent, err := agentkit.New("claude-sonnet-4-5",
agentkit.WithInstructions("You are a concise assistant."),
agentkit.WithTools(weather))
res, err := agent.Run(ctx, "What's the weather in Cape Town?")
fmt.Println(res.Output)
Index ¶
- Constants
- Variables
- func Map[In, Out any](ctx context.Context, parallel int, items []In, ...) ([]Out, error)
- func Progress(ctx context.Context, text string)
- func ProgressWriter(ctx context.Context) io.Writer
- func SchemaFor[T any](opts ...FuncOption) (json.RawMessage, error)
- func WithCall(ctx context.Context, c Call) context.Context
- type Agent
- func (a *Agent) Client() core.Chatter
- func (a *Agent) Name() string
- func (a *Agent) Run(ctx context.Context, input string, opts ...RunOption) (*Result, error)
- func (a *Agent) RunMessages(ctx context.Context, msgs []core.Message, opts ...RunOption) (*Result, error)
- func (a *Agent) Stream(ctx context.Context, input string, opts ...RunOption) iter.Seq2[Event, error]
- func (a *Agent) StreamMessages(ctx context.Context, msgs []core.Message, opts ...RunOption) iter.Seq2[Event, error]
- func (a *Agent) Tools() Toolset
- func (a *Agent) With(opts ...Option) (*Agent, error)
- type Approver
- type ApproverFunc
- type AsToolOption
- type Budget
- type BudgetError
- type Call
- type CharEstimator
- type CompactInfo
- type Compactor
- type CompactorFunc
- type Decision
- type Deleter
- type Estimator
- type Event
- type EventKind
- type FileStore
- func (s *FileStore) Append(_ context.Context, sessionID string, msgs ...core.Message) error
- func (s *FileStore) Delete(_ context.Context, sessionID string) error
- func (s *FileStore) List(_ context.Context) ([]SessionInfo, error)
- func (s *FileStore) Load(_ context.Context, sessionID string) ([]core.Message, error)
- type FuncOption
- type HandoffInfo
- type Hooks
- type Inbox
- type Lister
- type MemoryStore
- func (s *MemoryStore) Append(_ context.Context, sessionID string, msgs ...core.Message) error
- func (s *MemoryStore) Delete(_ context.Context, sessionID string) error
- func (s *MemoryStore) List(_ context.Context) ([]SessionInfo, error)
- func (s *MemoryStore) Load(_ context.Context, sessionID string) ([]core.Message, error)
- type Middleware
- type ModelCallInfo
- type ModelResponseInfo
- type Option
- func WithAdditionalInstructions(sections ...string) Option
- func WithBudget(b Budget) Option
- func WithCache(c core.CacheConfig) Option
- func WithClientOptions(opts ...core.Option) Option
- func WithCompactor(c Compactor) Option
- func WithContextWindow(tokens int) Option
- func WithEstimator(e Estimator) Option
- func WithHooks(h Hooks) Option
- func WithInstructions(s string) Option
- func WithMaxTokens(n int) Option
- func WithMiddleware(mws ...Middleware) Option
- func WithName(name string) Option
- func WithParallel(n int) Option
- func WithProviderOptions(po map[string]map[string]any) Option
- func WithReasoning(r core.ReasoningConfig) Option
- func WithRegistry(r *llmkit.Registry) Option
- func WithRequestExtra(extra map[string]any) Option
- func WithRetriever(r Retriever, k int) Option
- func WithRetry(p RetryPolicy) Option
- func WithStore(s Store) Option
- func WithTemperature(t float64) Option
- func WithToolChoice(tc core.ToolChoice) Option
- func WithTools(tools ...Tool) Option
- type Output
- type OutputMode
- type Pinned
- type Result
- type Retriever
- type RetryInfo
- type RetryPolicy
- type RunInfo
- type RunOption
- type Sequential
- type SessionInfo
- type StepInfo
- type StopReason
- type Store
- type SummarizeOption
- type Tool
- func AsTool(a *Agent, name, description string, opts ...AsToolOption) Tool
- func Func[In, Out any](name, description string, fn func(context.Context, In) (Out, error), ...) Tool
- func Handoff(targets ...*Agent) Tool
- func NewFunc[In, Out any](name, description string, fn func(context.Context, In) (Out, error), ...) (Tool, error)
- func Raw(name, description string, params json.RawMessage, ...) Tool
- func Recall(r Retriever, k int) Tool
- func Rename(t Tool, name string) Tool
- func Wrap(t Tool, mws ...Middleware) Tool
- type ToolCallInfo
- type ToolResultInfo
- type Toolset
- type VectorMemory
- type VectorOption
Constants ¶
const FinalAnswerTool = "final_answer"
FinalAnswerTool is the name of the tool Run[T] injects in OutputTool mode.
const HandoffToolName = "handoff"
HandoffToolName is the name of the tool Handoff builds.
const RecallToolName = "recall"
RecallToolName is the name of the tool Recall builds.
Variables ¶
var ( ErrBudgetExceeded = errors.New("agentkit: budget exceeded") ErrNoFinalAnswer = errors.New("agentkit: model finished without final answer") ErrToolNotFound = errors.New("agentkit: tool not found") ErrApprovalDenied = errors.New("agentkit: tool call not approved") ErrHandoffLoop = errors.New("agentkit: handoff limit reached") ErrDuplicateTool = errors.New("agentkit: duplicate tool name") ErrInvalidArgs = errors.New("agentkit: tool arguments failed schema validation") )
Sentinel errors. Match them with errors.Is; a partial *Result accompanies every run error.
var DefaultRetry = RetryPolicy{MaxAttempts: 3, BaseDelay: 500 * time.Millisecond, MaxDelay: 30 * time.Second, Jitter: 0.2}
DefaultRetry is the policy agents use unless WithRetry overrides it.
Functions ¶
func Map ¶
func Map[In, Out any](ctx context.Context, parallel int, items []In, fn func(context.Context, In) (Out, error)) ([]Out, error)
Map runs fn over items with bounded concurrency and returns results in input order. Errors are joined; on cancellation unrun items stay zero and the joined error includes ctx.Err().
func Progress ¶ added in v0.3.0
Progress reports interim output from inside a tool call as an EventToolProgress carrying the current ToolCall. It never touches the transcript and is a no-op outside a streaming run.
func ProgressWriter ¶ added in v0.3.0
ProgressWriter returns a Writer whose every Write becomes one Progress call, for streaming command output; it discards outside a streaming run.
func SchemaFor ¶
func SchemaFor[T any](opts ...FuncOption) (json.RawMessage, error)
SchemaFor derives the JSON Schema Func would use for T.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is an immutable configuration: a model, instructions, tools and limits. One Agent serves any number of concurrent runs.
func NewFromClient ¶
NewFromClient builds an Agent around an existing client (or a fake).
func (*Agent) Client ¶ added in v0.3.0
Client returns the llmkit client (or fake) the agent talks to.
func (*Agent) RunMessages ¶
func (a *Agent) RunMessages(ctx context.Context, msgs []core.Message, opts ...RunOption) (*Result, error)
RunMessages is Run with caller-built messages appended to the session.
func (*Agent) Stream ¶
func (a *Agent) Stream(ctx context.Context, input string, opts ...RunOption) iter.Seq2[Event, error]
Stream is Run yielding events as they happen. The final event is EventFinish.
func (*Agent) StreamMessages ¶
func (a *Agent) StreamMessages(ctx context.Context, msgs []core.Message, opts ...RunOption) iter.Seq2[Event, error]
StreamMessages is Stream with caller-built messages.
type Approver ¶ added in v0.3.0
Approver decides whether a tool call may run. Approve may block for as long as it needs (a person may be asked); return ctx.Err() when ctx ends. It is called from a tool worker goroutine when WithParallel is above one.
type ApproverFunc ¶ added in v0.3.0
ApproverFunc adapts a function to Approver.
type AsToolOption ¶
type AsToolOption func(*subAgentTool)
AsToolOption configures AsTool.
func WithForwardEvents ¶
func WithForwardEvents() AsToolOption
WithForwardEvents surfaces the child's events in the parent's stream. Every child event, its EventFinish included, is forwarded with the child's own RunID and Depth and with Parent set to the enclosing run's ID. Without the option, or when the parent is not streaming, the child runs silently.
type Budget ¶
type Budget struct {
MaxSteps int // model calls; default 10
MaxTokens int // cumulative Usage.TotalTokens; 0 = unlimited
MaxToolCalls int // 0 = unlimited
MaxHandoffs int // default 5
Timeout time.Duration // 0 = none
}
Budget bounds a run. Zero values take the documented defaults.
type BudgetError ¶
BudgetError reports which Budget limit stopped a run.
func (*BudgetError) Unwrap ¶
func (e *BudgetError) Unwrap() error
Unwrap lets errors.Is match ErrBudgetExceeded.
type CharEstimator ¶
CharEstimator divides text length by CharsPerToken and charges flat costs per message and per binary part. Zero fields take the defaults 4, 4, 800.
type CompactInfo ¶
CompactInfo describes a history compaction; Reason is "proactive" or "context_length".
type Compactor ¶
type Compactor interface {
Compact(ctx context.Context, msgs []core.Message, budgetTokens int) ([]core.Message, error)
}
Compactor shrinks the history sent to the model to roughly budgetTokens. Implementations must keep tool calls with their results.
func StripReasoning ¶ added in v0.3.0
func StripReasoning() Compactor
StripReasoning drops reasoning parts from every message and any message left empty by that. Use it in a Chain when a transcript must be replayed to a model that rejects another model's reasoning blocks (for example after switching models on a session); text and tool calls are untouched.
func Summarize ¶
func Summarize(c core.Chatter, keepTurns int, opts ...SummarizeOption) Compactor
Summarize replaces turns older than keepTurns with one model-written summary, inserted as a user message after the system prompt. keepTurns 0 replays nothing: the model sees only the system prompt and the summary. Summaries are memoised per dropped prefix so repeated runs in one process do not pay twice.
type CompactorFunc ¶
type CompactorFunc func(ctx context.Context, msgs []core.Message, budgetTokens int) ([]core.Message, error)
CompactorFunc adapts a function to Compactor.
type Decision ¶ added in v0.3.0
type Decision struct {
Allow bool
Arguments json.RawMessage
Reason string
}
Decision is an Approver's verdict on one tool call. Arguments, when set, replace the arguments handed to the tool; the assistant message in the transcript keeps what the model wrote.
func AllowWith ¶ added in v0.3.0
func AllowWith(args json.RawMessage) Decision
AllowWith approves the call with rewritten arguments.
type Event ¶
type Event struct {
Kind EventKind
RunID string
Agent string
Step int
Depth int
Parent string
Text string // EventText, EventReasoning, EventToolProgress
ToolCall *core.ToolCall // tool events and approval events
ToolResult *core.ToolResult
Duration time.Duration // EventToolResult, EventUsage
Err error // EventRetry, EventToolResult (the tool's Go error)
Usage *core.Usage // EventUsage: this model call only
FinishReason core.FinishReason
Decision *Decision // EventApprovalResult
Attempt int
Delay time.Duration
Before int
After int
Handoff *HandoffInfo
Result *Result
}
Event is one item of Agent.Stream. Events are always delivered on the goroutine that ranges over the stream, whatever WithParallel is set to. Exactly one EventFinish for the run itself ends a stream and carries the Result; on failure it is paired with the error. Events forwarded from a sub-agent (AsTool with WithForwardEvents) carry the child's RunID, a Depth greater than the run's own and Parent set to the enclosing run's ID; they include the child's own EventFinish.
type EventKind ¶
type EventKind uint8
EventKind discriminates streamed run events.
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore keeps one append-only JSON Lines file per session under a directory: each line is {"t":"<RFC3339Nano>","m":<Message>} and Append writes with O_APPEND and fsync, so an interrupted write costs at most the line being written, which Load drops. Sessions written by earlier versions as one JSON array (<id>.json) are still readable and are migrated to the line format on their first Append. The directory is created on first Append.
func NewFileStore ¶
NewFileStore returns a FileStore rooted at dir; no I/O happens here.
type FuncOption ¶
type FuncOption func(*funcConfig)
FuncOption tunes schema generation for Func and NewFunc.
func WithEnum ¶
func WithEnum[T ~string](values ...T) FuncOption
WithEnum constrains every field of type T to the given values.
func WithForOptions ¶
func WithForOptions(o *jsonschema.ForOptions) FuncOption
WithForOptions passes options through to jsonschema.For.
func WithSchema ¶
func WithSchema(params json.RawMessage) FuncOption
WithSchema supplies the full parameter schema instead of deriving it.
func WithStrict ¶
func WithStrict() FuncOption
WithStrict marks the tool for OpenAI strict mode. Every property must then be required, so avoid omitempty fields.
func WithoutValidation ¶
func WithoutValidation() FuncOption
WithoutValidation skips schema validation of incoming arguments.
type HandoffInfo ¶
HandoffInfo describes control passing to another agent.
type Hooks ¶
type Hooks struct {
OnRunStart func(RunInfo)
OnStep func(StepInfo)
OnModelCall func(ModelCallInfo)
OnModelResponse func(ModelResponseInfo)
OnToolCall func(ToolCallInfo)
OnToolResult func(ToolResultInfo)
OnRetry func(RetryInfo)
OnCompact func(CompactInfo)
OnHandoff func(HandoffInfo)
OnRunEnd func(*Result, error)
}
Hooks receive callbacks during a run. Every field is optional. Tool hooks may fire from worker goroutines when WithParallel is above one.
type Inbox ¶ added in v0.3.0
type Inbox struct {
// contains filtered or unexported fields
}
Inbox queues user messages for a run that is already in progress. The loop drains it at step boundaries: before every model call and, when the model stops with plain text, instead of finishing, so a message posted while tools run lands after their results. Drained messages are appended to the transcript and the session store like any user turn. Safe for concurrent use; one Inbox may serve several runs but each message goes to one of them.
func (*Inbox) Post ¶ added in v0.3.0
Post queues a user message built from parts; no parts is a no-op.
func (*Inbox) PostMessage ¶ added in v0.3.0
PostMessage queues a caller-built message.
type Lister ¶ added in v0.3.0
type Lister interface {
List(ctx context.Context) ([]SessionInfo, error)
}
Lister is implemented by stores that can enumerate their sessions, most recently updated first.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore keeps sessions in process memory.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore returns an empty MemoryStore.
func (*MemoryStore) Delete ¶
func (s *MemoryStore) Delete(_ context.Context, sessionID string) error
Delete forgets the session.
func (*MemoryStore) List ¶ added in v0.3.0
func (s *MemoryStore) List(_ context.Context) ([]SessionInfo, error)
List implements Lister.
type Middleware ¶
Middleware wraps a Tool. Wrap applies the first middleware outermost.
func Approve ¶
func Approve(fn func(ctx context.Context, c Call) error) Middleware
Approve gates each call; a non-nil error from fn is fed back to the model as an error result wrapping ErrApprovalDenied. Cancel ctx inside fn to abort the run instead. It is ApproveWith over an Approver that denies on error.
func ApproveWith ¶ added in v0.3.0
func ApproveWith(ap Approver) Middleware
ApproveWith gates each call through ap. In a streaming run an EventApprovalRequest precedes the Approver and an EventApprovalResult carries its Decision, so a UI can show the pending call and answer it asynchronously. A denial (or an Approver error) becomes an error result wrapping ErrApprovalDenied and the run continues; when ctx ends while approval is pending, ctx.Err() is returned so the run stops as canceled. Rewritten arguments reach the tool but are not written back into the transcript.
func Recover ¶
func Recover() Middleware
Recover turns a panic inside the tool into an error result.
func Serial ¶
func Serial() Middleware
Serial marks the tool as never running concurrently with other tool calls.
type ModelCallInfo ¶
ModelCallInfo describes a request about to be sent; treat Request as read-only.
type ModelResponseInfo ¶
type ModelResponseInfo struct {
RunID string
Agent string
Step int
Response *core.Response
Duration time.Duration
Err error
}
ModelResponseInfo describes a completed model call.
type Option ¶
Option configures an Agent.
func WithAdditionalInstructions ¶ added in v0.2.0
WithAdditionalInstructions appends sections to the system prompt after the text set by WithInstructions, whatever the option order. Empty sections are dropped; sections are separated by a blank line.
func WithCache ¶ added in v0.3.0
func WithCache(c core.CacheConfig) Option
WithCache asks providers with explicit prompt caching to place cache breakpoints on every request; see core.CacheConfig. {System: true, Turns: 1} keeps the instructions and tool definitions cached across a whole session while the trailing turn moves.
func WithClientOptions ¶
WithClientOptions passes options to the llmkit client (New only).
func WithCompactor ¶
WithCompactor shapes the history sent to the model when it grows too large.
func WithContextWindow ¶
WithContextWindow enables proactive compaction when the estimated prompt exceeds 90% of tokens.
func WithEstimator ¶
WithEstimator replaces the token estimator used for proactive compaction.
func WithInstructions ¶
WithInstructions sets the system prompt.
func WithMaxTokens ¶
WithMaxTokens caps output tokens per model call.
func WithMiddleware ¶
func WithMiddleware(mws ...Middleware) Option
WithMiddleware wraps every tool of the agent, including Recall and sub-agents.
func WithParallel ¶
WithParallel allows up to n tool calls of one step to run concurrently.
func WithProviderOptions ¶
WithProviderOptions merges provider-keyed raw fields into every request.
func WithReasoning ¶
func WithReasoning(r core.ReasoningConfig) Option
WithReasoning enables extended thinking where supported.
func WithRegistry ¶
WithRegistry resolves the model against a specific llmkit registry (New only).
func WithRequestExtra ¶
WithRequestExtra merges raw fields into every request body.
func WithRetriever ¶
WithRetriever adds a "recall" tool returning the k best matches.
func WithTemperature ¶
WithTemperature sets the sampling temperature.
func WithToolChoice ¶
func WithToolChoice(tc core.ToolChoice) Option
WithToolChoice sets the request tool choice.
type Output ¶
Output is what a tool hands back to the model. IsError marks a tool-level failure the model should see; a Go error from Call means the same and is also reported to Hooks.
type OutputMode ¶
type OutputMode uint8
OutputMode selects how Run[T] obtains structured output.
const ( OutputAuto OutputMode = iota // schema for tool-less agents, tool otherwise OutputSchema // provider json_schema response format OutputTool // synthetic final_answer tool )
Output modes.
type Pinned ¶ added in v0.2.0
type Pinned interface {
Pinned() bool
}
Pinned is implemented by tools whose successful results must stay visible to the model after compaction. When a compactor drops the turn holding such a result, the loop re-sends its content inside the system prompt of every later request; the transcript and the session store are not changed. Pinned content can never be compacted away, so keep it small.
type Result ¶
type Result struct {
RunID string
Agent string
Output string
Message core.Message
Messages []core.Message
New []core.Message
Usage core.Usage
Steps int
ToolCalls int
Handoffs int
FinishReason core.FinishReason
StopReason StopReason
Duration time.Duration
}
Result is the outcome of a run. On error it is partial but always present.
type RetryInfo ¶
type RetryInfo struct {
RunID string
Agent string
Step int
Attempt int
Delay time.Duration
Err error
}
RetryInfo describes a model-call retry.
type RetryPolicy ¶
type RetryPolicy struct {
MaxAttempts int // total attempts; default 3, 1 disables retries
BaseDelay time.Duration // default 500ms
MaxDelay time.Duration // default 30s
Jitter float64 // fraction of the delay, default 0.2
}
RetryPolicy governs retries of model calls. Tools are never retried.
func (RetryPolicy) Delay ¶
func (p RetryPolicy) Delay(attempt int, err error) time.Duration
Delay returns how long to wait before the given 1-based retry attempt, honoring a Retry-After hint when the error carries one.
func (RetryPolicy) Retryable ¶
func (p RetryPolicy) Retryable(err error) bool
Retryable reports whether err is transient: rate limits, 5xx and transport failures. Context errors, other 4xx and ErrContextLength are not.
type RunOption ¶
type RunOption func(*runConfig)
RunOption configures one run.
func WithOutputMode ¶
func WithOutputMode(m OutputMode) RunOption
WithOutputMode overrides how Run[T] obtains structured output.
func WithRunHooks ¶
WithRunHooks adds observers for this run only.
func WithSession ¶
WithSession loads history from the agent's Store before the run and appends the new messages afterwards.
type Sequential ¶
type Sequential interface {
Sequential() bool
}
Sequential is implemented by tools that must not run concurrently with other tool calls from the same step. Serial adds it; MCP tools may declare it.
type SessionInfo ¶ added in v0.3.0
type SessionInfo struct {
ID string
Created time.Time
Updated time.Time
Messages int
Title string // first line of the first user message, at most 80 runes
}
SessionInfo summarizes a stored session without loading it.
type StopReason ¶
type StopReason string
StopReason says why a run ended.
const ( StopCompleted StopReason = "completed" StopFinalAnswer StopReason = "final_answer" StopMaxSteps StopReason = "max_steps" StopMaxTokens StopReason = "max_tokens" StopMaxToolCalls StopReason = "max_tool_calls" StopDeadline StopReason = "deadline" StopCancelled StopReason = "canceled" StopError StopReason = "error" )
Stop reasons.
type Store ¶
type Store interface {
Load(ctx context.Context, sessionID string) ([]core.Message, error)
Append(ctx context.Context, sessionID string, msgs ...core.Message) error
}
Store persists conversations by session ID. Load returns nil for an unknown session. Stores hold the lossless transcript; compaction never touches them.
type SummarizeOption ¶
type SummarizeOption func(*summarizer)
SummarizeOption configures Summarize.
func WithSummaryEstimator ¶
func WithSummaryEstimator(e Estimator) SummarizeOption
WithSummaryEstimator replaces the estimator used to decide how much to drop.
func WithSummaryPrompt ¶
func WithSummaryPrompt(prompt string) SummarizeOption
WithSummaryPrompt replaces the instruction sent to the summarizing model.
type Tool ¶
type Tool interface {
Definition() core.Tool
Call(ctx context.Context, args json.RawMessage) (Output, error)
}
Tool is anything the model may call.
func AsTool ¶
func AsTool(a *Agent, name, description string, opts ...AsToolOption) Tool
AsTool exposes an agent as a tool taking {"input": string}. The child runs with its own budget, one level deeper, and only its final text comes back; its token usage is added to the parent's.
func Func ¶
func Func[In, Out any](name, description string, fn func(context.Context, In) (Out, error), opts ...FuncOption) Tool
Func builds a Tool whose arguments are decoded into In and whose result is Out. The schema is derived from In; arguments are validated against it before decoding. Func panics when In cannot be represented; use NewFunc for a recoverable error.
func Handoff ¶
Handoff builds a tool that transfers the conversation to one of the target agents: the system prompt, tools and model switch while the transcript is carried over. Give targets their own Handoff tool to allow handing back.
func NewFunc ¶
func NewFunc[In, Out any](name, description string, fn func(context.Context, In) (Out, error), opts ...FuncOption) (Tool, error)
NewFunc is Func returning an error instead of panicking.
func Raw ¶
func Raw(name, description string, params json.RawMessage, fn func(context.Context, json.RawMessage) (Output, error)) Tool
Raw builds a Tool from a hand-written JSON Schema.
func Wrap ¶
func Wrap(t Tool, mws ...Middleware) Tool
Wrap applies mws to t; nil middleware is skipped.
type ToolCallInfo ¶
type ToolCallInfo struct {
Call Call
}
ToolCallInfo describes a tool about to run.
type ToolResultInfo ¶
ToolResultInfo describes a finished tool call.
type Toolset ¶
type Toolset []Tool
Toolset is an ordered list of tools.
func (Toolset) Definitions ¶
Definitions returns the core.Tool definitions in order.
type VectorMemory ¶
type VectorMemory struct {
// contains filtered or unexported fields
}
VectorMemory is an in-memory store of texts searched by cosine similarity.
func NewVectorMemory ¶
func NewVectorMemory(e core.Embedder, opts ...VectorOption) *VectorMemory
NewVectorMemory builds an empty memory over the embedder.
type VectorOption ¶
type VectorOption func(*VectorMemory)
VectorOption configures VectorMemory.
func WithDimensions ¶
func WithDimensions(n int) VectorOption
WithDimensions requests a fixed embedding size from the embedder.
func WithReranker ¶
func WithReranker(r core.Reranker) VectorOption
WithReranker reorders the top candidates with a cross-encoder.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
internal/fake
Package fake registers an in-process OpenAI-compatible provider so the examples run offline.
|
Package fake registers an in-process OpenAI-compatible provider so the examples run offline. |
|
multiagent
command
Command multiagent shows a sub-agent exposed as a tool and a parallel Map.
|
Command multiagent shows a sub-agent exposed as a tool and a parallel Map. |
|
skills
command
Command skills shows Agent Skills loaded from an embedded filesystem.
|
Command skills shows Agent Skills loaded from an embedded filesystem. |
|
tools
command
Command tools shows a typed tool driven by the agent loop.
|
Command tools shows a typed tool driven by the agent loop. |
|
typed
command
Command typed shows Run[T]: the agent must return a value matching a Go struct.
|
Command typed shows Run[T]: the agent must return a value matching a Go struct. |
|
internal
|
|
|
atomicfile
Package atomicfile writes files via a temporary sibling and rename.
|
Package atomicfile writes files via a temporary sibling and rename. |
|
pool
Package pool runs functions over a slice with bounded concurrency, preserving input order in the results.
|
Package pool runs functions over a slice with bounded concurrency, preserving input order in the results. |
|
mcp
module
|
|
|
Package skills loads Agent Skills (https://agentskills.io) and exposes them to an agent with progressive disclosure: the catalog of names and descriptions goes into the system prompt, the full SKILL.md body is returned by the "skill" tool when the model activates a skill, and bundled files are read on demand through the "skill_file" tool.
|
Package skills loads Agent Skills (https://agentskills.io) and exposes them to an agent with progressive disclosure: the catalog of names and descriptions goes into the system prompt, the full SKILL.md body is returned by the "skill" tool when the model activates a skill, and bundled files are read on demand through the "skill_file" tool. |
|
Package slogx adapts agentkit.Hooks to log/slog.
|
Package slogx adapts agentkit.Hooks to log/slog. |