[Bug]: Fix 404 Haiku error by switching to default Sonnet model (Fixes #4112) #4245
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.
Description
Fixes #4112 the Haiku formatting 404 error by falling back to the default Sonnet model. to make sure the AI agent continues working even if the Haiku model is unavailable and logs failures for debugging.
When the Haiku formatting model (claude-3-5-haiku-20241022) is unavailable, the agent fails with a 404 error during formatting. This causes the agent workflow to break instead of continuing execution, even though a suitable fallback model (Sonnet) is available.
The error prevents normal agent operation and results in an avoidable failure when the Haiku model is deprecated, unavailable, or temporarily disabled
To Reproduce
Steps to reproduce the behavior:
1, Configure the agent to use the Haiku model for formatting
2, Run the agent using:
3,uv run python -m exports.my_agent --help
Observe the following error in the terminal:
Agent execution stops instead of continuing with a fallback model
Expected Behavior
If the Haiku formatting model is unavailable, the agent should gracefully fall back to the default Sonnet model, continue execution successfully, and log the failure for debugging purposes without breaking the workflow.
Environment
Configuration
Relevant parts of the agent configuration or environment setup:
on bash
Agent output after fallback confirms successful execution:
Checklist
uv run python -m exports.my_agent --helpand confirmed output is generated with fallbackType of Change