Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Autogen Agbench CLI: Difference between revisions

From Leeroopedia
Auto-imported from implementations/Microsoft_Autogen_Agbench_CLI.md
 
Sync from local file
 
Line 27: Line 27:
== Code Reference ==
== Code Reference ==


'''Source Location:''' <code>/tmp/kapso_repo_2mr4n2g4/python/packages/agbench/src/agbench/cli.py</code>
'''Source Location:''' <code>python/packages/agbench/src/agbench/cli.py</code>


'''Signature:'''
'''Signature:'''

Latest revision as of 10:45, 27 September 2026

Property Value
Source https://github.com/microsoft/autogen
Domains Benchmarking CLI Command_Line_Interface Testing
Last Updated 2026-02-11 17:00 GMT

Overview

The main command-line interface entry point for AutoGenBench that routes subcommands to specialized handlers for running, tabulating, linting, and managing benchmark scenarios.

Description

The cli.py module serves as the primary entry point for the autogenbench command-line tool. It implements a dispatcher pattern that routes user commands to appropriate subcommand handlers. The module defines a CommandSpec typed dictionary structure to maintain command metadata including command names, descriptions, and handler functions. The main() function parses command-line arguments and delegates execution to one of four primary subcommands: run (execute benchmark configurations), tabulate (analyze and format results), lint (validate benchmark configurations), and remove_missing (clean up incomplete benchmark runs). The implementation includes comprehensive help text generation with dynamic formatting that adjusts to the longest command name for aligned display. Version information is accessible through the --version flag, and detailed help is available via --help. The module imports specialized CLI handlers from sibling modules and maintains a clean separation of concerns by delegating all substantive functionality to these specialized handlers.

Usage

Use this module when you need to:

  • Provide a unified command-line interface for all AutoGenBench operations
  • Route user commands to appropriate benchmark management functions
  • Display version information or comprehensive help text
  • Validate command-line arguments before delegating to subcommand handlers
  • Maintain a consistent CLI experience across different benchmark operations

Code Reference

Source Location: python/packages/agbench/src/agbench/cli.py

Signature:

def main(args: Optional[List[str]] = None) -> None:
    """
    Main entry point for the autogenbench CLI tool.

    Parses command-line arguments and dispatches to appropriate subcommand handlers.
    If no args provided, uses sys.argv. Expects format: autogenbench COMMAND ARGS

    Args:
        args: Optional list of command-line arguments (defaults to sys.argv)

    Returns:
        None (exits with appropriate status code)
    """

Import:

from agbench.cli import main

I/O Contract

Inputs

Parameter Type Required Description
args Optional[List[str]] No Command-line arguments list. If None, uses sys.argv. Expected format: [program_name, command, ...command_args]

Outputs

Output Type Description
Return value None Function exits with sys.exit() status codes
Exit code 0 int Successful command execution or help display
Exit code 2 int Invalid command or missing arguments
stdout str Version information when --version is used
stderr str Usage text, help text, or error messages

Usage Examples

Basic Command Execution:

# Display version information
autogenbench --version

# Display help text
autogenbench --help

# Run a benchmark configuration
autogenbench run path/to/config.json

# Tabulate results from a previous run
autogenbench tabulate path/to/runlogs

# Lint a benchmark configuration
autogenbench lint path/to/logfile.txt

# Remove folders with missing results
autogenbench remove_missing path/to/runlogs

Programmatic Usage:

from agbench.cli import main

# Call with explicit arguments
main(["autogenbench", "run", "config.json"])

# Call with default arguments (uses sys.argv)
main()

# Access version information programmatically
from agbench.version import __version__
print(f"AutoGenBench version {__version__}")

Command Specification Structure:

from typing import Callable, Optional, Sequence
from typing_extensions import TypedDict

class CommandSpec(TypedDict):
    """Structure for defining CLI commands"""
    command: str  # Command name (e.g., "run", "tabulate")
    description: str  # Brief description for help text
    function: Optional[Callable[[Sequence[str]], None]]  # Handler function

# Example command specification
command_spec = {
    "command": "run",
    "description": "run a given benchmark configuration",
    "function": run_cli,
}

Related Pages