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 Linter CLI

From Leeroopedia
Revision as of 11:31, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Microsoft_Autogen_Agbench_Linter_CLI.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Property Value
Source https://github.com/microsoft/autogen
Domains Benchmarking CLI Log_Analysis Quality_Assurance OpenAI
Last Updated 2026-02-11 17:00 GMT

Overview

A command-line tool that analyzes AutoGen benchmark log files using OpenAI-powered qualitative coding to detect errors, inefficiencies, and issues with severity-based reporting.

Description

The linter/cli.py module provides automated analysis capabilities for benchmark console logs. It leverages OpenAI's language models through an OAIQualitativeCoder to perform qualitative coding on log files, identifying patterns of errors, warnings, and inefficiencies. The module implements several key functions: prepend_line_numbers() adds right-justified line numbers to log content for precise issue location; load_log_file() reads log files and optionally adds line numbers; code_log() applies the qualitative coder to analyze log content; print_coded_results() formats findings with ANSI color coding (red for severity 2, yellow for severity 1, green for severity 0); and get_log_summary() generates single-sentence summaries using GPT-4. The CLI interface accepts a log file path and produces comprehensive output including a summary, categorized issues with severity indicators, line number references, and reasons for each finding. The implementation uses the OpenAI Responses API with the gpt-4o model for summary generation and relies on a custom coding framework for detailed analysis.

Usage

Use this module when you need to:

  • Automatically analyze benchmark run logs for errors and inefficiencies
  • Generate qualitative assessments of benchmark execution quality
  • Identify patterns of failures across multiple benchmark runs
  • Produce severity-ranked reports of issues in log files
  • Create single-sentence summaries of benchmark log content
  • Integrate AI-powered log analysis into benchmark workflows

Code Reference

Source Location: /tmp/kapso_repo_2mr4n2g4/python/packages/agbench/src/agbench/linter/cli.py

Signature:

def lint_cli(args: Sequence[str]) -> None:
    """
    CLI entry point for log linting functionality.

    Analyzes a console log file, generates a summary, detects errors and
    inefficiencies, and prints formatted results with severity indicators.

    Args:
        args: Command-line arguments where args[0] is the invocation command
              and args[1:] contains the parsed arguments including logfile path

    Returns:
        None (outputs results to stdout)
    """

def code_log(path: str) -> Optional[CodedDocument]:
    """
    Apply qualitative coding to a log file.

    Args:
        path: Absolute path to the log file to analyze

    Returns:
        CodedDocument with identified codes and examples, or None on failure

    Raises:
        FileNotFoundError: If the specified file does not exist
    """

def get_log_summary(input_path: str) -> str:
    """
    Generate a single sentence summary for the given log file.

    Args:
        input_path: Path to the log file

    Returns:
        Single-sentence summary string generated by GPT-4
    """

Import:

from agbench.linter.cli import lint_cli, code_log, get_log_summary

I/O Contract

Inputs

Parameter Type Required Description
args Sequence[str] Yes Command-line arguments list. args[0] is invocation command, args[1] is log file path
path str Yes Absolute or relative path to console log file for analysis

Outputs

Output Type Description
Summary str Single-sentence GPT-4 generated summary of log content
Coded issues List[Code] Severity-sorted list of identified issues with names, definitions, line ranges, and reasons
Error count int Total number of issues found across all severity levels
ANSI colored output str Formatted console output with color-coded severity levels (red/yellow/green)

Usage Examples

Command-Line Usage:

# Analyze a benchmark log file
autogenbench lint path/to/console_log.txt

# Example output format:
# Processing file: path/to/console_log.txt
# [Summary from GPT-4]
# [2]: Critical Error: Definition of critical issue
# path/to/console_log.txt:42:45    Reason for this error
# [1]: Warning: Definition of warning
# path/to/console_log.txt:78:80    Reason for this warning
# Found 2 errors in path/to/console_log.txt.

Programmatic Usage:

from agbench.linter.cli import code_log, get_log_summary, print_coded_results

# Analyze a log file
log_path = "/path/to/benchmark/console_log.txt"

# Get summary
summary = get_log_summary(log_path)
print(f"Summary: {summary}")

# Perform detailed coding analysis
coded_doc = code_log(log_path)

if coded_doc:
    # Print formatted results with color coding
    print_coded_results(log_path, coded_doc)

    # Access individual codes programmatically
    for code in coded_doc.codes:
        print(f"Issue: {code.name}")
        print(f"Severity: {code.severity}")
        print(f"Definition: {code.definition}")
        for example in code.examples:
            print(f"  Line {example.line}-{example.line_end}: {example.reason}")

Helper Function Usage:

from agbench.linter.cli import prepend_line_numbers, load_log_file

# Load log file with line numbers
document = load_log_file("console_log.txt", prepend_numbers=True)
print(f"Document name: {document.name}")
print(f"Content length: {len(document.text)}")

# Manually prepend line numbers to text
lines = ["First line", "Second line", "Third line"]
numbered_lines = prepend_line_numbers(lines)
# Result: ['1: First line', '2: Second line', '3: Third line']

Integration with Main CLI:

# The lint_cli function is called by the main agbench dispatcher
# args[0] = "autogenbench lint"
# args[1:] = ["path/to/logfile.txt"]

from agbench.linter.cli import lint_cli

# Simulate CLI call
lint_cli(["autogenbench lint", "path/to/console_log.txt"])

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment