Skip to content

Conversation

@Radu-Raicea
Copy link
Member

@Radu-Raicea Radu-Raicea commented Oct 28, 2025

This now track web search tool calls across various providers, and sends the web search count as an event property ($ai_web_search_count) to be used in calculating the LLM costs, where applicable.

@Radu-Raicea Radu-Raicea marked this pull request as ready for review October 30, 2025 20:23
@Radu-Raicea Radu-Raicea requested a review from a team October 30, 2025 20:23
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.

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

if provider_type == "chat":
if not hasattr(chunk, "usage") or not chunk.usage:
return usage

P1 Badge Detect web searches before early exit in streaming chunks

For chat completions, extract_openai_usage_from_chunk immediately returns when a chunk lacks usage. The call to extract_openai_web_search_count() is placed after this guard, so any streaming chunk that contains web search indicators (citations, web_search_call, etc.) but no usage is ignored and $ai_web_search_count will never be reported. OpenAI can emit citations before the final chunk where token usage is provided, meaning web searches won’t be captured for such streams. Extract the web search count before the early return or separate it from the usage check so non‑usage chunks can still contribute to the count.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

@andrewm4894 andrewm4894 left a comment

Choose a reason for hiding this comment

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

lgtm apart form merge conflict but approving so no delay once that sorted

@Radu-Raicea
Copy link
Member Author

@andrewm4894 Thank you!

For everyone: please do not merge, I need to run a couple of sanity checks before I merge.

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.

3 participants