Legion.Tools.HumanTool (Legion v0.4.0)

View Source

Built-in tool for asking a human a question mid-execution.

Configuration

Configure via tool_config/1 in your agent:

def tool_config(Legion.Tools.HumanTool) do
  [handler: MyApp.ChatHandler, timeout: 30_000]
end

Options:

  • :handler (required) — a pid or registered name that receives {:human_request, ref, from_pid, question, meta} and must send {:human_response, ref, answer} back to from_pid.
  • :timeout — milliseconds to wait for a response. Defaults to :infinity.

Usage (for LLM agent)

Legion.Tools.HumanTool.ask("What format do you prefer?")

Summary

Functions

Asks a human a question and blocks until they respond.

Callback implementation for Legion.Tool.description/0.

Functions

ask(question)

Asks a human a question and blocks until they respond.

Returns the human's answer as a string. Use this tool with eval_and_continue.

description()

Callback implementation for Legion.Tool.description/0.

extra_allowed_modules()

Callback implementation for Legion.Tool.extra_allowed_modules/0.