Repository navigation
System improvements #592
Description
Next.js 16 & Gemini 3.1: Strategic Advancement Report (May 2026)
Executive Summary
This report details the latest advancements in the Next.js 16 framework and the Gemini 3.1 Pro AI model. Based on the current QCX platform architecture (Next.js 15.3, React 19.1, Gemini 3.1 Pro Preview), several high-impact upgrade opportunities have been identified to enhance performance, reasoning capabilities, and agentic workflows.
1. Next.js 16: The Routing & Performance Overhaul
Next.js 16 (released May 2026) introduces a fundamental shift in how applications handle navigation and data prefetching [1].
Key Advancements
| Feature | Description | Impact for QCX |
|---|---|---|
| Routing Overhaul | Complete rewrite of the navigation system for leaner, faster transitions. | Faster map-to-chat transitions and smoother UI. |
| Layout Deduplication | Shared layouts are downloaded only once during prefetching across multiple URLs. | Reduced bandwidth and faster multi-page navigation. |
| Incremental Prefetching | Only fetches missing cache segments instead of entire pages. | Significant reduction in total transfer size for complex dashboards. |
| Stable Turbopack | Turbopack is now the default for both dev and build without experimental flags. |
Faster development cycles and optimized production builds. |
| React 19.2 Support | Native support for View Transitions, useEffectEvent, and Activity. |
Enhanced animation capabilities for the geospatial UI. |
| React Compiler | Automatic memoization of components for performance gains. | Eliminates manual useMemo/useCallback overhead in complex components. |
Upgrade Recommendations for QCX
- Migrate to Next.js 16: Update
package.jsontonext@16.x. - Leverage Cache Components: Replace
experimental.dynamicIOwith the newcacheComponentsconfiguration for granular server-side caching. - Adopt React Compiler: Enable the React Compiler to automatically optimize the heavy geospatial UI components.
- Rename Middleware: Rename
middleware.tstoproxy.tsto align with the new Node.js runtime standards in v16.
2. Gemini 3.1 Pro: Reasoning & Agentic Excellence
Gemini 3.1 Pro (released February 2026) is a reasoning-optimized upgrade that excels in complex, multi-step task execution [2].
Key Advancements
| Capability | Gemini 3.1 Pro Performance | Strategic Advantage |
|---|---|---|
| Abstract Reasoning | 77.1% on ARC-AGI-2 (leads all models) [2]. | Superior handling of complex geospatial logic and land classification. |
| Agentic Workflows | 33.5% on APEX-Agents (nearly 2x Gemini 3 Pro) [2]. | Highly reliable multi-step tool use for the researcher and taskManager. |
| Custom Tools Endpoint | New gemini-3.1-pro-preview-customtools endpoint. |
Optimized specifically for bash, terminal, and custom API tool calls. |
| Expert Science | 94.3% on GPQA Diamond [2]. | Enhanced accuracy for technical geospatial and environmental analysis. |
| Context Caching | Native support for long-context caching. | Drastically reduces costs for long-running chat sessions with large histories. |
Integration Recommendations for QCX
- Switch to Custom Tools Endpoint: For the
researcheragent, use thegemini-3.1-pro-preview-customtoolsendpoint to improve tool-calling reliability. - Implement Context Caching: Use context caching for the
resolutionSearchagent when analyzing large satellite imagery datasets or long conversation histories. - Reasoning-First Prompts: Update system prompts to leverage the improved chain-of-thought reasoning for complex land feature predictions.
- Batch API Usage: Utilize the new Batch API for non-real-time geospatial analysis to reduce costs by up to 50%.
3. QCX Platform: Strategic Update Roadmap
Phase 1: Core Infrastructure (Immediate)
- Upgrade to Next.js 16.2+: Gain the routing overhaul and stable Turbopack benefits.
- Update React to 19.2: Enable View Transitions for the map interface.
- Enable React Compiler: Optimize the
CopilotandSearchRelatedcomponents automatically.
Phase 2: AI Intelligence (Short-term)
- Transition to
customtoolsEndpoint: Improve the reliability of thegeospatialQueryTool. - Implement Context Caching: Optimize token usage for the
researcheragent. - Refine Reasoning Prompts: Update the
resolutionSearchsystem prompt to utilize the 77.1% ARC-AGI-2 reasoning capabilities.
Phase 3: Performance & UX (Mid-term)
- Adopt Incremental Prefetching: Optimize the loading of the search results page.
- Implement View Transitions: Create seamless transitions between the map view and the chat panel.
- Leverage Build Adapters: Optimize the standalone Docker build process for faster deployments.
Conclusion
The combination of Next.js 16's routing efficiency and Gemini 3.1 Pro's reasoning power provides a significant competitive advantage for the QCX platform. By following this roadmap, the platform will achieve superior UI responsiveness and industry-leading AI analysis accuracy.
References
[1] Upgrading: Version 16 | Next.js
[2] Gemini 3.1 Pro: #1 Reasoning AI Benchmarks & API Guide | Google DeepMind
Activity
ngoiyaeric commentedon May 6, 2026
@coderabbitai plan
coderabbitai commentedon May 6, 2026
Coding Plan
Summary
middleware.tstoproxy.tsper v16 conventionsgetModel()function with ausesToolsparameter to route the researcher agent to thegemini-3.1-pro-preview-customtoolsendpoint while other agents use the standard endpointDesign Choices
Design Choice 1: Context Caching Implementation Approach
Options Considered:
@google/generative-aiSDK directly for context caching, bypassing the Vercel AI SDK for cached callsChosen Option: 2
Rationale: Application-level caching is more consistent with the existing Vercel AI SDK architecture and avoids maintaining two parallel SDK integrations for the same provider.
Design Choice 2: Customtools Endpoint Scope
Options Considered:
getModel()with an optional parameter to indicate tool usageChosen Option: 2
Rationale: Extending
getModel()with ausesToolsparameter maintains the single source of truth for model selection and follows the existing pattern of parameterized model retrieval.💡 User Tips
Regenerate the plan with different choices with
@coderabbitai <feedback>.Implementation Steps
Phase 1: Core Framework Upgrade
This phase upgrades the application to Next.js 16 with React 19.2, enables React Compiler for automatic component optimization, and aligns the middleware with v16 conventions.
Task 1: Update Package Dependencies
Update all core framework packages to their Next.js 16 compatible versions.
package.jsonto setnextto^16.2.0andreact/react-domto^19.2.0eslint-config-nextfrom^14.2.28to^16.xto match the Next.js version@types/reactand@types/react-domto versions compatible with React 19.2Task 2: Update Next.js Configuration for v16
Modify the Next.js configuration to adopt v16 features and conventions.
next.config.mjsto remove the--turboCLI flag dependency since Turbopack is now stable and default in v16cacheComponentsconfiguration if granular server-side caching is desired (replaces the experimental.dynamicIO pattern)output: 'standalone'remains compatible with v16 build adaptersserverActionsconfiguration to the v16 format if changedTask 3: Rename Middleware to Proxy
Align with Next.js 16's Node.js runtime standards by renaming the middleware file.
middleware.tstoproxy.tsat the project rootnext-actionheader check) continues to function correctly/settingsroute protection logic (currently a placeholder) works under the new proxy patternTask 4: Enable React Compiler
Enable automatic memoization to optimize heavy UI components without manual intervention.
next.config.mjsto addexperimental: { reactCompiler: true }(or the v16 stable path if it has moved out of experimental)babel-plugin-react-compilerif required by the v16 React Compiler integrationcomponents/copilot.tsxandcomponents/search-related.tsxcan remain—the compiler will handle optimization regardlesscomponents/resolution-carousel.tsxwill now be automatically optimized🤖 Prompt for AI agents
Phase 2: Gemini AI Intelligence Enhancements
This phase improves the Gemini 3.1 Pro integration by switching to the optimized customtools endpoint for tool-calling agents, implementing context caching for token efficiency, and updating system prompts to leverage enhanced reasoning.
Task 1: Update Model Selection for Customtools Endpoint
Modify the model selection logic to use the specialized customtools endpoint when tools are involved.
getModel()inlib/utils/index.tsto accept an optionalusesTools?: booleanparameterusesToolsis true and Gemini is the selected/detected provider, returngemini-3.1-pro-preview-customtoolsinstead ofgemini-3.1-pro-previewlib/agents/researcher.tsxto passusesTools: truesince it's the only agent with tool accessTask 2: Implement Context Caching Utilities
Create a caching layer to reduce token usage for long conversation histories.
lib/utils/(e.g.,context-cache.ts) to manage conversation context cachingTask 3: Update Researcher Agent Prompts for Reasoning
Refine the researcher system prompt to leverage Gemini 3.1 Pro's improved chain-of-thought reasoning.
lib/agents/researcher.tsxto include explicit reasoning directivesTask 4: Update Resolution Search Agent for Enhanced Analysis
Update the satellite image analysis agent to utilize improved reasoning for land classification.
lib/agents/resolution-search.tsxto emphasize structured reasoning for land feature classificationTask 5: Update Documentation
Update project documentation to reflect the new versions and configuration.
GEMINI_3.1_PRO_INTEGRATION.mdto document the customtools endpoint usage and when it applies🤖 Prompt for AI agents
Research
The QCX platform is a Next.js 15.3.8 application with React 19.1.2, using the Vercel AI SDK to orchestrate multiple AI agents (researcher, taskManager, inquire, writer, resolutionSearch, querySuggestor). The central model selection logic lives in
lib/utils/index.tsviagetModel(), which supports Gemini, Grok, Bedrock, and OpenAI with fallback priority. Tools are defined inlib/agents/tools/and injected only into the researcher agent. Heavy UI components likecopilot.tsxandsearch-related.tsxuse extensive manual memoization (5+ useCallback/useMemo hooks), whileresolution-carousel.tsxhas none. The currentmiddleware.tsis a stub with hardcoded authentication. Theeslint-config-nextpackage is outdated at v14.x.🚀 Next Steps
🤖 All AI agent prompts combined
💡 Iterate on the plan with:
@coderabbitai <feedback>💬 Have feedback or questions? Drop into our discord!