-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Context
During review of PR #69 (#69), Copilot noted that the new timeout-fallback behavior and fallback_model response field are not covered by tests.
What needs testing
Add tests that cover the Cloudflare AI timeout fallback path:
- Simulate timeout error: Mock
c.env.AI.runto throw an error with code3046(timeout) on the primary model - Verify fallback retry: Confirm the handler retries the request with the fallback model after the primary model times out
- Verify metadata in non-streaming responses: Assert that the
fallback_modelfield is present and correct in the JSON response body when fallback is triggered - Verify metadata in streaming responses: Assert that the
X-Fallback-Modelheader is set correctly when the fallback model is used in streaming mode - Verify normal path: Ensure that when the primary model succeeds, no fallback metadata is present
Acceptance criteria
- Test exists that triggers code 3046 timeout on primary model
- Test verifies fallback model is called after timeout
- Test checks
fallback_modelfield in non-streaming JSON response - Test checks
X-Fallback-Modelheader in streaming response - Test confirms no fallback metadata when primary model succeeds
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request