ReliableTool
autogen.tools.experimental.ReliableTool #
ReliableTool(name, func_or_tool, runner_llm_config, validator_llm_config, description=None, system_message_addition_for_tool_calling='', system_message_addition_for_result_validation='', max_tool_invocations=3, enable_dynamic_validation=False, messages=None, ground_truth=None)
Bases: Tool
A ReliableTool wraps an existing function or tool. When the ReliableTool is invoked, it kicks off an internal Group Chat where a Runner and Validator agent will iteratively invoke the wrapped function or tool until the output of a single invocation of the original function or tool satisfies the provided validation criteria. Reliable Tools are best used when the LLM used or the function or tool itself is unreliable. Commonly this happens when using small, local LLMs, <32b params Or when functions/tools are used to "explore" (doing many web searches, exploring a database with SQL) The Reliable Tool allows the user to bake a result validation strategy into the tool itself so that the broader group chat/agentic system can be built more clearly around the intended flow instead of needing to focus so much on retry and validation loops.
Additionally, the .run() and .a_run() methods serve as a way to use LLMs to invoke a specific tool outside of a Group Chat or similar structure to provide a more traditional programming method of using LLMs and tools in code.
PARAMETER | DESCRIPTION |
---|---|
name | A unique and descriptive name for this ReliableTool instance. This name is used for logging, internal context management, and can be how other agents or systems refer to this specific reliable capability. Example: TYPE: |
func_or_tool | The core Python function or an existing AG2 |
runner_llm_config | The LLM configuration for the internal "Runner Agent". This agent is responsible for interpreting the high-level |
validator_llm_config | The LLM configuration for the internal "Validator Agent". After the |
description | None): A human-readable description of what this |
system_message_addition_for_tool_calling | ""): Additional text appended to the system message of the internal "Runner Agent". This allows you to provide specific instructions, context, or constraints to the LLM responsible for deciding how to call your underlying TYPE: |
system_message_addition_for_result_validation | ""): Additional text appended to the system message of the internal "Validator Agent". This is where you define the base or static criteria for validating the result (string representation) of your TYPE: |
max_tool_invocations | 3): The maximum number of times the internal "Runner Agent" can attempt to call the underlying TYPE: |
enable_dynamic_validation | False): If TYPE: |
messages | None): A list of initial messages (e.g., from a prior conversation history) to provide context to the internal Runner and Validator agents. These messages are prepended to the message history seen by these agents during their internal chat, helping them understand the TYPE: |
ground_truth | None): A list of strings representing factual information, examples, or specific constraints that should be considered by the internal Runner and Validator agents. These are injected into the conversation history as distinct user messages (e.g., "[[Provided Ground Truth 1]]: ..."). Use to provide specific, factual data or strong hints that might not fit naturally into system messages or prior conversation history, guiding the agents towards correct interpretation or validation. Example: |
Source code in autogen/tools/experimental/reliable/reliable.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 |
|
tool_schema property
#
Get the schema for the tool.
This is the preferred way of handling function calls with OpeaAI and compatible frameworks.
function_schema property
#
Get the schema for the function.
This is the old way of handling function calls with OpenAI and compatible frameworks. It is provided for backward compatibility.
realtime_tool_schema property
#
Get the schema for the tool.
This is the preferred way of handling function calls with OpeaAI and compatible frameworks.
INTERNAL_TOOL_NAME_PREFIX class-attribute
instance-attribute
#
enable_dynamic_validation instance-attribute
#
register_for_llm #
Registers the tool for use with a ConversableAgent's language model (LLM).
This method registers the tool so that it can be invoked by the agent during interactions with the language model.
PARAMETER | DESCRIPTION |
---|---|
agent | The agent to which the tool will be registered. TYPE: |
Source code in autogen/tools/tool.py
register_for_execution #
Registers the tool for direct execution by a ConversableAgent.
This method registers the tool so that it can be executed by the agent, typically outside of the context of an LLM interaction.
PARAMETER | DESCRIPTION |
---|---|
agent | The agent to which the tool will be registered. TYPE: |
Source code in autogen/tools/tool.py
register_tool #
Register a tool to be both proposed and executed by an agent.
Equivalent to calling both register_for_llm
and register_for_execution
with the same agent.
Note: This will not make the agent recommend and execute the call in the one step. If the agent recommends the tool, it will need to be the next agent to speak in order to execute the tool.
PARAMETER | DESCRIPTION |
---|---|
agent | The agent to which the tool will be registered. TYPE: |
Source code in autogen/tools/tool.py
run #
run(task, context_variables=None, validation_prompt_addition=None, messages=None, ground_truth=None)
Source code in autogen/tools/experimental/reliable/reliable.py
a_run async
#
a_run(task, context_variables=None, validation_prompt_addition=None, messages=None, ground_truth=None)
Source code in autogen/tools/experimental/reliable/reliable.py
run_and_get_details #
run_and_get_details(task, context_variables=None, validation_prompt_addition=None, messages=None, ground_truth=None)
Source code in autogen/tools/experimental/reliable/reliable.py
a_run_and_get_details async
#
a_run_and_get_details(task, context_variables=None, validation_prompt_addition=None, messages=None, ground_truth=None)