Skip to content

openai native web search tool enabled#2410

Merged
sawka merged 2 commits intomainfrom
sawka/openai-native-web-search
Oct 9, 2025
Merged

openai native web search tool enabled#2410
sawka merged 2 commits intomainfrom
sawka/openai-native-web-search

Conversation

@sawka
Copy link
Member

@sawka sawka commented Oct 9, 2025

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 9, 2025

Walkthrough

Adds native web search support and tracking across chat, backend, and telemetry layers. Introduces AllowNativeWebSearch in WaveChatOpts to include a web_search tool in OpenAI requests. Extends streaming state to detect web_search_call events and increments webSearchCount on completion. Propagates this count into usage via new NativeWebSearchCount fields in OpenAIUsage and AIUsage, aggregates in getUsage, logs/metrics, and emits in telemetry as WaveAINativeWebSearchCount. Adjusts OpenAIRequestTool JSON tags to omitempty. Updates event handling, message/tool extraction to use threaded state. Minor formatting cleanup.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ❓ Inconclusive No pull request description was provided, so there is insufficient information to determine whether it relates to the changeset. Please add a brief description summarizing the key changes and their purpose to help reviewers understand the scope and motivation of this pull request.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly states the main change of enabling the native web search tool in the OpenAI integration and succinctly reflects the core intent of the pull request.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sawka/openai-native-web-search

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd0e75a and 29d7c43.

📒 Files selected for processing (5)
  • pkg/aiusechat/openai/openai-backend.go (10 hunks)
  • pkg/aiusechat/openai/openai-convertmessage.go (3 hunks)
  • pkg/aiusechat/uctypes/usechat-types.go (2 hunks)
  • pkg/aiusechat/usechat.go (4 hunks)
  • pkg/telemetry/telemetrydata/telemetrydata.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
pkg/aiusechat/openai/openai-convertmessage.go (1)
pkg/aiusechat/uctypes/usechat-types.go (3)
  • StopKindPremiumRateLimit (159-159)
  • DefaultOpenAIModel (13-13)
  • ThinkingLevelLow (117-117)
pkg/aiusechat/openai/openai-backend.go (1)
pkg/aiusechat/uctypes/usechat-types.go (3)
  • UIMessageDataToolUse (136-143)
  • WaveChatOpts (419-433)
  • WaveToolCall (163-168)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Build for TestDriver.ai
🔇 Additional comments (13)
pkg/aiusechat/uctypes/usechat-types.go (2)

225-229: Native web search usage field wired cleanly.

The additional counter slots neatly into AIUsage and matches the downstream JSON contract. Looks good.


420-429: Opt-in flag placement makes sense.

Adding AllowNativeWebSearch directly on WaveChatOpts keeps request construction flexible without surprising existing callers. Nice touch.

pkg/telemetry/telemetrydata/telemetrydata.go (1)

104-123: Telemetry coverage extended appropriately.

Including waveai:nativewebsearchcount ensures the new metric shows up in persisted analytics—no gaps spotted.

pkg/aiusechat/usechat.go (4)

183-199: Usage aggregation accounts for web search correctly.

The incremental sum keeps counts consistent across multi-step runs. Implementation looks solid.


339-377: Runtime metrics now expose web search count.

Streaming log + metric accumulation integrate smoothly; no regressions spotted.


529-550: Telemetry payload forwards native web search totals.

End-to-end propagation is complete—thanks for keeping analytics in sync.


602-609: Server side opts-in to native web search.

Setting the flag here keeps client behavior centralized; matches the new request tooling.

pkg/aiusechat/openai/openai-convertmessage.go (2)

77-83: omitempty change enables minimal web search payload.

Good call—avoids emitting empty strings when injecting the native tool.


186-192: Conditional web search tool injection looks correct.

Only fires when explicitly allowed and keeps payload minimal. Nice implementation.

pkg/aiusechat/openai/openai-backend.go (4)

124-130: Usage accessor now surfaces native web search count.

This keeps the public AIUsage API aligned with the backend data—looks tidy.


327-335: Streaming state extension is lightweight and focused.

Tracking webSearchCount alongside existing state keeps parsing responsibilities localized.


766-792: Response extraction propagates search counts reliably.

Hooking the streaming counter into the final message usage cleanly closes the loop.


877-964: Final message construction handles search telemetry gracefully.

Assistant message picks up both usage metadata and tool call attachments—solid end-to-end wiring.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sawka sawka merged commit ef6366f into main Oct 9, 2025
8 checks passed
@sawka sawka deleted the sawka/openai-native-web-search branch October 9, 2025 22:06
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.

1 participant