-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: image gen tool causing error #5445
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR fixes a critical bug where the image generation tool would cause system crashes during tool construction when OpenAI or Azure DALLE providers weren't configured. The fix implements graceful degradation by adding availability checking for built-in tools before initialization.
The core change is in tool_constructor.py
where the existing is_available()
method calls are now wrapped in a try-catch block. When a tool's availability check fails or returns false, the tool is simply skipped rather than causing the entire tool construction process to fail. This is particularly important for the ImageGenerationTool
, which requires OpenAI/Azure providers - without this fix, deployments with only Anthropic providers would crash during chat streaming initialization.
The PR also includes a comprehensive integration test (test_answer_without_openai.py
) that validates the fix by setting up an Anthropic-only environment and ensuring chat streaming works correctly without errors. This test specifically removes all existing LLM providers, configures only Anthropic, and verifies that the system can successfully stream chat responses without the image generation tool causing initialization failures.
This change aligns with the codebase's principle of "fail loudly instead of silently letting errors slip" by explicitly logging when tools are unavailable while gracefully continuing operation with available tools. The fix maintains backward compatibility and doesn't change the tool API - it simply makes the system more resilient to missing provider configurations.
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it implements defensive programming practices
- Score reflects solid error handling implementation and comprehensive test coverage for the specific bug scenario
- Pay close attention to the tool construction logic to ensure no edge cases were missed
2 files reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="backend/onyx/tools/tool_constructor.py">
<violation number="1" location="backend/onyx/tools/tool_constructor.py:218">
Avoid logger.exception here; it can log sensitive details from the exception/traceback. Log a safe message without exception details instead.
(Based on your team's feedback about not logging raw exception strings that may include URLs with temporary auth tokens.)</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai
to give feedback, ask questions, or re-run the review.
Description
[Provide a brief description of the changes in this PR]
How Has This Been Tested?
[Describe the tests you ran to verify your changes]
Backporting (check the box to trigger backport action)
Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.
Summary by cubic
Skip unavailable built‑in tools during construction to prevent the image generation tool from causing errors. This avoids crashes when some providers aren’t configured and keeps chat streaming working (e.g., Anthropic‑only).