Skip to content

Fix OpenAI stable web search action parameters - #6722

Merged
IMax153 merged 2 commits into
Effect-TS:mainfrom
mrtdurdenthe2:fix/openai-web-search-action-params
Aug 3, 2026
Merged

Fix OpenAI stable web search action parameters#6722
IMax153 merged 2 commits into
Effect-TS:mainfrom
mrtdurdenthe2:fix/openai-web-search-action-params

Conversation

@mrtdurdenthe2

@mrtdurdenthe2 mrtdurdenthe2 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Stable OpenAI web_search responses currently become Effect tool calls with params: {}, while OpenAiTool.WebSearch requires params.action. A successful provider response therefore fails Effect response decoding with InvalidOutputError: Missing key at ["params"]["action"].

This change preserves the existing public tool schema and maps the completed provider action into stable web search tool-call parameters. For streaming responses, the initial response.output_item.added event may not contain action, so the stable tool call is emitted when response.output_item.done provides the completed action. WebSearchPreview keeps its existing empty-parameter behavior.

OpenAI API Reference

OpenAI documents that Responses API web search output includes “a web_search_call output item with the ID of the search call, along with the action taken in web_search_call.action.”

https://platform.openai.com/docs/guides/tools-web-search#output-and-citations

The documented response shape includes:

{
  "type": "web_search_call",
  "id": "ws_...",
  "status": "completed",
  "action": {
    "type": "search",
    "query": "latest news about AI"
  }
}

Testing

  • Added deterministic non-streaming coverage with gpt-4.1 and gpt-5.6 model configurations.
  • Added streaming coverage where the partial item omits action and the completed item supplies it.
  • Verified the provider action remains available in both tool-call parameters and the tool result.
  • pnpm test --run: 96 tests passed.
  • pnpm check: passed.
  • pnpm build: passed.
  • dprint, oxlint, and git diff --check: passed.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed OpenAI web search responses so search actions are correctly preserved in tool calls and results.
    • Improved streamed web search handling by waiting for complete action details before emitting tool-call events.
    • Ensured stable web search actions include the expected search type and query.

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 28, 2026
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b575c32

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 29 packages
Name Type
@effect/ai-openai Patch
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d47f4a8-aa00-455b-9688-f1f5b6e950b1

📥 Commits

Reviewing files that changed from the base of the PR and between 35141f1 and b575c32.

📒 Files selected for processing (3)
  • .changeset/fix-openai-web-search-action.md
  • packages/ai/openai/src/OpenAiLanguageModel.ts
  • packages/ai/openai/test/OpenAiLanguageModel.test.ts

📝 Walkthrough

Walkthrough

OpenAI web search response conversion now preserves stable action metadata in non-streaming and streaming tool calls. Tests cover generated and streamed responses, and a patch Changesets entry documents the fix.

Changes

OpenAI web search action decoding

Layer / File(s) Summary
Preserve stable web search actions
packages/ai/openai/src/OpenAiLanguageModel.ts, .changeset/fix-openai-web-search-action.md
Non-streaming tool calls include stable actions, while streaming tool calls wait for completed output items before emitting action parameters.
Test stable web search decoding
packages/ai/openai/test/OpenAiLanguageModel.test.ts
Tests validate stable action parameters and completed tool results for generated and streamed responses.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: tim-smart

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

@effect-slopcop effect-slopcop Bot added 4.0 bug Something isn't working labels Jul 28, 2026
Comment thread packages/ai/openai/test/OpenAiLanguageModel.test.ts Outdated
Comment thread packages/ai/openai/test/OpenAiLanguageModel.test.ts Outdated
Comment thread packages/ai/openai/test/OpenAiLanguageModel.test.ts Outdated
@mrtdurdenthe2
mrtdurdenthe2 marked this pull request as ready for review July 29, 2026 19:26
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
basic.ts 6.63 KB 6.63 KB 0.00 KB (0.00%)
batching.ts 9.42 KB 9.42 KB 0.00 KB (0.00%)
brand.ts 6.31 KB 6.31 KB 0.00 KB (0.00%)
cache.ts 10.12 KB 10.12 KB 0.00 KB (0.00%)
config.ts 19.90 KB 19.90 KB 0.00 KB (0.00%)
differ.ts 20.03 KB 20.03 KB 0.00 KB (0.00%)
http-client.ts 20.94 KB 20.94 KB 0.00 KB (0.00%)
logger.ts 10.28 KB 10.28 KB 0.00 KB (0.00%)
metric.ts 8.55 KB 8.55 KB 0.00 KB (0.00%)
optic.ts 7.33 KB 7.33 KB 0.00 KB (0.00%)
pubsub.ts 14.26 KB 14.26 KB 0.00 KB (0.00%)
queue.ts 11.09 KB 11.09 KB 0.00 KB (0.00%)
schedule.ts 10.27 KB 10.27 KB 0.00 KB (0.00%)
schema-class.ts 18.86 KB 18.86 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.78 KB 28.78 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.09 KB 25.09 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.95 KB 12.95 KB 0.00 KB (0.00%)
schema-string.ts 10.65 KB 10.65 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.85 KB 14.85 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 21.66 KB 21.66 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.10 KB 24.10 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.00 KB 19.00 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.73 KB 18.73 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.59 KB 18.59 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.23 KB 22.23 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.27 KB 19.27 KB 0.00 KB (0.00%)
schema.ts 18.12 KB 18.12 KB 0.00 KB (0.00%)
stm.ts 12.05 KB 12.05 KB 0.00 KB (0.00%)
stream.ts 9.37 KB 9.37 KB 0.00 KB (0.00%)

@mrtdurdenthe2

Copy link
Copy Markdown
Contributor Author

@IMax153 Sorry, not sure if you get notifications for resolving the reviews.

Also thanks for the reviews 😃

@IMax153
IMax153 merged commit 9344742 into Effect-TS:main Aug 3, 2026
17 checks passed
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Done in PR Backlog Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 bug Something isn't working ready for review

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants