Skip to content

Conversation

@mscolnick
Copy link
Contributor

@mscolnick mscolnick commented Dec 1, 2025

Fixes #7330

Summary

Fixes an IndexError: list index out of range that occurred when using OpenAI-compatible providers (like DeepSeek) with the "Generate with AI" feature.

## Summary

Fixes an `IndexError: list index out of range` that occurred when using OpenAI-compatible providers (like DeepSeek) with the "Generate with AI" feature.
@vercel
Copy link

vercel bot commented Dec 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
marimo-docs Ready Ready Preview Comment Dec 1, 2025 3:08pm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an IndexError that occurred when using OpenAI-compatible providers (like DeepSeek) with AI streaming features. The issue arose when providers sent tool call delta chunks before the tool call start chunk, causing an out-of-bounds access to the tool_call_ids list.

  • Adds bounds checking before accessing tool_call_ids array
  • Adds comprehensive test coverage for the edge case
  • Follows existing pattern used in GoogleProvider

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
marimo/_server/ai/providers.py Added bounds check tool_index < len(tool_call_ids) in OpenAIProvider and BedrockProvider to prevent IndexError when tool deltas arrive before tool call initialization
tests/_server/ai/test_providers.py Added regression tests for both OpenAIProvider and BedrockProvider to verify graceful handling of out-of-bounds tool call indices

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mscolnick mscolnick merged commit 29a5ae2 into main Dec 1, 2025
43 of 47 checks passed
@mscolnick mscolnick deleted the ms/deepseek branch December 1, 2025 17:18
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.

Error in AI streaming response: list index out of range

3 participants