Skip to content

agents-cli create precondition and generation failures can exit successfully or show tracebacks #68

Description

@benagentai93-dot

Baseline

Reproduced from v1.3.1 at 5a306f8956cb1eeae69f9709de0e4d61b44e11e7.

Reproduction

Examples:

agents-cli create xxxxxxxxxxxxxxxxxxxxxxxxxxx --skip-welcome
agents-cli create existing --output-dir /tmp --skip-welcome
agents-cli create sample-agent --agent not-an-agent --skip-welcome

For the second command, pre-create /tmp/existing. Remote-template fetch, invalid agent-directory, or template generation exceptions expose the other paths.

Actual behavior

Several precondition failures print an error and return normally, producing exit code 0. Other validation/generation paths raise raw exceptions or Abort, leading to inconsistent output and possible tracebacks.

Expected behavior

Usage/precondition errors must exit non-zero as click.UsageError; fetch/generation failures must exit non-zero as concise click.ClickException errors. Interactive cancellation should retain Click's cancellation semantics. Normal CLI use should not show a traceback.

Minimal fix

Route create-time failures through one command-boundary handler: re-raise existing ClickException and Abort, translate validation ValueError to UsageError, and translate other generation/fetch exceptions to ClickException. Replace ordinary error returns with explicit Click errors.

Reference implementation: benagentai93-dot@f1c212b

Test evidence

Eight runnable regression cases cover overlong names, existing directories, invalid agent/base-template/agent-directory, generation/fetch failures, and interactive cancellation. They verify exit codes and absence of tracebacks.

Fork verification on Python 3.11/3.13:

  • focused Batch 1 suite: 17 passed
  • full root suite: 19 passed
  • lint, type check, build, and installed-wheel smoke: passed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions