autogen - ✅(Solved) Fix Define explicit exit-code taxonomy for AutoGen CLI tooling [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
microsoft/autogen#7330Fetched 2026-04-08 00:39:52
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

Fix Action

Fixed

PR fix notes

PR #7331: Add deterministic CLI exit-code taxonomy for config/runtime failures

Description (problem / solution / changelog)

Problem

CLI failure modes returned inconsistent exit behavior across usage/config/runtime paths, making automation retries and classification unreliable.

Why now

Deterministic exit-code contracts are needed for CI and operator workflows to distinguish actionable categories.

What changed

  • Added explicit exit code constants across Magentic-One CLI and AutoGen Studio CLI:
    • success: 0
    • usage: 2
    • config: 3
    • runtime: 4
  • Updated Magentic-One CLI to:
    • route missing task to usage exit
    • route config/load/validation failures to config exit
    • route runtime failures to runtime exit.
  • Updated AutoGen Studio CLI to:
    • route config validation failures to config exit
    • route runtime server failures to runtime exit.
  • Added regression tests:
    • python/packages/magentic-one-cli/tests/test_m1_exit_codes.py
    • python/packages/autogen-studio/tests/test_cli_exit_codes.py

Validation

  • uv run ruff check src tests
  • uv run ruff format --check src tests
  • uv run pytest -q tests/test_m1_exit_codes.py
  • uv run ruff check autogenstudio tests
  • uv run ruff format --check autogenstudio tests
  • uv run pytest -q tests/test_cli_exit_codes.py

Refs #7330

Changed files

  • python/packages/autogen-studio/autogenstudio/cli.py (modified, +38/-18)
  • python/packages/autogen-studio/tests/test_cli_exit_codes.py (added, +31/-0)
  • python/packages/magentic-one-cli/src/magentic_one_cli/_m1.py (modified, +29/-12)
  • python/packages/magentic-one-cli/tests/test_m1_exit_codes.py (added, +41/-0)
RAW_BUFFERClick to expand / collapse

Problem

AutoGen CLI/dev tooling failures currently use ambiguous exit behavior, making CI and wrappers unable to route failures deterministically.

Why now

Enterprise and CI automation need stable, class-specific exit contracts.

Current behavior is insufficient

autogen-studio / magentic-one-cli failure categories are not consistently expressed as a documented exit-code taxonomy.

Expected behavior

Define explicit exit codes for policy/dependency/runtime failure classes and lock with command tests.

Acceptance / Validation

  • Add exit-code mapping and tests for representative failure classes.
  • Cover python/packages/autogen-studio and python/packages/magentic-one-cli command surfaces.
  • Ensure docs/tests reflect the contract.

Evidence packet

  • Commit under test: 13e144e54 (origin/main)
  • Runtime environment: macOS arm64, Python 3.14.0
  • Minimal repro:
    1. Trigger dependency-missing startup failure.
    2. Trigger policy/config failure.
    3. Trigger generic runtime failure.
  • Expected: deterministic, class-specific exit codes.
  • Actual: non-uniform/implicit exit behavior makes automation routing ambiguous.

Likely codepaths

python/packages/autogen-studio, python/packages/magentic-one-cli.

extent analysis

Fix Plan

To address the issue, we will introduce explicit exit codes for different failure categories in the AutoGen CLI and dev tooling.

Step-by-Step Solution

  1. Define Exit Code Taxonomy:

    • Policy/dependency failure: exit code 10
    • Runtime failure: exit code 20
    • Generic failure: exit code 30
  2. Update autogen-studio and magentic-one-cli:

    • In python/packages/autogen-studio and python/packages/magentic-one-cli, modify the failure handling to use the defined exit codes.

Example code snippet for autogen-studio:

import sys

# ...

def handle_policy_failure():
    print("Policy failure occurred")
    sys.exit(10)

def handle_runtime_failure():
    print("Runtime failure occurred")
    sys.exit(20)

def handle_generic_failure():
    print("Generic failure occurred")
    sys.exit(30)
  1. Add Exit Code Mapping and Tests:
    • Create tests to cover representative failure classes for both autogen-studio and magentic-one-cli.
    • Ensure the tests verify the correct exit codes are used for each failure category.

Example test code snippet:

import unittest
import subprocess

class TestExitCodes(unittest.TestCase):
    def test_policy_failure(self):
        result = subprocess.run(["autogen-studio", "--policy-failure"], capture_output=True)
        self.assertEqual(result.returncode, 10)

    def test_runtime_failure(self):
        result = subprocess.run(["autogen-studio", "--runtime-failure"], capture_output=True)
        self.assertEqual(result.returncode, 20)

    def test_generic_failure(self):
        result = subprocess.run(["autogen-studio", "--generic-failure"], capture_output=True)
        self.assertEqual(result.returncode, 30)

Verification

To verify the fix, run the tests and check that the correct exit codes are returned for each failure category.

Extra Tips

  • Document the exit code taxonomy in the project's documentation to ensure consistency and clarity.
  • Consider using a centralized error handling mechanism to simplify the implementation of exit codes across the project.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Define explicit exit codes for policy/dependency/runtime failure classes and lock with command tests.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

autogen - ✅(Solved) Fix Define explicit exit-code taxonomy for AutoGen CLI tooling [1 pull requests, 1 participants]