research

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Evidence

type Evidence struct {
	Plan           Plan
	Sources        []Source
	AttemptedQuery []string
	Failures       []string
	Observations   []Observation
	Metrics        Metrics
	LimitReached   bool
	ContextLimit   int
}

Evidence is safe, bounded context collected for the model.

func (Evidence) ContextSection

func (e Evidence) ContextSection() string

ContextSection serializes evidence as internal model context. It explicitly labels web content as untrusted so page text cannot become instructions.

func (Evidence) FallbackAnswer

func (e Evidence) FallbackAnswer() string

func (Evidence) NeedsRepair

func (e Evidence) NeedsRepair(content string) (bool, string)

NeedsRepair detects a small set of objectively invalid research answers. This is deliberately narrow: it does not attempt to grade writing quality.

func (Evidence) RepairInstruction

func (e Evidence) RepairInstruction(reason string) string

type Executor

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

Executor performs the bounded, deterministic retrieval phase before the LLM starts reasoning. Functions are injectable so behavior can be tested without network access.

func NewExecutor

func NewExecutor() *Executor

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, plan Plan) (evidence Evidence, resultErr error)

Execute searches in parallel, selects diverse URLs, and fetches the bounded source set. Individual network/source failures are recoverable; cancellation remains fatal so the user's Stop action is immediate.

type Kind

type Kind string

Kind identifies a deterministic research workflow.

const (
	KindNone       Kind = ""
	KindNews       Kind = "news"
	KindTravel     Kind = "travel"
	KindComparison Kind = "comparison"
	KindResearch   Kind = "research"
)

type Metrics

type Metrics struct {
	PlannerIterations int
	ToolCalls         int
	SearchCalls       int
	FetchCalls        int
	CacheHits         int
	ElapsedMS         int64
}

Metrics summarizes a complete deterministic research pass.

type Observation

type Observation struct {
	Tool       string
	Status     string
	Summary    string
	ErrorCode  string
	ElapsedMS  int64
	Confidence float64
	CacheHit   bool
	Target     string
}

Observation is the compact, provider-independent result of one tool call. Raw HTML and large provider payloads are deliberately excluded.

type Plan

type Plan struct {
	Kind             Kind
	Queries          []string
	SeedURLs         []string
	MinSources       int
	MaxSources       int
	Date             string
	ResolvedRequest  string
	ResponseLanguage string
}

Plan is the code-owned contract for one research pass.

func Analyze

func Analyze(prompt string, requestContext map[string]any, now time.Time) Plan

Analyze recognizes research-heavy work and creates bounded search queries. Weather is intentionally handled by its location-aware path instead of a generic web query, which prevents searches such as "today weather".

func AnalyzeConversation

func AnalyzeConversation(prompt string, previousUserPrompts []string, requestContext map[string]any, now time.Time) Plan

AnalyzeConversation carries short user refinements such as "Tokyo" or "自驾" into the latest research task instead of treating them as new tasks.

type Protocol

type Protocol struct {
	MaxSearches          int
	MaxFetches           int
	MaxPlannerIterations int
	MaxExecutionTime     time.Duration
	SearchCacheTTL       time.Duration
	FetchCacheTTL        time.Duration
	MaxContextChars      int
	SearchInterval       time.Duration
	FetchInterval        time.Duration
	PerDomainInterval    time.Duration
	MaxFetchRetries      int
	RetryBackoff         time.Duration
}

Protocol defines the deterministic limits around the model-independent research phase. The zero value is normalized to DefaultProtocol.

func DefaultProtocol

func DefaultProtocol() Protocol

DefaultProtocol implements Agent Protocol v1.0 limits.

type Source

type Source struct {
	Title      string
	URL        string
	Snippet    string
	Content    string
	TrustScore float64
	TrustLevel string
}

Jump to

Keyboard shortcuts

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