strategy

package
v0.5.11 Latest Latest
Warning

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

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

Documentation

Overview

Package strategy 提供统一 agent loop 的可选执行策略。

三种策略(ReAct / PlanExecute / Reflection)都实现 runtime.Strategy 接口, 以「提示词引导 + 共享回合循环」的方式表达各自模式——运行在同一个统一 runtime 回合循环上,而非各自独立的 loop 实现。经 agent.WithStrategy 选用。

这是「统一 agent loop」的轻量落点:同一个 ReActAgent 通过切换 Strategy 即可 表现为 ReAct / 先规划后执行 / 自检反思。功能更丰富的多调用编排(独立的 PlanExecuteAgent / ReflectionAgent)与本路径并存,互不影响。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All() []hruntime.Strategy

All 返回全部内置策略(稳定顺序:react, plan-execute, reflection)。

func ByName

func ByName(name string) (hruntime.Strategy, bool)

ByName 按名称返回内置策略;未知名称返回 (nil, false)。

名称与各策略 Name() 一致:react / plan-execute / reflection。

Types

type PlanExecute

type PlanExecute struct{}

PlanExecute asks the model to plan before executing.

func (PlanExecute) AfterLLM

func (PlanExecute) BeforeTurn

func (PlanExecute) BuildSystemPrefix

func (PlanExecute) BuildSystemPrefix(context.Context, hruntime.Request) string

func (PlanExecute) Finalize

func (PlanExecute) Name

func (PlanExecute) Name() string

func (PlanExecute) ShouldContinue

func (PlanExecute) ShouldContinue(context.Context, *hruntime.State) bool

type ReAct

type ReAct struct{}

ReAct is the default reasoning/action strategy.

func (ReAct) AfterLLM

func (ReAct) AfterLLM(context.Context, *hruntime.State) error

func (ReAct) BeforeTurn

func (ReAct) BeforeTurn(context.Context, *hruntime.State) error

func (ReAct) BuildSystemPrefix

func (ReAct) BuildSystemPrefix(context.Context, hruntime.Request) string

func (ReAct) Finalize

func (ReAct) Finalize(context.Context, *hruntime.State) error

func (ReAct) Name

func (ReAct) Name() string

func (ReAct) ShouldContinue

func (ReAct) ShouldContinue(context.Context, *hruntime.State) bool

type Reflection

type Reflection struct{}

Reflection asks the model to self-check before finalizing.

func (Reflection) AfterLLM

func (Reflection) BeforeTurn

func (Reflection) BeforeTurn(context.Context, *hruntime.State) error

func (Reflection) BuildSystemPrefix

func (Reflection) BuildSystemPrefix(context.Context, hruntime.Request) string

func (Reflection) Finalize

func (Reflection) Name

func (Reflection) Name() string

func (Reflection) ShouldContinue

func (Reflection) ShouldContinue(context.Context, *hruntime.State) bool

Jump to

Keyboard shortcuts

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