Documentation
¶
Index ¶
- Variables
- type ApprovalOption
- type ApprovalRequest
- type ApprovalResponse
- type Decision
- type DeliberationConfig
- type DeliberationMode
- type DeliberationResult
- type Engine
- type HITLBridge
- type HITLConfig
- type HITLInterruptAdapter
- type InterruptRequester
- type LLMReasoner
- type Reasoner
- type Task
- type ThoughtProcess
Constants ¶
This section is empty.
Variables ¶
var ErrDecisionRejected = errors.New("decision rejected by human reviewer")
ErrDecisionRejected is returned when a human reviewer rejects a low-confidence decision.
Functions ¶
This section is empty.
Types ¶
type ApprovalOption ¶ added in v1.0.0
ApprovalOption is a single choice presented to the reviewer.
type ApprovalRequest ¶ added in v1.0.0
type ApprovalRequest struct {
Title string
Description string
Data any
Options []ApprovalOption
Timeout time.Duration
}
ApprovalRequest describes what the human needs to review.
type ApprovalResponse ¶ added in v1.0.0
type ApprovalResponse struct {
Action string // "approve", "reject", "modify"
Feedback string
Data any
}
ApprovalResponse carries the human reviewer's decision.
type Decision ¶
type Decision struct {
Action string `json:"action"`
Tool string `json:"tool,omitempty"`
Parameters map[string]any `json:"parameters,omitempty"`
Reasoning string `json:"reasoning"`
Confidence float64 `json:"confidence"`
}
决定是审议后的最后决定。
type DeliberationConfig ¶
type DeliberationConfig struct {
Mode DeliberationMode `json:"mode"`
MaxThinkingTime time.Duration `json:"max_thinking_time"`
MinConfidence float64 `json:"min_confidence"`
EnableSelfCritique bool `json:"enable_self_critique"`
MaxIterations int `json:"max_iterations"`
}
Deconfig 配置审议引擎 。
func DefaultDeliberationConfig ¶
func DefaultDeliberationConfig() DeliberationConfig
默认De ReleaseConfig 返回默认配置 。
type DeliberationMode ¶
type DeliberationMode string
审议 模式控制代理在行动前的理性.
const ( ModeImmediate DeliberationMode = "immediate" // Direct tool execution ModeDeliberate DeliberationMode = "deliberate" // Full reasoning cycle ModeAdaptive DeliberationMode = "adaptive" // Context-dependent )
type DeliberationResult ¶
type DeliberationResult struct {
TaskID string `json:"task_id"`
Thoughts []ThoughtProcess `json:"thoughts"`
Decision *Decision `json:"decision"`
TotalTime time.Duration `json:"total_time"`
Iterations int `json:"iterations"`
FinalConfidence float64 `json:"final_confidence"`
}
审议结果载有审议结果。
type Engine ¶
type Engine struct {
OnThought func(ThoughtProcess)
OnDecision func(Decision)
// contains filtered or unexported fields
}
Engine provides deliberation capabilities.
func NewEngine ¶
func NewEngine(config DeliberationConfig, reasoner Reasoner, logger *zap.Logger) *Engine
NewEngine创造了一个新的审议引擎.
func (*Engine) Deliberate ¶
Deliberate performs reasoning before action.
func (*Engine) GetMode ¶
func (e *Engine) GetMode() DeliberationMode
GetMode returns the current deliberation mode.
type HITLBridge ¶ added in v1.0.0
type HITLBridge struct {
// contains filtered or unexported fields
}
HITLBridge connects deliberation to human approval.
func NewHITLBridge ¶ added in v1.0.0
func NewHITLBridge(engine *Engine, requester InterruptRequester, config HITLConfig, logger *zap.Logger) *HITLBridge
NewHITLBridge creates a bridge between the deliberation engine and human review.
func (*HITLBridge) DeliberateWithApproval ¶ added in v1.0.0
func (b *HITLBridge) DeliberateWithApproval(ctx context.Context, task Task) (*DeliberationResult, error)
DeliberateWithApproval runs deliberation and escalates to a human reviewer when the final confidence falls below the configured threshold.
type HITLConfig ¶ added in v1.0.0
type HITLConfig struct {
Enabled bool
ConfidenceThreshold float64 // below this, escalate to human
InterruptTimeout time.Duration // how long to wait for human response
}
HITLConfig configures human-in-the-loop escalation.
func DefaultHITLConfig ¶ added in v1.0.0
func DefaultHITLConfig() HITLConfig
DefaultHITLConfig returns sensible defaults for HITL escalation.
type HITLInterruptAdapter ¶ added in v1.0.0
type HITLInterruptAdapter struct {
// contains filtered or unexported fields
}
HITLInterruptAdapter adapts hitl.InterruptManager to the InterruptRequester interface. This is the only file in the deliberation package that imports agent/hitl, keeping the rest of the package loosely coupled.
func NewHITLInterruptAdapter ¶ added in v1.0.0
func NewHITLInterruptAdapter(manager *hitl.InterruptManager) *HITLInterruptAdapter
NewHITLInterruptAdapter wraps an InterruptManager for use with HITLBridge.
func (*HITLInterruptAdapter) RequestApproval ¶ added in v1.0.0
func (a *HITLInterruptAdapter) RequestApproval(ctx context.Context, opts ApprovalRequest) (*ApprovalResponse, error)
RequestApproval translates an ApprovalRequest into a hitl.InterruptOptions call and maps the hitl.Response back to an ApprovalResponse.
type InterruptRequester ¶ added in v1.0.0
type InterruptRequester interface {
RequestApproval(ctx context.Context, opts ApprovalRequest) (*ApprovalResponse, error)
}
InterruptRequester is a local interface for HITL integration. Matches the subset of hitl.InterruptManager needed here. Using a local interface (§15) to keep deliberation loosely coupled.
type LLMReasoner ¶ added in v1.0.0
type LLMReasoner struct {
// contains filtered or unexported fields
}
LLMReasoner implements Reasoner using an llm.Provider.
func NewLLMReasoner ¶ added in v1.0.0
NewLLMReasoner creates a new LLM-backed Reasoner.
type Task ¶
type Task struct {
ID string `json:"id"`
Description string `json:"description"`
Goal string `json:"goal"`
Context map[string]any `json:"context,omitempty"`
AvailableTools []string `json:"available_tools,omitempty"`
SuggestedTool string `json:"suggested_tool,omitempty"`
Parameters map[string]any `json:"parameters,omitempty"`
}
任务是一项需要审议的任务。