Documentation
¶
Overview ¶
Package summarize provides pluggable tool result summarization hooks.
Use summarize.Passthrough for proxy tools before domain summarizers exist. Use summarize.Meta to pass context from present hooks to summarizers. Limit is the common cross-app field; SinceSeq, RunID, and Extra are optional.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToolListItems ¶
func ToolListItems[T any](items []T, total int, meta Meta, spec ToolListSummary[T]) (summary string, next []string)
ToolListItems builds envelope summary and next hints from a counted tool list payload.
Types ¶
type Meta ¶
type Meta struct {
Limit int // List cap applied during present.
SinceSeq int // Optional paging cursor.
RunID string // Optional entity id context.
Extra map[string]any // App-specific present→summarize context.
}
Meta carries presentation metadata from prepare/present hooks to summarizers.
Named fields are optional convenience slots for common patterns. Extra is an open bag for app-specific context. Summarizers should ignore fields they do not use.
type Registry ¶
type Registry struct {
Summarize SummaryFunc
Subjects SubjectsFunc
}
Registry holds pluggable summarization hooks for a tool server.
func Default ¶
func Default() *Registry
Default returns a registry that uses the tool name as summary.
func Passthrough ¶
func Passthrough() *Registry
Passthrough returns a registry that uses the tool name as summary and omits subjects. Use with summarize.NewResponder for proxy tools before domain summarizers are ready.
func RegistryFromSummaries ¶
func RegistryFromSummaries(summaries ToolSummaries) *Registry
RegistryFromSummaries builds a Registry backed by per-tool summarizers.
type Responder ¶
Responder builds MCP tool results from envelopes using a registry.
func NewResponder ¶
NewResponder returns a responder with the given registry or Default when nil.
type SubjectsFunc ¶
SubjectsFunc returns entity references extracted from a tool result.
type SummaryFunc ¶
SummaryFunc returns a short summary and continuation hints for a tool result.
type ToolListSummary ¶
type ToolListSummary[T any] struct { CountLabel string Next []string PageHint string SampleSize int NextFor func(T) []string }
ToolListSummary configures summary and next-hint generation for a list tool result.
type ToolSummaries ¶
type ToolSummaries map[string]ToolSummary
ToolSummaries maps MCP tool names to result summarizers.