agentutils

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package agentutils provides utilities used by the agent and orchestrator layer.

It solves the problem of condensing verbose tool outputs and content into structured formats (JSON, Text, YAML) before passing them to the LLM or downstream consumers. Without it, long tool responses would consume context window and obscure the relevant information.

The main component is Summarizer: it uses a lightweight LLM model to produce context-aware summaries in a requested output format, so that agents can work with concise, structured data instead of raw payloads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSummarizerTool

func NewSummarizerTool(s Summarizer) tool.Tool

NewSummarizerTool returns a tool.Tool named "summarize_content" that wraps the given Summarizer. Other agents can include this tool in their tool registry to get on-demand summarization of verbose content. Without this, agents would need direct access to the Summarizer interface rather than the standard tool-calling mechanism.

func SetSkipSummarize added in v0.1.7

func SetSkipSummarize(ctx context.Context)

SetSkipSummarize instructs the upstream auto-summarize middleware to bypass summarization for the current tool call, returning its verbatim output.

Types

type OutputFormat

type OutputFormat string

OutputFormat controls the structure of the summarized output. Supported values are JSON, Text, and YAML.

const (
	// OutputFormatJSON instructs the summarizer to produce a JSON-formatted summary.
	OutputFormatJSON OutputFormat = "JSON"

	// OutputFormatText instructs the summarizer to produce a plain-text summary.
	OutputFormatText OutputFormat = "TEXT"

	// OutputFormatMarkdown instructs the summarizer to produce a markdown-formatted summary.
	OutputFormatMarkdown OutputFormat = "MARKDOWN"

	// OutputFormatYAML instructs the summarizer to produce a YAML-formatted summary.
	OutputFormatYAML OutputFormat = "YAML"
)

type SummarizeRequest

type SummarizeRequest struct {
	Content              string       `json:"content" jsonschema:"description=The content to summarize,required"`
	RequiredOutputFormat OutputFormat `` /* 129-byte string literal not displayed */
}

SummarizeRequest is the input for both the Summarizer.Summarize method and the summarize_content tool. Content is the raw text to summarize and RequiredOutputFormat determines the structure of the result.

type Summarizer

type Summarizer interface {
	Summarize(ctx context.Context, req SummarizeRequest) (string, error)
}

Summarizer produces context-aware summaries using a lightweight LLM model. It exists so that tool outputs and other verbose content can be condensed into structured formats (JSON, Text, YAML) before being presented to downstream consumers. Without this, callers would need to implement their own prompt engineering and LLM orchestration for summarization.

func NewSummarizer

func NewSummarizer(ctx context.Context, modelProvider modelprovider.ModelProvider, auditor audit.Auditor) (Summarizer, error)

NewSummarizer creates a new Summarizer that uses the frontdesk (fast, cheap) model to condense content into the requested output format. The returned Summarizer makes single, tool-free LLM calls, keeping latency and cost minimal. Without this constructor, callers would need to manually wire an expert.Expert with the correct system prompt and task type for summarization.

func NewSummarizerWithExpert

func NewSummarizerWithExpert(exp expert.Expert) Summarizer

NewSummarizerWithExpert creates a Summarizer using a pre-built expert.Expert. This is primarily useful in tests where the caller wants to inject a stub or fake expert without needing a real model provider. Without this constructor, tests would need to set up a full model provider and audit infrastructure just to test summarization logic.

type SummarizerToolProvider

type SummarizerToolProvider struct {
	// contains filtered or unexported fields
}

SummarizerToolProvider wraps a Summarizer and satisfies the tools.ToolProviders interface so the summarize_content tool can be passed directly to tools.NewRegistry.

func NewSummarizerToolProvider

func NewSummarizerToolProvider(s Summarizer) *SummarizerToolProvider

NewSummarizerToolProvider creates a ToolProvider for the summarizer tool.

func (*SummarizerToolProvider) GetTools

func (p *SummarizerToolProvider) GetTools() []tool.Tool

GetTools returns the summarizer tool.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL