Documentation
¶
Index ¶
- Constants
- Variables
- func AdvancePlanOnSuccess(p *Plan) (completedIndex int, completedStep string, startedIndex int, startedStep string, ...)
- func BuildSystemPrompt(registry *tools.Registry, spec PromptSpec) string
- func CompleteAllPlanSteps(p *Plan)
- func ExtractFileWritePaths(task string) []string
- func NormalizePlanSteps(p *Plan)
- type AgentResponse
- type Config
- type Context
- type Engine
- type Final
- type Hook
- type Limits
- type LogOptions
- type Metrics
- type Option
- func WithFallbackFinal(fn func() *Final) Option
- func WithGuard(g *guard.Guard) Option
- func WithHook(h Hook) Option
- func WithLogOptions(o LogOptions) Option
- func WithLogger(l *slog.Logger) Option
- func WithOnToolSuccess(fn func(*Context, string)) Option
- func WithParamsBuilder(fn func(RunOptions) map[string]any) Option
- func WithPlanStepUpdate(fn func(*Context, PlanStepUpdate)) Option
- func WithPromptBuilder(fn func(*tools.Registry, string) string) Option
- func WithSkillAuthProfiles(authProfiles []string, enforce bool) Option
- type PendingOutput
- type Plan
- type PlanStep
- type PlanStepUpdate
- type PlanSteps
- type PromptBlock
- type PromptSkill
- type PromptSpec
- type RunOptions
- type Step
- type ToolCall
Constants ¶
View Source
const ( DefaultMaxSteps = 15 DefaultParseRetries = 2 DefaultToolRepeatLimit = 3 )
View Source
const ( PlanStatusPending = "pending" PlanStatusInProgress = "in_progress" PlanStatusCompleted = "completed" )
View Source
const ( TypeToolCall = "tool_call" TypePlan = "plan" TypeFinal = "final" TypeFinalAnswer = "final_answer" )
Variables ¶
View Source
var ( ErrParseFailure = errors.New("failed to parse agent response from LLM output") ErrInvalidToolCall = errors.New("tool_call JSON responses are not supported") ErrInvalidPlan = errors.New("plan response missing payload") ErrInvalidFinal = errors.New("final response missing payload") )
Functions ¶
func AdvancePlanOnSuccess ¶
func BuildSystemPrompt ¶
func BuildSystemPrompt(registry *tools.Registry, spec PromptSpec) string
func CompleteAllPlanSteps ¶
func CompleteAllPlanSteps(p *Plan)
func ExtractFileWritePaths ¶
func NormalizePlanSteps ¶
func NormalizePlanSteps(p *Plan)
Types ¶
type AgentResponse ¶
type AgentResponse struct {
Type string `json:"type"`
ToolCall *ToolCall `json:"tool_call,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
Plan *Plan `json:"plan,omitempty"`
Final *Final `json:"final,omitempty"`
FinalAnswer *Final `json:"final_answer,omitempty"`
RawFinalAnswer json.RawMessage `json:"-"`
}
func ParseResponse ¶
func ParseResponse(result llm.Result) (*AgentResponse, error)
func (*AgentResponse) FinalPayload ¶
func (r *AgentResponse) FinalPayload() *Final
func (*AgentResponse) PlanPayload ¶
func (r *AgentResponse) PlanPayload() *Plan
type Context ¶
type Context struct {
Task string
Steps []Step
MaxSteps int
Plan *Plan
Metrics *Metrics
RawFinalAnswer json.RawMessage
}
func NewContext ¶
func (*Context) RecordStep ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
type Limits ¶ added in v0.2.7
Limits groups loop-control knobs so upper layers can pass agent limits as a single value instead of repeating individual fields.
func (Limits) NormalizeForRuntime ¶ added in v0.2.7
NormalizeForRuntime applies channel/runtime defaults that historically treated <=0 values as unset for retries/repeat limits.
type LogOptions ¶
type LogOptions struct {
IncludeThoughts bool
IncludeToolParams bool
IncludeSkillContents bool
MaxThoughtChars int
MaxJSONBytes int
MaxStringValueChars int
MaxSkillContentChars int
RedactKeys []string
}
func DefaultLogOptions ¶
func DefaultLogOptions() LogOptions
type Option ¶
type Option func(*Engine)
func WithFallbackFinal ¶
func WithLogOptions ¶
func WithLogOptions(o LogOptions) Option
func WithLogger ¶
func WithOnToolSuccess ¶
func WithParamsBuilder ¶
func WithParamsBuilder(fn func(RunOptions) map[string]any) Option
func WithPlanStepUpdate ¶
func WithPlanStepUpdate(fn func(*Context, PlanStepUpdate)) Option
func WithPromptBuilder ¶
WithPromptBuilder replaces the default system prompt builder. This hook is intended for tests in this repository.
func WithSkillAuthProfiles ¶
type PendingOutput ¶
type PendingOutput struct {
Status string `json:"status"`
ApprovalRequestID string `json:"approval_request_id"`
Message string `json:"message"`
}
PendingOutput is returned as Final.Output when the run is paused awaiting an external approval. It is intentionally small and safe to serialize (no raw tool params or secrets).
type PlanStepUpdate ¶
type PromptBlock ¶
type PromptBlock struct {
Content string
}
type PromptSkill ¶ added in v0.1.2
type PromptSpec ¶
type PromptSpec struct {
Identity string
Rules []string
Skills []PromptSkill
Blocks []PromptBlock
}
func DefaultPromptSpec ¶
func DefaultPromptSpec() PromptSpec
type RunOptions ¶
type ToolCall ¶
type ToolCall struct {
ID string `json:"tool_call_id,omitempty"`
Type string `json:"tool_call_type,omitempty"`
Thought string `json:"thought"`
Name string `json:"tool_name"`
Params map[string]any `json:"tool_params"`
RawArguments string `json:"raw_arguments,omitempty"`
ThoughtSignature string `json:"thought_signature,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.