Documentation
¶
Index ¶
Constants ¶
const ( // AdvisorSystemPrompt steers the nested advisor model to help the parent // agent rather than speaking directly to the end user. AdvisorSystemPrompt = `` /* 426-byte string literal not displayed */ // ParentGuidanceBlock is a reusable prompt block for teaching parent agents // when to invoke the built-in advisor tool. ParentGuidanceBlock = `` /* 482-byte string literal not displayed */ // LimitReachedAdvice is returned when the per-run advisor budget is // exhausted, telling the parent agent to stop calling the advisor. LimitReachedAdvice = "The advisor budget for this turn is exhausted. Do not call the advisor again this turn; proceed with your own judgment." )
const ToolName = "advisor"
ToolName is the identifier the advisor tool registers under. The parent agent's exclusive-tool policy and the advisor-guidance block both reference this name, so keeping them synchronized requires a single source of truth.
Variables ¶
This section is empty.
Functions ¶
func BuildAdvisorMessages ¶
func BuildAdvisorMessages( question string, conversationSnapshot []fantasy.Message, ) []fantasy.Message
BuildAdvisorMessages prepares a nested advisor prompt using the recent chat context plus the explicit advisor question.
func Tool ¶
func Tool(opts ToolOptions) fantasy.AgentTool
Tool returns a fantasy.AgentTool that asks a nested model for concise strategic guidance. The nested advisor sees recent conversation context, runs without tools, and is limited to a single model step.
Types ¶
type AdvisorArgs ¶
type AdvisorArgs struct {
Question string `` /* 155-byte string literal not displayed */
}
type AdvisorResult ¶
type AdvisorResult struct {
Type ResultType `json:"type"`
Advice string `json:"advice,omitempty"`
Error string `json:"error,omitempty"`
AdvisorModel string `json:"advisor_model,omitempty"`
RemainingUses int `json:"remaining_uses"`
}
AdvisorResult is the structured result returned by the advisor runtime.
type ResultType ¶
type ResultType string
ResultType is the tagged variant of AdvisorResult. Callers should compare against the exported constants rather than string literals.
const ( // ResultTypeAdvice indicates the advisor returned guidance. ResultTypeAdvice ResultType = "advice" // ResultTypeLimitReached indicates the per-run advisor budget is exhausted. ResultTypeLimitReached ResultType = "limit_reached" // ResultTypeError indicates the nested advisor run failed. ResultTypeError ResultType = "error" )
type RunAdvisorOptions ¶
type RunAdvisorOptions struct {
OnAdviceDelta func(delta string)
OnReasoningDelta func(delta string)
OnLiveOutputReset func()
}
RunAdvisorOptions carries optional streaming callbacks for a single RunAdvisor invocation.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime executes nested, tool-less advisor runs against the configured language model.
Each Runtime instance is scoped to a single outer chat run. The MaxUsesPerRun counter increments on every successful advisor call and is never reset, so callers must construct a fresh Runtime (via NewRuntime) for each outer run. There is intentionally no Reset method: the per-run quota is a safety bound on a single run, not a rolling window.
func NewRuntime ¶
func NewRuntime(cfg RuntimeConfig) (*Runtime, error)
NewRuntime validates and normalizes advisor runtime configuration.
func (*Runtime) RemainingUses ¶
RemainingUses reports how many advisor calls are still available for the current runtime.
func (*Runtime) RunAdvisor ¶
func (rt *Runtime) RunAdvisor( ctx context.Context, question string, conversationSnapshot []fantasy.Message, opts *RunAdvisorOptions, ) (AdvisorResult, error)
RunAdvisor executes a single, tool-less nested advisor call.
type RuntimeConfig ¶
type RuntimeConfig struct {
Model fantasy.LanguageModel
// CallTemplate's provider options are cloned for each nested call.
CallTemplate fantasy.Call
MaxUsesPerRun int
MaxOutputTokens int64
StreamSilenceTimeout time.Duration
// MaxRetries is the maximum number of retries after a transient
// provider error within one advisor call. It must be positive.
MaxRetries int
}
RuntimeConfig configures a single advisor runtime instance.
type ToolOptions ¶
ToolOptions configures the built-in advisor tool.