agentic

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgenticFetchURL

func AgenticFetchURL(opts AgenticToolOpts) tool.Tool

AgenticFetchURL wraps fetch_url in a subtask that fetches the URL and returns the relevant section. Use instead of the bare fetch_url when the page is likely long (documentation, articles, search results) and you only need a specific answer. The full fetched HTML/text never enters the parent's context.

Subtask tool requirements (InnerTools): the canonical "fetch_url" tool. Defaults to 2 turns.

func AgenticGrep

func AgenticGrep(opts AgenticToolOpts) tool.Tool

AgenticGrep wraps grep in a subtask that ranks and summarizes matches. Use instead of the bare grep when the pattern is likely to hit many matches and you only care about the most relevant few. The raw match list never enters the parent's context.

Subtask tool requirements (InnerTools): the canonical "grep" tool. "read_file" is also supplied so a subtask can pull surrounding context when the operator's question genuinely demands it, but the default subtask prompt steers AWAY from that — see below. Defaults to 2 turns since #60 — the earlier 3-turn default invited Flash to do too many tool round trips on cross-corpus searches and confabulate file:line content. Two turns forces the subtask into grep → digest. Operators with rich-context needs can raise via opts.Budgets — at the cost of larger hallucination surface on weaker subtask models.

func AgenticReadFile

func AgenticReadFile(opts AgenticToolOpts) tool.Tool

AgenticReadFile wraps read_file in a subtask that reads the target file and returns a focused excerpt or summary. Use instead of the bare read_file when the file might be large and the model only needs a specific section — common for config files, large source files, or long logs.

Subtask tool requirements (InnerTools): the canonical "read_file" tool. Defaults to 2 turns when Budgets.MaxTurns is zero (read + summarize, no spiraling).

func AgenticResearch

func AgenticResearch(opts AgenticToolOpts) tool.Tool

AgenticResearch wraps an open-ended exploration in a subtask that can use a broader read-only toolset to investigate a question. Use for "understand how X works" / "trace the data flow from A to B" / "what's the convention for Y in this codebase" — questions that need multiple file reads and greps but whose intermediate exploration is noise to the parent.

Subtask tool requirements (InnerTools): read_file + grep + list_dir + glob (the standard read-only investigation kit). Defaults to 5 turns (the design doc's "broad research dispatch" budget); raise via opts.Budgets for genuinely open-ended questions.

Types

type AgenticToolOpts

type AgenticToolOpts struct {
	// AgentGetter returns the *Agent the wrapper should call
	// RunSubtask on. Required. Pass a closure that captures the
	// agent pointer the consumer will populate after agent.New
	// returns. A nil return is treated as "registration race
	// not yet complete" and the tool reports a clear error to
	// the model (defensive; shouldn't happen in practice).
	AgentGetter func() *agent.Agent

	// Provider + SmallModelID resolve the subtask's model on
	// first call (and cache it). When SmallModelID is "" (or
	// Provider is nil), the wrapper omits SubtaskSpec.Model and
	// the subtask inherits the parent's model. Set
	// SmallModelID to a flash/haiku-tier model to realize the
	// cost-efficiency win the design doc calls out.
	Provider     models.Provider
	SmallModelID string

	// Budgets override SubtaskBudgetDefaults for this tool's
	// subtasks. Each preset constructor sets a sensible
	// Budgets.MaxTurns default when the caller leaves it zero;
	// override here to raise (or lower) the cap.
	Budgets agent.SubtaskBudgets

	// InnerTools is the set of tools the subtask is allowed to
	// call. Required. Each preset's docstring lists the
	// specific tools the subtask needs to do its job — pass
	// those instances (typically the ones you already
	// registered on the parent agent, so they share the same
	// permission gate and output caps).
	InnerTools []tool.Tool
}

AgenticToolOpts is shared configuration for every agentic wrapper. AgentGetter is the late-binding hook the wrappers need to call Agent.RunSubtask — same pattern as agent.NewMarkTaskDoneTool, because tool registration happens before agent.New returns.

Jump to

Keyboard shortcuts

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