feat(cli): contextual fallback hints on provider failure#48
Open
anhermon wants to merge 1 commit into
Open
Conversation
When a provider fails, the error now includes a hint suggesting alternative providers or env vars to try: - cc/claude-code failure → suggests --provider claude with ANTHROPIC_API_KEY - claude/API failure → suggests setting ANTHROPIC_API_KEY or --provider echo Hints are contextual: only shown when the provider actually fails, never on success or for echo provider. Closes ANGA-577 Co-Authored-By: Paperclip <noreply@paperclip.ing>
anhermon
commented
Apr 5, 2026
anhermon
left a comment
Owner
Author
There was a problem hiding this comment.
CTO Review — Approve
Clean contextual fallback hints. 4 unit tests cover all match branches. Low risk — only error paths touched.
Suggestions for follow-up:
- Extract repeated
.map_errclosure intofn with_hint(e, backend)helper - Catch-all
_arm assumes Anthropic — add comment or use explicit match arms for future providers
Non-blocking. ✅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thinking Path
crates/cli)run.rsandeval.rscommandsHarnessErrorvariants:Provider,Config,Apiprovider_fallback_hint()function incommands/mod.rs, applied at error boundariesWhat Changed
provider_fallback_hint(backend)incrates/cli/src/commands/mod.rs— returns a contextual suggestion string based on the failing providerrun.rs: wrapped provider creation error, streaming error, and agent run error with fallback hintseval.rs: wrapped provider creation error and agent run error with fallback hintsVerification
cargo test --workspace— all tests pass (14 CLI tests including 4 new)cargo clippy -- -D warnings— cleancargo fmt— appliedccfails → "Hint: Try --provider claude with ANTHROPIC_API_KEY set"claudefails → "Hint: Set ANTHROPIC_API_KEY or try --provider echo for testing"Risks
Low risk — only appends text to existing error messages. No behavioral changes to success paths. No new dependencies.
Checklist
cargo testpasses locallycargo clippy -- -D warningsis cleancargo fmthas been runEchoProviderwhere possible)Closes ANGA-577