Skip to content

feat: forward x_search time range and image search in console provider - #892

Open
0xlinn wants to merge 2 commits into
chenyme:mainfrom
0xlinn:feat/console-x-search-time-range-image-search
Open

feat: forward x_search time range and image search in console provider#892
0xlinn wants to merge 2 commits into
chenyme:mainfrom
0xlinn:feat/console-x-search-time-range-image-search

Conversation

@0xlinn

@0xlinn 0xlinn commented Aug 11, 2026

Copy link
Copy Markdown

Summary

The Console provider path (normalizeConsoleTools in backend/internal/infra/provider/console/normalize.go) currently strips every x_search field except type/enable_video_understanding, and every web_search field except type/enable_image_understanding. Clients that send the official xAI fields from_date/to_date (X search time bounds) and enable_image_search (image search toggle) silently lose them.

Changes

  • web_search: pass through enable_image_search (official xAI Web Search tool field, see https://docs.x.ai/developers/tools/web-search)
  • x_search: pass through from_date/to_date (official xAI X Search fields, YYYY-MM-DD) with:
    • format validation (drop invalid, matching the console provider's tolerate-and-drop style rather than rejecting the request)
    • order validation: if from_date > to_date, both are dropped to avoid an upstream 400

The cli provider already validates these exact fields (responses_tool_types.go normalizeXSearchTool), so this brings the Console path closer to the same wire contract.

Compatibility

No behavior change for requests that do not set the new fields: existing tools are normalized exactly as before (defaults enable_image_understanding: true, enable_video_understanding: true unchanged). Invalid values are dropped, never passed upstream.

Notes / residual risk

  • Console path still intentionally does not forward allowed_domains / excluded_domains / allowed_x_handles / excluded_x_handles (out of scope for this PR).
  • Invalid date handling differs from CLI: CLI returns 400; Console drops (consistent with existing Console strip-unknown style).

0xlinn added 2 commits August 11, 2026 23:02
Console path normalizeConsoleTools currently strips every x_search field except type/enable_video_understanding and every web_search field except type/enable_image_understanding, dropping from_date/to_date and enable_image_search that clients legitimately send.

- web_search: pass through enable_image_search (image search toggle)
- x_search: pass through from_date/to_date (YYYY-MM-DD) with format and order validation; invalid values are dropped instead of erroring, matching the console provider's tolerate-and-drop style. The cli provider already validates these fields the same way.

Behavior is unchanged for requests that do not set the new fields.
…forwarding

Add table-style subtests for normalizeConsoleTools:

- forward enable_image_search on web_search; omit when unset
- strip unknown web_search fields
- forward valid x_search from_date/to_date
- drop invalid formats and inverted ranges
- keep single-sided from_date

Keeps Console's tolerate-and-drop style (unlike CLI which returns 400).
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.

1 participant