Inference Logoinference.sh

Approval Settings

Human-in-the-loop (HIL) for tool execution.


Overview

Require user approval before tools execute:

1from inferencesh import tool, string2 3delete_file = (4    tool("delete_file")5    .describe("Delete a file from the system")6    .param("path", string("File path"))7    .require_approval()  # ← Requires approval8    .handler(lambda args: delete(args["path"]))9    .build()10)

How It Works

  1. Agent decides to call tool with requireApproval
  2. Execution pauses with status awaiting_approval
  3. User sees the tool call and can approve or reject
  4. If approved: tool executes normally
  5. If rejected: agent receives rejection and can try alternatives

Approval Flow

code
1Agent: "I need to delete old-file.txt"2       [calls delete_file(path="old-file.txt")]3 4System:  Awaiting approval5        Tool: delete_file6        Args: {"path": "old-file.txt"}7        [Approve] [Reject]8 9User: [clicks Approve]10 11Tool: Executes delete("old-file.txt")12 13Agent: "Done! I've deleted old-file.txt"

Any Tool Type

All tool types support approval:

1# Client Tools2tool("dangerous_action").require_approval().handler(do_dangerous).build()3 4# App Tools5app_tool("expensive_model", "expensive/model@latest").require_approval().build()6 7# Agent Tools8agent_tool("expert", "my-team/expert@latest").require_approval().build()9 10# Webhook Tools11webhook_tool("external_api", "https://api.example.com").require_approval().build()

Use Cases

Destructive Operations

1delete_tool = (2    tool("delete")3    .describe("Delete data")4    .require_approval()5    .build()6)

External Integrations

1send_email = (2    webhook_tool("send_email", "https://api.email.com/send")3    .describe("Send an email")4    .require_approval()  # Don't spam!5    .build()6)

Expensive Operations

1premium_analysis = (2    app_tool("analyze", "expensive/analyzer@latest")3    .describe("Premium analysis ($5/call)")4    .require_approval()5    .build()6)

Handling Rejections

When a user rejects a tool call, the agent receives feedback and can try alternatives:

code
1Agent: "Let me delete that file"2       [calls delete_file  REJECTED]3 4Agent: "I understand you don't want to delete it. 5        Would you like me to archive it instead?"

Selective Approval

Mix approved and auto-execute tools:

1agent = client.agent({2    "core_app_ref": "infsh/claude-sonnet-4@latest",3    "tools": [4        # Auto-execute (safe)5        tool("read_file").handler(read_file).build(),6        tool("list_files").handler(list_files).build(),7        8        # Require approval (dangerous)9        tool("delete_file").require_approval().handler(delete_file).build(),10        tool("modify_file").require_approval().handler(modify_file).build(),11    ]12})

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.