Skip to content

feat(protocols): implement P4 IncludeField web_search_call variants - #1274

Merged
slin1237 merged 1 commit into
mainfrom
feat/audit-p4-include-field
Apr 21, 2026
Merged

slin1237 merged 1 commit into
mainfrom
feat/audit-p4-include-field

Conversation

@slin1237

@slin1237 slin1237 commented Apr 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements audit task P4: add the two missing IncludeField variants (web_search_call.action.sources, web_search_call.results) so spec-valid payloads for the top-level include[] array deserialize cleanly. Unblocks audit task T3 (web_search non-preview tool).

What changed

  • crates/protocols/src/responses.rs:
    • +2 IncludeField variants with #[serde(rename)] strings byte-identical to spec:
      • WebSearchCallActionSources → "web_search_call.action.sources"
      • WebSearchCallResults → "web_search_call.results"
    • +1 serde round-trip unit test covering both new renames and spec-listed existing variants.
  • Single-file blast radius: +27 / -0.

Why

OpenAI Responses API spec lists 8 allowed values for the top-level include[] array (see .claude/_audit/openai-responses-api-spec.md:71-79, specifically lines 73-74). smg previously modeled only 6; spec-valid clients sending "web_search_call.results" or "web_search_call.action.sources" hit deserialization failure. Pure additive schema change.

Verification

  • cargo check -p openai-protocol passes (isolated CARGO_TARGET_DIR=/tmp/p4-target to avoid worktree cache collision)
  • cargo test -p openai-protocol → 83/83 pass including the new test_include_field_web_search_call_variants_round_trip
  • cargo +nightly fmt --all -- --check silent
  • cargo clippy -p openai-protocol --all-targets --all-features -- -D warnings clean
  • Tech Lead independent spec-roundtrip: hand-built 8-value fixture from spec file, all byte-identical both directions → APPROVE
  • Codex review: unavailable (harness skill permission; Lead proceeded solo per playbook §8 fallback after own roundtrip passed)
  • Grep: grep -rn 'match.*IncludeField' across crates/, model_gateway/, bindings/, e2e_test/ → zero hits (no exhaustive match needs updating)
  • Grep: grep -rn 'IncludeField::' → 4 references, all construction or .contains(…), additive-safe
  • Grep: grep -rn 'IncludeField' bindings/ → zero hits (no Python/Go mirror)

Blast radius

Exactly 1 file: crates/protocols/src/responses.rs. Matches audit's declared Blast Radius.

Out of scope

  • WebSearchCall output struct missing typed results field — belongs to T3 (P4-dependent), not P4's acceptance criteria.
  • Runtime response-shaping for the new include values — T3's scope.

Refs: audit task P4 · .claude/_audit/responses-api-gap-audit.md

Summary by CodeRabbit

  • New Features

    • Added support for two new include-field options to return more detailed web search call data (action sources and results).
  • Tests

    • Added a unit test to validate encoding/decoding of the new include-field options.

@coderabbitai

coderabbitai Bot commented Apr 21, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b2485312-7176-4a6d-a7a3-1d122c81152b

📥 Commits

Reviewing files that changed from the base of the PR and between d1dc9f9 and 16cf2e0.

📒 Files selected for processing (1)
  • crates/protocols/src/responses.rs

📝 Walkthrough

Walkthrough

Added two new public IncludeField enum variants with serde renames for web search call metadata and a unit test that deserializes, asserts ordering, and round-trips serialization for those fields.

Changes

Cohort / File(s) Summary
Protocol Enum Extension & Tests
crates/protocols/src/responses.rs
Added WebSearchCallActionSources and WebSearchCallResults variants to pub enum IncludeField with serde(rename = "..."). Added a unit test that deserializes a JSON array into these variants, asserts exact vector contents/order, and verifies serialization round-trip.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

tests

Suggested reviewers

  • CatherineSue
  • key4ng

Poem

🐰 Two fields hop into the light,
Mapped by serde, tidy and bright,
Tests nibble through order and round-trip,
Data dances, then takes a skip,
A cheerful carrot-shaped commit tonight.

🚥 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 accurately and specifically describes the main change: adding two new IncludeField web_search_call variants to align with the OpenAI Responses API spec.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/audit-p4-include-field

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

@claude claude 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.

Looks good — two new IncludeField variants with correct serde renames matching the OpenAI Responses API spec, consistent naming convention with existing variants, and a solid round-trip test. No issues found.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds the WebSearchCallActionSources and WebSearchCallResults variants to the IncludeField enum, including their corresponding serialization mappings. A unit test was also added to verify the round-trip serialization and deserialization of these new fields. I have no feedback to provide.

@github-actions github-actions Bot added the protocols Protocols crate changes label Apr 21, 2026
What:
- Add two variants to `IncludeField` in crates/protocols/src/responses.rs:
  - WebSearchCallActionSources  -> "web_search_call.action.sources"
  - WebSearchCallResults        -> "web_search_call.results"
- Add one serde round-trip test in the existing `mod tests` that
  deserializes both rename strings into the new variants and serializes
  them back byte-identically to the spec allowed-values list.

Why:
- OpenAI Responses API spec lists 8 allowed values for the top-level
  `include` array (openai-responses-api-spec.md:71-79). Prior to this
  change smg only modeled 6 variants; spec-valid payloads with
  "web_search_call.action.sources" or "web_search_call.results" failed
  to deserialize into `Option<Vec<IncludeField>>`, causing 400-style
  errors on otherwise-compliant clients and blocking audit task T3
  (non-preview web_search tool) that depends on P4.

How:
- Purely additive: `IncludeField` uses explicit `#[serde(rename)]` per
  variant with no `#[serde(other)]` or `#[serde(untagged)]` fallback,
  so adding variants cannot alter deserialization of existing inputs.
- No downstream gating logic changes in this PR. Spec wiring for web
  search result/source inclusion is owned by T3 (currently blocked on
  P4). Only one existing variant (MessageOutputTextLogprobs) is
  inspected in code (cross-field validation at responses.rs:1097); the
  new variants keep the same "pure schema" posture.
- Round-trip test mirrors the pattern of the adjacent
  test_require_approval_*_round_trip tests: one assert on parsed value,
  one assert on re-serialized JSON.

Refs: P4
Signed-off-by: Simo Lin <linsimo.mark@gmail.com>
@slin1237
slin1237 force-pushed the feat/audit-p4-include-field branch from d1dc9f9 to 16cf2e0 Compare April 21, 2026 05:26
@slin1237
slin1237 merged commit 1da2cbc into main Apr 21, 2026
46 checks passed
@slin1237
slin1237 deleted the feat/audit-p4-include-field branch April 21, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

protocols Protocols crate changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant