-
-
Notifications
You must be signed in to change notification settings - Fork 6
Upgrade to Next.js 16 and Gemini 3.1 Pro Enhancements #593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # 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 | ||
| 1. **Migrate to Next.js 16**: Update `package.json` to `next@16.x`. | ||
| 2. **Leverage Cache Components**: Replace `experimental.dynamicIO` with the new `cacheComponents` configuration for granular server-side caching. | ||
| 3. **Adopt React Compiler**: Enable the React Compiler to automatically optimize the heavy geospatial UI components. | ||
| 4. **Rename Middleware**: Rename `middleware.ts` to `proxy.ts` to 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 | ||
| 1. **Switch to Custom Tools Endpoint**: For the `researcher` agent, use the `gemini-3.1-pro-preview-customtools` endpoint to improve tool-calling reliability. | ||
| 2. **Implement Context Caching**: Use context caching for the `resolutionSearch` agent when analyzing large satellite imagery datasets or long conversation histories. | ||
| 3. **Reasoning-First Prompts**: Update system prompts to leverage the improved chain-of-thought reasoning for complex land feature predictions. | ||
| 4. **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 `Copilot` and `SearchRelated` components automatically. | ||
|
|
||
| ### Phase 2: AI Intelligence (Short-term) | ||
| * **Transition to `customtools` Endpoint**: Improve the reliability of the `geospatialQueryTool`. | ||
| * **Implement Context Caching**: Optimize token usage for the `researcher` agent. | ||
| * **Refine Reasoning Prompts**: Update the `resolutionSearch` system 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](https://nextjs.org/docs/app/guides/upgrading/version-16) | ||
| [2] [Gemini 3.1 Pro: #1 Reasoning AI Benchmarks & API Guide | Google DeepMind](https://vertu.com/ai-tools/gemini-3-1-pro-benchmarks-api-specs-developer-guide-in-2026/) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,10 +18,17 @@ import { DrawnFeature } from './resolution-search' | |||||||||||||||||||||||||
| const raw = String.raw | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const getDefaultSystemPrompt = (date: string, drawnFeatures?: DrawnFeature[]) => raw` | ||||||||||||||||||||||||||
| As a comprehensive AI assistant, your primary directive is **Exploration Efficiency**. You must use the provided tools judiciously to gather information and formulate a response. | ||||||||||||||||||||||||||
| As a comprehensive AI assistant, your primary directive is **Exploration Efficiency with Enhanced Reasoning**. You must use the provided tools judiciously to gather information and formulate a response. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Current date and time: ${date}. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **Reasoning Approach (Gemini 3.1 Pro Enhanced):** | ||||||||||||||||||||||||||
| Before using any tool, break down complex queries into logical steps: | ||||||||||||||||||||||||||
| 1. Understand the user's intent and constraints | ||||||||||||||||||||||||||
| 2. Identify which tool(s) can best address each part | ||||||||||||||||||||||||||
| 3. Explain your reasoning when selecting between multiple tools | ||||||||||||||||||||||||||
| 4. Execute tools in the optimal order | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Comment on lines
+25
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same model-identity coupling as in Line 25's 🛠️ Proposed fix-**Reasoning Approach (Gemini 3.1 Pro Enhanced):**
+**Reasoning Approach:**📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| ${drawnFeatures && drawnFeatures.length > 0 ? `The user has drawn the following features on the map for your reference: | ||||||||||||||||||||||||||
| ${drawnFeatures.map(f => `- ${f.type} with measurement ${f.measurement}`).join('\n')} | ||||||||||||||||||||||||||
| Use these user-drawn areas/lines as primary areas of interest for your analysis if applicable to the query.` : ''} | ||||||||||||||||||||||||||
|
|
@@ -77,6 +84,12 @@ These rules override all previous instructions. | |||||||||||||||||||||||||
| **Pre-configured Responses:** | ||||||||||||||||||||||||||
| - "What is a planet computer?" → "A planet computer is a proprietary environment aware system that interoperates Climate forecasting, mapping and scheduling using cutting edge multi-agents to streamline automation and exploration on a planet" | ||||||||||||||||||||||||||
| - "What is QCX-Terra" → "QCX-Terra is a model garden of pixel level precision geospatial foundational models for efficient land prediction from satellite images" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **Tool Reasoning Enhancement:** | ||||||||||||||||||||||||||
| When selecting tools, consider: | ||||||||||||||||||||||||||
| - Geospatial queries benefit from multi-step reasoning before tool invocation | ||||||||||||||||||||||||||
| - Complex searches may require breaking down into multiple search queries | ||||||||||||||||||||||||||
| - Always explain your tool selection rationale to the user when appropriate | ||||||||||||||||||||||||||
| ` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export async function researcher( | ||||||||||||||||||||||||||
|
|
@@ -111,7 +124,7 @@ export async function researcher( | |||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const result = await nonexperimental_streamText({ | ||||||||||||||||||||||||||
| model: (await getModel(hasImage)) as LanguageModel, | ||||||||||||||||||||||||||
| model: (await getModel(hasImage, true)) as LanguageModel, | ||||||||||||||||||||||||||
| maxTokens: 4096, | ||||||||||||||||||||||||||
| system: systemPromptToUse, | ||||||||||||||||||||||||||
| messages, | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| /** | ||
| * Context Caching Utility for Gemini 3.1 Pro | ||
| * Reduces token usage for long conversation histories by caching stable context | ||
| */ | ||
|
|
||
| import { CoreMessage } from 'ai'; | ||
|
|
||
| interface CachedContext { | ||
| conversationId: string; | ||
| messageCheckpoint: number; | ||
| cachedPrefix: string; | ||
| systemPrompt: string; | ||
| timestamp: number; | ||
| ttl: number; // Time to live in milliseconds | ||
| } | ||
|
|
||
| const contextCache = new Map<string, CachedContext>(); | ||
| const CACHE_TTL = 30 * 60 * 1000; // 30 minutes | ||
| const MAX_CACHE_SIZE = 100; | ||
|
|
||
| /** | ||
| * Generate a cache key based on conversation ID and message count | ||
| */ | ||
| function generateCacheKey(conversationId: string, messageCount: number): string { | ||
| return `${conversationId}:${messageCount}`; | ||
| } | ||
|
|
||
| /** | ||
| * Cache conversation context to reduce token usage | ||
| */ | ||
| export function cacheConversationContext( | ||
| conversationId: string, | ||
| messages: CoreMessage[], | ||
| systemPrompt: string | ||
| ): void { | ||
| const messageCheckpoint = messages.length; | ||
| const cacheKey = generateCacheKey(conversationId, messageCheckpoint); | ||
|
|
||
| // Create a serialized prefix of the conversation | ||
| const cachedPrefix = messages | ||
| .slice(0, Math.floor(messages.length * 0.8)) // Cache first 80% of messages | ||
| .map(m => `${m.role}: ${typeof m.content === 'string' ? m.content : '[complex content]'}`) | ||
| .join('\n'); | ||
|
|
||
| const cachedContext: CachedContext = { | ||
| conversationId, | ||
| messageCheckpoint, | ||
| cachedPrefix, | ||
| systemPrompt, | ||
| timestamp: Date.now(), | ||
| ttl: CACHE_TTL, | ||
| }; | ||
|
|
||
| contextCache.set(cacheKey, cachedContext); | ||
|
|
||
| // Cleanup old entries if cache exceeds max size | ||
| if (contextCache.size > MAX_CACHE_SIZE) { | ||
| const oldestKey = Array.from(contextCache.entries()) | ||
| .sort((a, b) => a[1].timestamp - b[1].timestamp)[0][0]; | ||
| contextCache.delete(oldestKey); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Retrieve cached context if available and not expired | ||
| */ | ||
| export function getCachedContext( | ||
| conversationId: string, | ||
| messageCount: number | ||
| ): CachedContext | null { | ||
| const cacheKey = generateCacheKey(conversationId, messageCount); | ||
| const cached = contextCache.get(cacheKey); | ||
|
|
||
| if (!cached) return null; | ||
|
|
||
| // Check if cache has expired | ||
| if (Date.now() - cached.timestamp > cached.ttl) { | ||
| contextCache.delete(cacheKey); | ||
| return null; | ||
| } | ||
|
|
||
| return cached; | ||
| } | ||
|
|
||
| /** | ||
| * Clear cache for a specific conversation | ||
| */ | ||
| export function clearConversationCache(conversationId: string): void { | ||
| const keysToDelete: string[] = []; | ||
| for (const [key] of contextCache.entries()) { | ||
| if (key.startsWith(conversationId)) { | ||
| keysToDelete.push(key); | ||
| } | ||
| } | ||
| keysToDelete.forEach(key => contextCache.delete(key)); | ||
| } | ||
|
Comment on lines
+88
to
+96
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🐛 Proposed fix- if (key.startsWith(conversationId)) {
+ if (key.startsWith(conversationId + ':')) {🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * Clear all cached contexts | ||
| */ | ||
| export function clearAllContextCache(): void { | ||
| contextCache.clear(); | ||
| } | ||
|
|
||
| /** | ||
| * Get cache statistics for monitoring | ||
| */ | ||
| export function getCacheStats() { | ||
| return { | ||
| size: contextCache.size, | ||
| maxSize: MAX_CACHE_SIZE, | ||
| ttl: CACHE_TTL, | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,16 @@ const nextConfig = { | |
| bodySizeLimit: '200mb', | ||
| }, | ||
| }, | ||
|
|
||
| // turbopack root at top level in v16 | ||
| turbopack: { | ||
| root: '.', | ||
| }, | ||
|
|
||
| // reactCompiler and cacheComponents moved to top level in v16 | ||
| reactCompiler: true, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
The This is a non-breaking improvement, but confirm the build time increase is acceptable in your CI pipeline. 🤖 Prompt for AI Agents |
||
| cacheComponents: true, | ||
|
|
||
| transpilePackages: ['QCX', 'mapbox_mcp'], // Added to transpile local packages | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reference [2] uses a non-authoritative source for benchmark claims.
vertu.comis a luxury smartphone brand, not an official Google or DeepMind publication. All benchmark figures cited in the Gemini 3.1 Pro table (ARC-AGI-2, APEX-Agents, GPQA Diamond) trace back to this single non-authoritative reference. Replace with the official Google DeepMind blog post or the Gemini API models documentation.🤖 Prompt for AI Agents