Skip to content

Conversation

UmarFarooq-MP
Copy link

This PR fixes #106
, where cagent new could fail silently (or with confusing provider errors) and leave the user without any generated YAML file.

✅ Changes

Added fallback logic in root.NewNewCmd to always write a stub YAML if model generation fails.

Added creator.WriteStubAgentFile helper that:

Creates a minimal valid YAML.

Selects sensible defaults (openai/gpt-4o-mini, anthropic/claude-sonnet-4-0, google/gemini-2.5-flash, or dmr/ai/qwen3:latest) based on available credentials.

Improved error messaging so users know both why generation failed and that a stub file was created.

Reproduction (before fix)

./cagent new myagent.yaml
# -> fails with connection refused / 404 errors
# -> no myagent.yaml created

Behavior (after fix)

./cagent new myagent.yaml
# -> error reported
# -> stub agent file created at myagent.yaml

Generated stub:

version: "1"

agents:
  root:
    model: dmr/ai/qwen3:latest
    description: "TODO: Add description"
    instruction: "TODO: Add instructions"

Why this matters

Users are no longer left “empty-handed” if the model call fails.
Greatly improves onboarding UX: cagent new always leaves a file users can edit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant