Documentation
¶
Overview ¶
Package approvaltool provides a Human-in-the-Loop (HITL) tool example.
This tool demonstrates the long-running/HITL pattern where: 1. Tool returns immediately with a pending status 2. Task transitions to `input_required` state 3. Human provides approval/rejection 4. Task resumes with the human's decision
This is different from StreamingTool which produces incremental output but runs to completion without human intervention.
Example usage:
tool := approvaltool.New(approvaltool.Config{
Name: "request_approval",
Description: "Request human approval for sensitive operations",
})
A2A Protocol Mapping:
- Initial call: Returns immediately with pending status
- Task state: Transitions to `input_required`
- A2A event: `status-update` with `state: input_required`
- Human response: Sent via `message/send` with approval decision
- Resume: Task continues with approval result
Index ¶
- type ApprovalTool
- func (t *ApprovalTool) Call(ctx tool.Context, args map[string]any) (map[string]any, error)
- func (t *ApprovalTool) Description() string
- func (t *ApprovalTool) IsLongRunning() bool
- func (t *ApprovalTool) Name() string
- func (t *ApprovalTool) RequiresApproval() bool
- func (t *ApprovalTool) Schema() map[string]any
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApprovalTool ¶
type ApprovalTool struct {
// contains filtered or unexported fields
}
ApprovalTool implements a HITL approval workflow.
func (*ApprovalTool) Call ¶
Call executes the approval request. For HITL tools, this returns immediately with a pending status. The actual approval/rejection comes later via human input.
func (*ApprovalTool) Description ¶
func (t *ApprovalTool) Description() string
Description returns the tool description.
func (*ApprovalTool) IsLongRunning ¶
func (t *ApprovalTool) IsLongRunning() bool
IsLongRunning returns false - this is not an async tool.
func (*ApprovalTool) RequiresApproval ¶
func (t *ApprovalTool) RequiresApproval() bool
RequiresApproval returns true - this is a HITL tool. The difference from streaming: - Streaming: produces incremental output but runs to completion - RequiresApproval: pauses and waits for human input before execution
func (*ApprovalTool) Schema ¶
func (t *ApprovalTool) Schema() map[string]any
Schema returns the JSON schema for the tool parameters.