Improve Mistral rate-limit handling and add cooldown probe scripts#70
Conversation
There was a problem hiding this comment.
The PR improves Mistral API rate-limit handling with better cooldown logic and adaptive backoff. The Kotlin changes look solid - increased minimum interval to 1500ms, added header parsing for server-specified delays, and improved retry logic with adaptive backoff.
Critical security issue found in the probe script: hardcoded API key must be replaced with environment variable to prevent credential exposure in version control.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
| import time | ||
| from typing import Tuple, List | ||
|
|
||
| MISTRAL_API_KEY = "zsEegAJFadHH4uooe2lW0HVNmy1rpqGT" |
There was a problem hiding this comment.
🛑 Security Vulnerability: Hardcoded API key exposes credentials in version control1
Replace with environment variable to prevent credential leakage.
| MISTRAL_API_KEY = "zsEegAJFadHH4uooe2lW0HVNmy1rpqGT" | |
| MISTRAL_API_KEY = os.environ.get("MISTRAL_API_KEY", "") |
Footnotes
-
CWE-798: Use of Hard-coded Credentials - https://cwe.mitre.org/data/definitions/798.html ↩
| import json | ||
| import subprocess | ||
| import time |
There was a problem hiding this comment.
Missing import for os module required for environment variable access. This will cause a NameError at runtime when the suggested fix is applied.
| import json | |
| import subprocess | |
| import time | |
| import json | |
| import os | |
| import subprocess | |
| import time |
…tCoordinator.kt Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com>
…or Mistral coordinator Update callMistralApi to accept and use multiple API keys for proper rotation through MistralRequestCoordinator, instead of defeating the coordinator's purpose with a single-key list
…limit-issue Introduce MistralRequestCoordinator and queueing for Mistral auto-screenshots
Motivation
Description
1100Lto1500Land add an overloadedmarkKeyCooldownthat accepts anextraDelayMsto honor server-specified delays and adaptive backoff.Retry-Afterandx-ratelimit-resetheaders viaparseRetryAfterMsandparseRateLimitResetDelayMs, and compute an adaptive retry delay withadaptiveRetryDelayMsto escalate waits on repeated failures.maxAttemptsand improve retry/error handling to mark keys as blocked and to throw clearer errors after exhausting attempts, plus ensurestopExecutionFlagis set/reset appropriately and addroundToLongimport used by header parsing.scripts/mistral_cooldown_probe.pyandscripts/mistral_cooldown_probe.shto probe cooldown timing by exercising streaming and non-streaming requests and measuring minimal successful wait intervals.Testing
./gradlew assembleDebug,./gradlew testand./gradlew lint, and they completed successfully.python3 scripts/mistral_cooldown_probe.pywrapper present), and no automated tests failed during the change.Codex Task