Skip to content

Conversation

Weves
Copy link
Contributor

@Weves Weves commented Sep 17, 2025

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.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

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).

  • Bug Fixes
    • Check tool availability with try/except and skip tools that aren’t available.
    • Prevent initialize-time failures for the image gen tool when env/provider is missing.
    • Added test ensuring chat streams correctly with only an Anthropic provider configured.

Copy link

vercel bot commented Sep 17, 2025

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

Project Deployment Preview Comments Updated (UTC)
internal-search Ready Ready Preview Comment Sep 17, 2025 9:58pm

@Weves Weves marked this pull request as ready for review September 17, 2025 21:25
@Weves Weves requested a review from a team as a code owner September 17, 2025 21:25
@Weves Weves changed the title Fix image gen tool causing error fix: image gen tool causing error Sep 17, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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

Edit Code Review Bot Settings | Greptile

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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&#39;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.

@Weves Weves merged commit 4b0c6d1 into main Sep 17, 2025
53 of 54 checks passed
@Weves Weves deleted the fix-image-gen-tool-causing-error branch September 17, 2025 23:39
wenxi-onyx pushed a commit that referenced this pull request Sep 18, 2025
wenxi-onyx pushed a commit that referenced this pull request Sep 18, 2025
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.

2 participants