Skip to content

Conversation

joachim-danswer
Copy link
Contributor

@joachim-danswer joachim-danswer commented Aug 26, 2025

Description

A number of smaller fixes addressing observed issues:

  • fix of budget calculation in thoughtful mode
  • Showing name of selected internal tool, even if used by the Generic Internal Tool subagent
  • special-casing Okta answer generation

Linear ticket: https://linear.app/danswer/issue/DAN-2337/drthoughtful-mode-fixes-with-okta

How Has This Been Tested?

Locally, using various question examples

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

Fixes DR/Thoughtful mode budget handling, improves internal tool labeling, and adds Okta-specific answer formatting for more accurate, readable outputs. Addresses Linear DAN-2337.

  • Bug Fixes
    • Correctly subtract tool cost using next_tool_name; remove default closer fallback to avoid mis-spend.
    • Show the tool’s display_name in outputs and include llm_name in iteration responses; set response_type to text.
    • Add Okta-specific tool-use prompt and route “Okta Profile” through it to format results and restrict answers to Okta data.
    • Emit explicit type fields for CustomToolStart and CustomToolDelta events; minor prompt copy tweaks for clarity.

@joachim-danswer joachim-danswer requested a review from a team as a code owner August 26, 2025 23:55
Copy link

vercel bot commented Aug 26, 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 Aug 27, 2025 3:30am

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 implements several targeted fixes for the DR (Deep Research) / Thoughtful mode system, addressing three main categories of issues:

Budget calculation fixes: The orchestrator now correctly uses next_tool_name instead of next_tool when accessing the available_tools dictionary for cost calculations. This prevents KeyError exceptions that would occur when the system attempts to subtract tool costs from the remaining time budget.

Tool display improvements: The generic internal tool sub-agent now uses display_name and llm_name properties instead of internal path names, ensuring users see meaningful tool names in the interface. Additionally, CustomToolStart and CustomToolDelta events now explicitly set their 'type' fields, which is required for proper Pydantic discriminated union processing in the streaming event system.

Okta-specific handling: A new specialized prompt template OKTA_TOOL_USE_SPECIAL_PROMPT has been added specifically for Okta Profile tools, which formats raw Okta responses into readable output before providing answers. The generic tool prompt has also been streamlined by removing redundant instructions about explaining tool functions.

Code cleanup: Unused variable assignments have been removed from the orchestrator, eliminating dead code while preserving necessary dictionary access for validation purposes.

These changes integrate with the existing DR system architecture by maintaining the same event-driven flow while fixing critical runtime issues and improving user experience through better tool identification and specialized response formatting.

Confidence score: 4/5

  • This PR addresses specific runtime bugs and improves user experience with minimal risk to existing functionality
  • Score reflects targeted fixes to well-defined issues with clear implementation approaches
  • Pay close attention to the orchestrator budget calculation logic to ensure the variable name fixes don't introduce edge cases

4 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 4 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

specific task query using the tool response.
If the tool definition and response did not provide information relevant to the specific context mentioned \
in the query, start out with a short statement highlighting this (e.g., I was not able to find information \
If the tool definition and response did not provide information relevant to the specific task query mentioned \
Copy link
Contributor

Choose a reason for hiding this comment

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

Comma is incorrectly placed on the next line, causing malformed "mentioned , start" output; add the comma at the end of the previous line before the continuation

Prompt for AI agents
Address the following comment on backend/onyx/prompts/dr_prompts.py at line 902:

<comment>Comma is incorrectly placed on the next line, causing malformed &quot;mentioned , start&quot; output; add the comma at the end of the previous line before the continuation</comment>

<file context>
@@ -863,10 +897,10 @@
    - while the base question is important, really focus on answering the specific task query. \
 That is your task.
 
-Please respond with a short sentence explaining what the tool does and provide a concise answer to the \
+Please respond with a concise answer to the \
 specific task query using the tool response.
-If the tool definition and response did not provide information relevant to the specific context mentioned \
-in the query, start out with a short statement highlighting this (e.g., I was not able to find information \
+If the tool definition and response did not provide information relevant to the specific task query mentioned \
</file context>

reasoning="",
additional_data=None,
response_type="string",
response_type="text",
Copy link
Contributor

Choose a reason for hiding this comment

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

should be Enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should. But this comes from the definition of CustomToolDelta etc. : response_type: str
Should be an enum there. Added a todo at a couple of spots.

@Weves Weves merged commit 2b23dbd into main Aug 27, 2025
11 of 15 checks passed
@Weves Weves deleted the small-post-DR-fixes branch August 27, 2025 05:33
AnkitTukatek pushed a commit to TukaTek/onyx that referenced this pull request Sep 23, 2025
* fix budget calculation

* Internal custom tool fix + Okta special casing

* nits

* CW comments
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