Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(autofix): Retry stream from where it left off #1675

Closed
wants to merge 7 commits into from

Conversation

kddubey
Copy link
Contributor

@kddubey kddubey commented Dec 28, 2024

Fix #1671.

Investigation found that backoff would address almost all of the overloaded errors.

Decided (see Notes at bottom of this notebook) to store the partial completion, and pass it as a new assistant message which the Anthropic API will continue generating.

Problems with this solution

Doesn't work when tools are provided. From the bottom of the test notebook:

BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'Your API request included an `assistant` message in the final position, which would pre-fill the `assistant` response. When using tools, pre-filling the `assistant` response is not supported.'}}

Can result in wrong newline generation when generating markdown. I didn't see formatting errors in code though. See the "Notes" section in the test notebook.

Note: prolly doesn't gel well w/ #1650

@kddubey kddubey changed the title feat(autofix): Retry stream from where it left off fix(autofix): Retry stream from where it left off Jan 3, 2025
@kddubey kddubey closed this Jan 18, 2025
@kddubey kddubey deleted the kddubey/autofix/retry-stream branch January 18, 2025 00:27
kddubey added a commit that referenced this pull request Jan 24, 2025
[Investigation](https://github.com/getsentry/ml-models/blob/main/autofix/retry_stream/investigate_errors.ipynb)
found that backoff would address almost all of the overloaded errors.

Fix #1671 by retrying the completion from scratch, unlike #1675.

## How has this been tested?

New unit tests and local runs described below

<details>
<summary>Local autofix runs</summary>

Repro issue locally:

1. `git checkout main`
2. Replace all `AnthropicProvider`s with `AnthropicProviderFlaky`s in
`coding/components.py`.
3. Run the Autofix coding step on a local issue, confirm you see the
overloaded error and the run fails.
4. `git stash` the stuff in step 2 b/c we'll use it again when testing
the fix.

Test fix:

1. `git checkout kddubey/autofix/retry-stream-from-scratch`
2. `git stash pop` to replace all `AnthropicProvider`s with
`AnthropicProviderFlaky`s in `coding/components.py`.
3. Run Autofix on a local issue, confirm you see the overloaded error in
your logs, but it quickly tries again and finishes the run.
4. `git stash` to undo step (2) to test an unflaky API
5. Run Autofix on the same issue, confirm the run finishes fine.

</summary>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(autofix): Investigate/implement exponential backoff for streaming vertex ai calls
1 participant