{"agent":"claude","input":"Add a fallback model to the chat route. Read package.json, lib/ai/providers.ts, lib/ai/models.ts, lib/ai/models.mock.ts, lib/ai/generate-title.ts, app/(chat)/api/chat/route.ts and lib/errors.ts first. Write a LanguageModelMiddleware in lib/ai/fallback.ts whose wrapStream calls the primary doStream and, on an APICallError that is retryable or has a 429 or 5xx status before any stream part has been emitted, calls a fallback model's doStream with the same params; never retry after the first chunk. Add an optional fallbackModelId to each entry in chatModels and have getLanguageModel return the wrapped model with wrapLanguageModel when one is set, and wrap the title model the same way. Emit the existing data-waiting-status with the fallback model's name and record the answering model on the assistant message. Add tests using the mock provider pattern: a primary that throws a retryable error and a fallback that streams, and a non-retryable error that is rethrown. Run the tests, pnpm check and tsc --noEmit, and open a pull request with the output.","resources":[{"url":"https://github.com/your-org/your-app"}]}