research

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvancedRunner added in v0.1.4

type AdvancedRunner interface {
	Runner
	ExecuteWithOptions(context.Context, Plan, ExecuteOptions) (Evidence, error)
}

AdvancedRunner is the optional V3 contract. Dispatcher uses it when model advice or live research progress is enabled, while older Runner implementations continue to work unchanged.

type Advisor added in v0.1.4

type Advisor = decision.Advisor

type AgentConfig added in v0.1.4

type AgentConfig struct {
	Protocol    Protocol
	CacheDir    string
	Providers   []string
	GitHubToken string
	Resilience  searchsystem.ResilienceConfig
}

type AgentExecutor added in v0.1.4

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

AgentExecutor adapts the layered Research Agent back to the existing dispatcher contract.

func NewResearchAgent added in v0.1.4

func NewResearchAgent() *AgentExecutor

func NewResearchAgentWithConfig added in v0.1.4

func NewResearchAgentWithConfig(config AgentConfig) *AgentExecutor

func (*AgentExecutor) Execute added in v0.1.4

func (e *AgentExecutor) Execute(ctx context.Context, plan Plan) (Evidence, error)

func (*AgentExecutor) ExecuteWithOptions added in v0.1.4

func (e *AgentExecutor) ExecuteWithOptions(ctx context.Context, plan Plan, options ExecuteOptions) (Evidence, error)

type Claim added in v0.1.4

type Claim struct {
	Text         string
	SourceIDs    []string
	Verification string
	Confidence   float64
}

type Contradiction added in v0.1.4

type Contradiction struct {
	ClaimIDs []string
	Summary  string
	Severity string
}

type Evidence

type Evidence struct {
	Plan           Plan
	Sources        []Source
	Claims         []Claim
	Contradictions []Contradiction
	Gaps           []ResearchGap
	AttemptedQuery []string
	Failures       []string
	Observations   []Observation
	Metrics        Metrics
	LimitReached   bool
	ContextLimit   int
	StopReason     string
	Confidence     float64
}

Evidence is the bounded, structured research result exposed to Dispatcher.

func (Evidence) ContextSection

func (e Evidence) ContextSection() string

ContextSection serializes ranked evidence as model context. Page text remains explicitly untrusted and cannot override system instructions.

func (Evidence) FallbackAnswer

func (e Evidence) FallbackAnswer() string

func (Evidence) NeedsRepair

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

NeedsRepair detects narrow, objectively invalid research answers.

func (Evidence) RepairInstruction

func (e Evidence) RepairInstruction(reason string) string

type ExecuteOptions added in v0.1.4

type ExecuteOptions struct {
	Advisor              Advisor
	EnableModelPlanning  bool
	EnableSemanticVerify bool
	MaxAdvisorClaims     int
	OnProgress           func(Progress) error
}

type Kind

type Kind string

Kind identifies a deterministic research workflow.

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

type Metrics

type Metrics struct {
	PlannerIterations int
	ToolCalls         int
	SearchCalls       int
	FetchCalls        int
	CacheHits         int
	AdvisorCalls      int
	PromptTokens      int
	CompletionTokens  int
	TotalTokens       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
	ResearchGoal     string
	Constraints      []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 Progress added in v0.1.4

type Progress = decision.Progress

type Protocol

type Protocol struct {
	MaxSearches          int
	MaxFetches           int
	MaxResearchRounds    int
	ResultsPerSearch     int
	MaxPlannerIterations int
	MaxExecutionTime     time.Duration
	SearchCacheTTL       time.Duration
	FetchCacheTTL        time.Duration
	ResearchCacheTTL     time.Duration
	NewsCacheTTL         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 ResearchGap added in v0.1.4

type ResearchGap struct {
	Code        string
	Description string
	Priority    int
}

type Runner added in v0.1.4

type Runner interface {
	Execute(context.Context, Plan) (Evidence, error)
}

Runner is the stable dispatcher-facing research contract.

type Source

type Source struct {
	ID               string
	Title            string
	URL              string
	Snippet          string
	Content          string
	Provider         string
	TrustScore       float64
	TrustLevel       string
	RelevanceScore   float64
	FreshnessScore   float64
	EvidenceScore    float64
	PublishedAt      time.Time
	VerificationNote string
}

type ValuablePage added in v0.1.4

type ValuablePage = decision.ValuablePage

Directories

Path Synopsis
Package decision implements the research decision layer.
Package decision implements the research decision layer.
Package evidence turns retrieved documents into ranked, attributable facts.
Package evidence turns retrieved documents into ranked, attributable facts.
Package searchsystem implements the capability layer of the research stack.
Package searchsystem implements the capability layer of the research stack.

Jump to

Keyboard shortcuts

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