kiro: update API version and retry transient 500s
The Kiro/CodeWhisperer API started rejecting tool-use requests from older API versions (0.1.14474) with InternalServerException. Update to 0.1.16551 and appVersion 0.12.333 to match kiro-cli. Also add retry with linear backoff (1-5s) for transient 500 errors which still occur intermittently even with the correct version.
This commit is contained in:
parent
fd20070294
commit
0fc9c9613c
|
|
@ -185,9 +185,14 @@ func (b *CodeWhispererBackend) runStream(ctx context.Context, req *kiroGenerateR
|
|||
|
||||
if streamErr != nil {
|
||||
var apiErr *kiroAPIError
|
||||
if errors.As(streamErr, &apiErr) && apiErr.isThrottled() && throttleAttempts < kiroMaxThrottleRetries {
|
||||
if errors.As(streamErr, &apiErr) && (apiErr.isThrottled() || apiErr.isTransient()) && throttleAttempts < kiroMaxThrottleRetries {
|
||||
throttleAttempts++
|
||||
wait := kiroThrottleBaseDelay << (throttleAttempts - 1)
|
||||
var wait time.Duration
|
||||
if apiErr.isThrottled() {
|
||||
wait = kiroThrottleBaseDelay << (throttleAttempts - 1)
|
||||
} else {
|
||||
wait = time.Duration(throttleAttempts) * time.Second
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
ch <- StreamEvent{Done: true, StopReason: ctx.Err().Error()}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ const (
|
|||
kiroAgentTaskType = "vibe"
|
||||
kiroAmzSDKRequest = "attempt=1; max=3"
|
||||
|
||||
kiroUserAgent = "aws-sdk-rust/1.3.14 ua/2.1 api/codewhispererstreaming/0.1.14474 os/linux lang/rust/1.92.0 md/appVersion-1.27.2 app/AmazonQ-For-CLI"
|
||||
kiroAmzUserAgent = "aws-sdk-rust/1.3.14 ua/2.1 api/codewhispererstreaming/0.1.14474 os/linux lang/rust/1.92.0 m/F app/AmazonQ-For-CLI"
|
||||
kiroUserAgent = "aws-sdk-rust/1.3.14 ua/2.1 api/codewhispererstreaming/0.1.16551 os/linux lang/rust/1.92.0 md/appVersion-0.12.333 app/AmazonQ-For-CLI"
|
||||
kiroAmzUserAgent = "aws-sdk-rust/1.3.14 ua/2.1 api/codewhispererstreaming/0.1.16551 os/linux lang/rust/1.92.0 m/F app/AmazonQ-For-CLI"
|
||||
|
||||
kiroOIDCUserAgent = "aws-sdk-rust/1.3.10 os/linux lang/rust/1.92.0"
|
||||
kiroOIDCAmzUserAgent = "aws-sdk-rust/1.3.10 ua/2.1 api/ssooidc/1.92.0 os/linux lang/rust/1.92.0 m/E app/AmazonQ-For-CLI"
|
||||
|
|
@ -349,6 +349,10 @@ func (e *kiroAPIError) isThrottled() bool {
|
|||
return e.StatusCode == http.StatusTooManyRequests || e.Code == "ThrottlingException"
|
||||
}
|
||||
|
||||
func (e *kiroAPIError) isTransient() bool {
|
||||
return e.StatusCode == http.StatusInternalServerError || e.Code == "InternalServerException"
|
||||
}
|
||||
|
||||
type kiroStreamCallbacks struct {
|
||||
OnAssistantDelta func(kiroAssistantEvent)
|
||||
}
|
||||
|
|
@ -634,8 +638,8 @@ func (c *kiroOIDCClient) RefreshToken(ctx context.Context, req kiroRefreshTokenR
|
|||
|
||||
const (
|
||||
kiroListModelsTarget = "AmazonCodeWhispererService.ListAvailableModels"
|
||||
kiroListModelsUserAgent = "aws-sdk-rust/1.3.14 ua/2.1 api/codewhispererruntime/0.1.14474 os/linux lang/rust/1.92.0 md/appVersion-1.27.2 app/AmazonQ-For-CLI"
|
||||
kiroListModelsAmzUserAgent = "aws-sdk-rust/1.3.14 ua/2.1 api/codewhispererruntime/0.1.14474 os/linux lang/rust/1.92.0 m/F,C app/AmazonQ-For-CLI"
|
||||
kiroListModelsUserAgent = "aws-sdk-rust/1.3.14 ua/2.1 api/codewhispererruntime/0.1.16551 os/linux lang/rust/1.92.0 md/appVersion-0.12.333 app/AmazonQ-For-CLI"
|
||||
kiroListModelsAmzUserAgent = "aws-sdk-rust/1.3.14 ua/2.1 api/codewhispererruntime/0.1.16551 os/linux lang/rust/1.92.0 m/F,C app/AmazonQ-For-CLI"
|
||||
)
|
||||
|
||||
type kiroListModelsRequest struct {
|
||||
|
|
|
|||
Reference in New Issue