Skip to content

fix(responses): strip Muse web_search fields on direct Meta - #3964

Closed
ildunari wants to merge 1 commit into
lidge-jun:devfrom
ildunari:fix/muse-spark-meta-web-search-strip
Closed

fix(responses): strip Muse web_search fields on direct Meta#3964
ildunari wants to merge 1 commit into
lidge-jun:devfrom
ildunari:fix/muse-spark-meta-web-search-strip

Conversation

@ildunari

@ildunari ildunari commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Codex still 400s on a first-turn Muse Spark request through the direct Meta Responses API because OpenCodex forwards Codex's ordinary web_search tool with search_content_types (and indexed_web_access). Meta accepts those fields only on web_search_preview.

This is the same field mismatch already sanitized for OpenCode Zen / Go. #3456 then scoped that sanitizer away from Meta on the assumption that https://api.meta.ai/v1 accepted the extra fields. Live traffic on 2026-09-07 shows that assumption is wrong.

User-visible failure

A first message of Hi never reaches the model. The client gets the raw gateway error:

{"error":{"code":null,"message":"`tools[].search_content_types` is only supported for web_search_preview tools.","param":"tools[].search_content_types","type":"invalid_request_error"}}

Poke reproduction: Hi to Studio / Say Hello returns the Meta search_content_types 400

Live OpenCodex evidence (Studio, 2026-09-07 18:47:54 local)

Field Value
Request ocx-08ac2a2e28a0c3f29b7899925d7f30cc
Provider meta-muse-spark (adapter: openai-responses, baseUrl: https://api.meta.ai/v1)
Model meta-muse-spark/muse-spark-1.3-contributor
Route explicit-provider
Status HTTP 400 in 328ms, no generation
Error invalid_request_error / tools[].search_content_types is only supported for web_search_preview tools.

Ordinary Muse Spark 1.3 turns on the same provider returned 200 earlier the same day. This is a hosted-tool bundle incompatibility, not a Meta outage.

The same direct-Meta 400 was reported on #3315 (comment) on 2026-09-02. That PR closed unmerged. #3317 expanded the model-id set. #3456 then kept the strip for Zen/Go URLs only and added a regression that preserved the field for Meta.

How to fix

Keep the existing exact-URL allowlist. Add the Meta Responses destination next to the two Zen URLs:

const MUSE_SPARK_WEB_SEARCH_STRICT_RESPONSE_URLS = new Set([
  "https://opencode.ai/zen/v1/responses",
  "https://opencode.ai/zen/go/v1/responses",
  "https://api.meta.ai/v1/responses",
]);

stripMuseSparkUnsupportedWebSearchFields already:

  • runs only for the Muse Spark Contributor model ids
  • drops search_content_types and indexed_web_access from plain web_search
  • leaves web_search_preview and every other accepted option (search_context_size, etc.) alone
  • covers top-level tools and nested additional_tools
  • ignores malformed / credentialed / query-bearing URLs

No new rewrite path. One destination, same guard.

Split baseUrl: https://api.meta.ai + responsesPath: /v1/responses resolves to the same URL, so it is covered too.

What this does not change

  • OpenCode Zen / Go behavior
  • Luna and every other non-Muse model
  • Direct Meta web_search_preview (fields stay)
  • Unrelated Responses providers

Verification

  • bun test tests/providers/muse-spark-web-search-compat.test.ts — 16 pass, 0 fail (the old "direct Meta preserves fields" case now asserts the strip; added preview preservation and split-path coverage)
  • bun run typecheck — clean
  • Live 400 captured against OpenCodex 2.47.0 on the unpatched Meta URL (screenshot + usage record above). This PR is the adapter-side fix for that request shape.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (Compatibility guard only; no user-facing config surface.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (Outbound field drop on an already-allowlisted model/URL pair. Screenshot and usage record contain no credentials.)

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Updated direct Meta AI web search request handling to remove unsupported search fields.
    • Preserved supported web search settings across top-level and nested configurations.
    • Ensured compatible behavior for split Meta AI endpoint configurations.

Direct api.meta.ai still 400s Codex search_content_types on ordinary
web_search for Muse Spark Contributor. lidge-jun#3456 scoped the sanitizer to
OpenCode Zen/Go URLs and preserved the field for Meta; live 2026-09-07
traffic shows Meta rejects the same field.

Add https://api.meta.ai/v1/responses to the exact-URL allowlist and
invert the Meta preservation regression.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions github-actions Bot added the bug Something isn't working label Sep 7, 2026
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 033aa717-ff00-4f90-a090-25988ba54af6

📥 Commits

Reviewing files that changed from the base of the PR and between eb4188a and 8488a47.

⛔ Files ignored due to path filters (1)
  • .github/pr-assets/muse-spark-meta-search-content-types-400.jpg is excluded by !**/*.jpg
📒 Files selected for processing (2)
  • src/adapters/openai-responses.ts
  • tests/providers/muse-spark-web-search-compat.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The adapter now treats the direct Meta Responses endpoint as strict for plain web_search fields. Tests cover top-level and nested tools, web_search_preview, and split baseUrl/responsesPath configuration.

Changes

Meta web search compatibility

Layer / File(s) Summary
Strict Meta web_search handling
src/adapters/openai-responses.ts:2135, 2144-2150, tests/providers/muse-spark-web-search-compat.test.ts:38-43, 228-268
The adapter strips search_content_types and indexed_web_access for plain web_search requests sent to https://api.meta.ai/v1/responses. Tests cover top-level and nested additional_tools, preserve these fields for web_search_preview, and verify split Meta endpoint configuration.

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

Merge Risk: ⚪ Minimal · up to 8488a

Direct Meta Responses requests now omit fields rejected on ordinary web_search tools while retaining supported options and web_search_preview behavior. The compatibility change is covered for direct and split configurations and is ready to merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: stripping unsupported Muse Spark web_search fields for direct Meta Responses requests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers: @lidge-jun @Ingwannu

Hygiene

Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 74 / 80

이 PR은 Muse Spark를 직접 Meta Responses(https://api.meta.ai/v1)로 보낼 때 Codex가 붙이는 평범한 web_search 도구의 search_content_types / indexed_web_access 필드 때문에 첫 턴이 HTTP 400으로 죽는 문제를 고칩니다. 증상은 “Hi” 한 마디도 모델에 닿지 않고, 게이트웨이가 tools[].search_content_types is only supported for web_search_preview tools라고 거절하는 형태입니다. PR 본문에 Studio 요청 ocx-08ac2a2e28a0c3f29b7899925d7f30cc(2026-09-07)와 #3315 당시 같은 400 보고가 같이 있습니다.

지금 dev HEAD eb4188a9fsrc/adapters/openai-responses.ts를 보면 stripMuseSparkUnsupportedWebSearchFields가 이미 있습니다. Muse Spark 1.2/1.3(+free) 모델 id에서, 목적지가 MUSE_SPARK_WEB_SEARCH_STRICT_RESPONSE_URLS에 들어 있을 때만 평범한 web_search에서 그 두 필드를 빼고, web_search_preview는 그대로 둡니다. 다만 허용 URL 집합이 OpenCode Zen/Go 두 개뿐이라, 직접 Meta(https://api.meta.ai/v1/responses)는 빠져 나갑니다. 그 범위 제한은 #3456이 “Meta는 필드를 받아들인다”고 가정하고 넣은 것이고, 이번 라이브 트래픽이 그 가정을 뒤집었습니다.

변경은 아주 작습니다. 같은 Set에 https://api.meta.ai/v1/responses 한 줄을 넣고, 주석을 Zen/Go + 직접 Meta로 고칩니다. 테스트 tests/providers/muse-spark-web-search-compat.test.ts는 “직접 Meta가 필드를 보존한다”를 “직접 Meta가 거절 필드를 벗긴다”로 바꾸고, preview 보존과 baseUrl+responsesPath 분리 조합까지 덮습니다. 런타임/카탈로그/types·config 분할과 겹치지 않습니다. #3315는 같은 방향이었지만 머지되지 않았고, 이번 패치는 이미 HEAD에 있는 가드에 URL만 더하는 쪽이어서 충돌면이 더 얇습니다.

라인 src/adapters/openai-responses.ts · MUSE_SPARK_WEB_SEARCH_STRICT_RESPONSE_URLS - 추가 URL은 정규화된 origin+pathname(끝 슬래시 제거, 소문자)과 정확히 맞아야 합니다. https://api.meta.ai/v1 같은 base만 있고 path가 빠진 문자열을 넣으면 매칭이 안 됩니다. PR은 /responses까지 넣었고, 분리 base/path 테스트로 같은 destination이 나오는지 확인합니다.

라인 tests/providers/muse-spark-web-search-compat.test.ts - 예전 “Meta는 필드를 보존” 기대가 라이브와 반대였습니다. 이번 뒤집기는 증거와 맞습니다. Luna·비-Muse·preview 경로는 그대로 둡니다.

경로 #3315 / #3456 - #3315는 미머지 잔여, #3456은 Meta를 가드 밖으로 뺀 결정입니다. 이번 PR이 그 결정을 부분 철회하는 셈이니, 머지 코멘트에 “#3456 Meta 예외를 라이브 400으로 되돌림”을 한 줄 적어두면 이후 기여자가 다시 예외를 넣지 않습니다.

메인테이너의 판단이 필요한 지점

너의 추천
CI 그린이면 바로 머지하세요. 한 줄 URL 허용 + 테스트 정정으로 라이브 첫 턴 400을 직접 끊습니다. types/config 분할에 걸리지 않으니 리베이스 대신 이대로 넣는 편이 낫습니다.

이 댓글은 grok-bot이 작성했습니다

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Source review at 8488a47: this is a narrowly scoped correction to an existing compatibility guard, not a new rewrite layer. The current dev allowlist still excludes the direct Meta Responses destination. The patch adds that one effective URL while keeping the four existing Muse IDs, plain web_search-only rewriting, nested additional_tools handling, and preview/non-Muse/malformed/credentialed/parameterized-destination exclusions intact. The supplied direct-Meta 400 is relevant evidence for reconsidering the old preserve-fields test.

The new test cases exercise direct Meta, preview preservation and split baseUrl/responsesPath resolution. Before final approval, please supply exact-head full runtime/typecheck CI under the repository readiness rules; the body currently records 16 focused passes and typecheck only. I have not independently executed this contributor code or made a live provider request. This is a positive scoped source review, not an overall merge approval or a claim that required CI passed.

ildunari commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@Ingwannu Ran the requested full local runtime suite and typecheck on unchanged PR head 8488a47c862047cb3077b6183bafbf7bdeef5867 (Linux container, Bun 1.4.0 / 34cbb9a40; root and GUI dependencies installed with frozen lockfiles). The working tree remains clean.

Check Result
bun run typecheck PASS, exit 0
bun run test FAIL, exit 1: aggregate 21,358 pass / 18 skip / 160 fail across 1,145 files, including all six serial lanes
Muse compatibility tests All 16 passed, including direct Meta stripping, preview preservation, and split endpoint resolution

The main parallel lane reported 21,179 pass / 18 skip / 159 fail. The six serial lanes added 179 pass / 1 fail; the failing serial lane was issue-452-empty-503.test.ts (16 pass / 1 fail).

Follow-up checks with a 30-second timeout:

  • bun run test -- --timeout 30000 tests/routing/combo-management-api.test.ts: 33 pass / 0 fail. The two rename cases that timed out in the full run pass in this isolated rerun.
  • bun run test -- --timeout 30000 tests/providers/muse-spark-web-search-compat.test.ts tests/claude-integration/claude-messages-endpoint.test.ts tests/responses/responses-self-named-namespace-scrub.test.ts: 72 pass / 8 fail. The Muse tests pass; one Claude endpoint case and seven namespace-scrub cases still fail. Some return HTTP 400 instead of 200; one error reports missing input[0].tools[0].description.

These results do not establish a green full suite, and I have not established whether the remaining failures are baseline failures or environment-dependent. No unrelated code was changed to make the tests pass. This is local execution evidence, not hosted CI evidence. The visible checks on this head are housekeeping checks only; please trigger the maintainer-controlled runtime/typecheck CI before final approval.

ildunari commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up baseline comparison for the verification report above:

Checked out the exact parent commit 5cd71ec91c82c4845f284e961e711227a6a52ed3 in a separate worktree and ran bun run test using the same Bun 1.4.0 runtime and installed dependencies. Before the run was stopped, its log covered 887 test files and reproduced 66 distinct failing test names, all of which also failed on PR head. This includes the combo rename timeouts, Claude native Responses prompt-cache/session case, and passthrough terminal-finalization cases. These 66 failures therefore also occur without this patch in this environment.

The baseline run did not complete: automatic execution approval review blocked an outbound request to an untrusted external relay because its payload could not be established. I did not bypass that restriction. The remaining 94 PR-run failure names are unclassified, not established regressions or established baseline failures.

The runtime diff is one additional allowlisted URL (https://api.meta.ai/v1/responses) plus comments; all 16 compatibility tests and typecheck passed on the PR head. No code changes are warranted by the baseline evidence collected so far, and no code was changed. This still is not a green full-suite attestation. Maintainer-controlled CI in the repository's expected environment remains needed to finish validation.

lidge-jun added a commit that referenced this pull request Sep 8, 2026
…rage, history) (#4051)

* fix(codex): keep Spark five-hour quota model-scoped

Carried from #4018 (author cb8010d6) for maintainer-side CI and sequential integration.
Closes #4017

Co-authored-by: cb8010d6 <53855466+cb8010d6@users.noreply.github.com>

* fix(codex): retain Spark quota on partial header updates

Carried from #4008 (author cb8010d6) for maintainer-side CI and sequential integration.
Closes #4007

Co-authored-by: cb8010d6 <53855466+cb8010d6@users.noreply.github.com>

* fix(codex): invalidate app-server observations at catalog boundaries

Carried from #3981 (author yansigit) for maintainer-side CI and sequential integration.

Co-authored-by: yansigit <44089734+yansigit@users.noreply.github.com>

* fix(web-search): stop inactivity timing after terminal events

Carried from #3979 (author yansigit) for maintainer-side CI and sequential integration.

Co-authored-by: yansigit <44089734+yansigit@users.noreply.github.com>

* fix(responses): strip Muse web_search fields on direct Meta

Carried from #3964 (author ildunari) for maintainer-side CI and sequential integration.

Co-authored-by: ildunari <95185577+ildunari@users.noreply.github.com>

* fix: preserve combo capabilities and skip referenced archives

Carried from #3863 (author x3M3x) for maintainer-side CI and sequential integration.

Co-authored-by: x3M3x <98298256+x3M3x@users.noreply.github.com>

* fix(codex): recover ocx1-compacted threads for native replay

Carried from #3920 (author cb8010d6) for maintainer-side CI and sequential integration.
Closes #3916

Co-authored-by: cb8010d6 <53855466+cb8010d6@users.noreply.github.com>

---------

Co-authored-by: t <a@b.com>
Co-authored-by: cb8010d6 <53855466+cb8010d6@users.noreply.github.com>
Co-authored-by: yansigit <44089734+yansigit@users.noreply.github.com>
Co-authored-by: ildunari <95185577+ildunari@users.noreply.github.com>
Co-authored-by: x3M3x <98298256+x3M3x@users.noreply.github.com>
@lidge-jun

Copy link
Copy Markdown
Owner

Landed on dev in 9587750 via #4051, which carried seven reviewed contributor fixes as one sequential integration branch. Your commit is preserved in the squash body with a Co-authored-by trailer, so the contribution stays attributed to you.

Verification at the merged head 1e32dee6e: Cross-platform CI run 34259247029 finished with 19 jobs successful and 0 failures, bun x tsc --noEmit exit 0, and 657 focused tests passing across the twelve affected files. An independent review confirmed the stacked tree is byte-identical to the union of the seven PR diffs.

Closing this PR because the change is already on dev. Thank you.

@lidge-jun lidge-jun closed this Sep 8, 2026
@lidge-jun

Copy link
Copy Markdown
Owner

Landed via #4051 at 9587750

@lidge-jun lidge-jun added the landed-via-maintainer Original PR closed after landing via a maintainer merge train label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working landed-via-maintainer Original PR closed after landing via a maintainer merge train review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants