Skip to content

feat: trace hosted web search in Langfuse - #318

Open
AlexZahar wants to merge 1 commit into
danny-avila:mainfrom
AlexZahar:codex/langfuse-web-search-observability
Open

feat: trace hosted web search in Langfuse#318
AlexZahar wants to merge 1 commit into
danny-avila:mainfrom
AlexZahar:codex/langfuse-web-search-observability

Conversation

@AlexZahar

Copy link
Copy Markdown

Summary

  • request web_search_call.action.sources for OpenAI and Azure Responses calls using hosted web search
  • emit each provider web_search_call as one child Langfuse tool observation
  • record the action, provider call ID, status, source count, and source URLs without fetched page bodies
  • deduplicate repeated streamed output items by provider call ID
  • keep telemetry best-effort so tracing failures cannot block model responses

This is independent from #317. It does not change web-search routing or execute an additional search.

Verification

  • npm test -- --runInBand src/llm/openai/llm.spec.ts src/llm/openai/contentBlocks.test.ts src/specs/langfuse-callbacks.test.ts (71 passed)
  • npm run build
  • Prettier, ESLint, and staged-file checks passed.

@danny-avila

Copy link
Copy Markdown
Owner

@codex review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80d3a64f95

ℹ️ 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".

Comment thread src/llm/openai/index.ts
function usesHostedWebSearch(tools?: OpenAIClient.Responses.Tool[]): boolean {
return (
tools?.some(
(tool) => tool.type === 'web_search' || tool.type === 'web_search_preview'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include versioned hosted web-search tools

With the current Responses API, hosted web search tools can also be sent as web_search_2025_08_26, not just web_search/web_search_preview (OpenAI API reference). In that case this predicate returns false, so invocationParams never adds web_search_call.action.sources and the Langfuse tool observation records no sources even though the call used hosted web search. Include the versioned hosted web-search tool type here.

Useful? React with 👍 / 👎.

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