Skip to content

Flatten resolutionSearchSchema for xAI compatibility#631

Merged
ngoiyaeric merged 1 commit into
mainfrom
flatten-resolution-search-schema-5297044305958981276
May 31, 2026
Merged

Flatten resolutionSearchSchema for xAI compatibility#631
ngoiyaeric merged 1 commit into
mainfrom
flatten-resolution-search-schema-5297044305958981276

Conversation

@ngoiyaeric

@ngoiyaeric ngoiyaeric commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Restructured the resolutionSearchSchema to follow a flattened pattern compatible with xAI's OpenAI-compatible endpoint. The schema was moved to a new file lib/schema/resolution-search.ts and updated to use z.string() instead of z.literal for fixed types and explicit coordinate types instead of z.any(). Top-level fields like newsContext and extractedCoordinates were flattened into individual optional fields. The resolutionSearch agent was updated to use this new schema, and reconstruction logic was added to app/actions.tsx to transform the flattened features back into a standard GeoJSON FeatureCollection for the frontend map components.


PR created automatically by Jules for task 5297044305958981276 started by @ngoiyaeric

Summary by CodeRabbit

  • Bug Fixes

    • Fixed geographic data formatting to ensure search results display correctly on maps with proper feature structures.
  • Improvements

    • Centralized schema validation for more consistent and reliable search result output formatting.

- Extract resolutionSearchSchema to lib/schema/resolution-search.ts
- Flatten schema structure to reduce nesting for better xAI compatibility
- Replace z.literal with z.string to avoid JSON Schema 'const' constraints
- Use explicit union types for coordinates instead of z.any()
- Make geoJson field optional
- Update agent prompt and field names
- Add reconstruction logic in app/actions.tsx to maintain UI compatibility with standard GeoJSON

Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
qcx Ready Ready Preview, Comment May 31, 2026 9:16am

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

The PR extracts the resolution search output schema into a centralized Zod definition, updates the agent to use this schema for structured output validation, and refactors the action flow to reconstruct a standard GeoJSON FeatureCollection from the validated features and persist it for rendering.

Changes

Resolution search schema centralization and GeoJSON handling

Layer / File(s) Summary
Shared resolution search schema definition
lib/schema/resolution-search.ts
Defines resolutionSearchSchema with optional flattened fields for extracted coordinates, COG metadata, recent news context, and nested geoJson FeatureCollection structure; exports inferred ResolutionSearch TypeScript type compatible with OpenAI structured output.
Agent schema usage and prompt alignment
lib/agents/resolution-search.tsx
Imports centralized resolutionSearchSchema for streamObject validation and updates systemPrompt "Structured Output" instruction to require geoJson (if any), news context, and extracted coordinates/COG information.
GeoJSON reconstruction and persistence
app/actions.tsx
Reconstructs a standard FeatureCollection GeoJSON object from agent-validated feature array, passes reconstructed data to GeoJsonLayer for rendering, and stores it in persisted resolution_search_result state.

Sequence Diagram(s)

sequenceDiagram
    participant Agent as resolution-search agent
    participant Action as resolution_search action
    participant Storage as AI state storage
    participant Render as GeoJsonLayer
    Agent->>Action: analysisResult with geoJson.features[]
    Action->>Action: reconstruct FeatureCollection<br/>from features array
    Action->>Render: pass reconstructed geoJson
    Action->>Storage: persist geoJson in<br/>resolution_search_result
    Render->>Render: render GeoJSON features
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • QueueLab/QCX#316: Directly related prior work on the resolution_search pipeline in app/actions.tsx and lib/agents/resolution-search.tsx, including geoJson production and validation.
  • QueueLab/QCX#589: Concurrent work expanding resolution search with Tavily news context and schema updates; the main PR consolidates these schema changes into a single shared definition.

Suggested labels

Review effort 3/5

Poem

A rabbit hops through schema fields so clean,
GeoJSON features dance in layers between,
Centralized and validated, geospatial dreams,
The action flow reconstructs and redeems! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: flattening the resolutionSearchSchema for xAI compatibility, which is the core objective of the pull request.
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 flatten-resolution-search-schema-5297044305958981276

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 and usage tips.

@ngoiyaeric ngoiyaeric merged commit b110b93 into main May 31, 2026
3 of 5 checks passed
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