Repository navigation
feat(ai): add GPT-5.2 models support - #181
Conversation
Add GPT-5.2 model family to PageSpace AI providers: - gpt-5.2, gpt-5.2-codex, gpt-5.2-mini (OpenAI direct) - openai/gpt-5.2, openai/gpt-5.2-codex, openai/gpt-5.2-mini (OpenRouter) Includes vision capabilities, pricing ($12/$48 per 1M tokens for full model), and context windows (500k tokens for full models, 256k for mini).
|
Warning Rate limit exceeded@2witstudios has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 42 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds GPT-5.2 family model keys across provider configs, marks GPT-5.2/GPT-5.1 aliases as vision-capable, and extends monitoring/pricing and context-window constants plus context-window selection logic for GPT-5.2 and GPT-5.1. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bcdc0d9e78
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 'openai/gpt-5.2': 500000, | ||
| 'openai/gpt-5.2-codex': 500000, | ||
| 'openai/gpt-5.2-mini': 256000, |
There was a problem hiding this comment.
Align gpt-5.2 context sizing with calculator
The new GPT‑5.2 context windows are declared here, but the runtime sizing logic used by getContextWindowSize in packages/lib/src/monitoring/ai-context-calculator.ts still treats all gpt-5* models as 272k (or 128k for mini/nano). When a user selects gpt-5.2 or gpt-5.2-mini, calculateTotalContextSize will therefore flag truncation and/or trim messages earlier than necessary even though the model supports 500k/256k. This mismatch will only appear for GPT‑5.2 models, and it was introduced by adding these IDs without updating the calculator.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/web/src/lib/ai/core/ai-providers-config.tsapps/web/src/lib/ai/core/model-capabilities.tspackages/lib/src/monitoring/ai-monitoring.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Never useanytypes - always use proper TypeScript types
Use camelCase for variable and function names
Use UPPER_SNAKE_CASE for constants
Use PascalCase for type and enum names
Use kebab-case for filenames, except React hooks (camelCase withuseprefix), Zustand stores (camelCase withuseprefix), and React components (PascalCase)
Lint with Next/ESLint as configured inapps/web/eslint.config.mjs
Message content should always use the message parts structure with{ parts: [{ type: 'text', text: '...' }] }
Use centralized permission functions from@pagespace/lib/permissions(e.g.,getUserAccessLevel,canUserEditPage) instead of implementing permission logic locally
Always use Drizzle client from@pagespace/dbpackage for database access
Use ESM modules throughout the codebase
**/*.{ts,tsx}: Never useanytypes - always use proper TypeScript types
Write code that is explicit over implicit and self-documenting
Files:
apps/web/src/lib/ai/core/model-capabilities.tspackages/lib/src/monitoring/ai-monitoring.tsapps/web/src/lib/ai/core/ai-providers-config.ts
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: React hook files should use camelCase matching the exported hook name (e.g.,useAuth.ts)
Zustand store files should use camelCase withuseprefix (e.g.,useAuthStore.ts)
Files:
apps/web/src/lib/ai/core/model-capabilities.tspackages/lib/src/monitoring/ai-monitoring.tsapps/web/src/lib/ai/core/ai-providers-config.ts
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Format code with Prettier
Files:
apps/web/src/lib/ai/core/model-capabilities.tspackages/lib/src/monitoring/ai-monitoring.tsapps/web/src/lib/ai/core/ai-providers-config.ts
apps/web/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
apps/web/src/**/*.{ts,tsx}: Use message parts structure for message content:{ parts: [{ type: 'text', text: '...' }] }
For database access, always use Drizzle client from@pagespace/db:import { db, pages } from '@pagespace/db';
Use centralized Drizzle ORM with PostgreSQL for all database operations - no direct SQL or other ORMs
Use Socket.IO for real-time collaboration features - imported from the realtime service at port 3001
Use Vercel AI SDK with async/await for all AI operations and streaming
Use Next.js 15 App Router and TypeScript for all routes and components
Files:
apps/web/src/lib/ai/core/model-capabilities.tsapps/web/src/lib/ai/core/ai-providers-config.ts
**/*ai*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Vercel AI SDK for AI integrations
Files:
packages/lib/src/monitoring/ai-monitoring.tsapps/web/src/lib/ai/core/ai-providers-config.ts
🧠 Learnings (2)
📚 Learning: 2025-12-14T14:54:45.713Z
Learnt from: CR
Repo: 2witstudios/PageSpace PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-14T14:54:45.713Z
Learning: When adding AI providers, follow the integration pattern documented in `docs/3.0-guides-and-tools/adding-ai-provider.md`
Applied to files:
apps/web/src/lib/ai/core/ai-providers-config.ts
📚 Learning: 2025-12-22T20:04:40.910Z
Learnt from: CR
Repo: 2witstudios/PageSpace PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-22T20:04:40.910Z
Learning: Applies to **/*ai*.{ts,tsx} : Use Vercel AI SDK for AI integrations
Applied to files:
apps/web/src/lib/ai/core/ai-providers-config.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Unit Tests
🔇 Additional comments (4)
apps/web/src/lib/ai/core/model-capabilities.ts (1)
15-21: LGTM! GPT-5.2 vision capability entries are correctly added.GPT-5.2 is a flagship-level reasoning model released in December 2025 by OpenAI with computer vision capabilities. The vision-capable entries for both direct OpenAI and OpenRouter-prefixed variants are appropriately included.
packages/lib/src/monitoring/ai-monitoring.ts (1)
198-200: Context window entries added correctly.The 500k token context for full models and 256k for mini variant matches the PR description and maintains consistency between OpenRouter and OpenAI Direct sections.
Also applies to: 274-276
apps/web/src/lib/ai/core/ai-providers-config.ts (2)
25-27: OpenRouter GPT-5.2 model entries added correctly.The entries follow the established pattern for OpenRouter models with the
openai/prefix and appropriate display names.
166-170: OpenAI direct GPT-5.2 model entries added correctly.The entries are well-organized with a section comment and follow the same pattern as the existing GPT-5.1 entries. All three variants (base, codex, mini) are consistently added across:
- Provider configuration (this file)
- Vision capabilities (
model-capabilities.ts)- Pricing and context windows (
ai-monitoring.ts)Based on learnings, this follows the documented integration pattern for adding AI providers.
- Fix ai-context-calculator.ts to properly detect GPT-5.2 models (500k for full models, 256k for mini) instead of falling through to generic GPT-5 logic (272k/128k) - Update pricing to official OpenAI rates: $1.75/$14.00 per 1M tokens for GPT-5.2/codex, $0.35/$2.80 for mini variant
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @packages/lib/src/monitoring/ai-context-calculator.ts:
- Around line 142-152: The GPT-5.2 branch currently returns 500_000 tokens but
the correct full-model context window is 400_000; change the return in the
modelLower.includes('gpt-5.2') block from 500_000 to 400_000, keep the mini
branch returning 256_000, and add a check for a 'nano' variant
(modelLower.includes('nano')) mirroring how GPT-5.0 is handled so the GPT-5.2
branch treats 'mini' and 'nano' consistently with the rest of the calculator
logic.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/lib/src/monitoring/ai-context-calculator.tspackages/lib/src/monitoring/ai-monitoring.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/lib/src/monitoring/ai-monitoring.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Never useanytypes - always use proper TypeScript types
Use camelCase for variable and function names
Use UPPER_SNAKE_CASE for constants
Use PascalCase for type and enum names
Use kebab-case for filenames, except React hooks (camelCase withuseprefix), Zustand stores (camelCase withuseprefix), and React components (PascalCase)
Lint with Next/ESLint as configured inapps/web/eslint.config.mjs
Message content should always use the message parts structure with{ parts: [{ type: 'text', text: '...' }] }
Use centralized permission functions from@pagespace/lib/permissions(e.g.,getUserAccessLevel,canUserEditPage) instead of implementing permission logic locally
Always use Drizzle client from@pagespace/dbpackage for database access
Use ESM modules throughout the codebase
**/*.{ts,tsx}: Never useanytypes - always use proper TypeScript types
Write code that is explicit over implicit and self-documenting
Files:
packages/lib/src/monitoring/ai-context-calculator.ts
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: React hook files should use camelCase matching the exported hook name (e.g.,useAuth.ts)
Zustand store files should use camelCase withuseprefix (e.g.,useAuthStore.ts)
Files:
packages/lib/src/monitoring/ai-context-calculator.ts
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Format code with Prettier
Files:
packages/lib/src/monitoring/ai-context-calculator.ts
**/*ai*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Vercel AI SDK for AI integrations
Files:
packages/lib/src/monitoring/ai-context-calculator.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Unit Tests
- Update full GPT-5.2 models from 500k to 400k context window - Add nano variant handling to GPT-5.2 branch for consistency - Update MODEL_CONTEXT_WINDOWS in ai-monitoring.ts to match
Add gpt-5.2-nano model to all configuration files: - ai-providers-config.ts: model list - model-capabilities.ts: vision support - ai-monitoring.ts: pricing ($0.07/$0.56) and context window (256k)
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @apps/web/src/lib/ai/core/ai-providers-config.ts:
- Around line 25-27: The OpenRouter paid models mapping is missing the
'openai/gpt-5.2-nano' entry; add a key/value pair for 'openai/gpt-5.2-nano'
(label it e.g. 'GPT-5.2 Nano') alongside the existing 'openai/gpt-5.2',
'openai/gpt-5.2-codex', and 'openai/gpt-5.2-mini' entries in the same exported
models object in ai-providers-config.ts so the OpenRouter list matches the
direct OpenAI models and VISION_CAPABLE_MODELS references.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/web/src/lib/ai/core/ai-providers-config.tsapps/web/src/lib/ai/core/model-capabilities.tspackages/lib/src/monitoring/ai-context-calculator.tspackages/lib/src/monitoring/ai-monitoring.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Never useanytypes - always use proper TypeScript types
Use camelCase for variable and function names
Use UPPER_SNAKE_CASE for constants
Use PascalCase for type and enum names
Use kebab-case for filenames, except React hooks (camelCase withuseprefix), Zustand stores (camelCase withuseprefix), and React components (PascalCase)
Lint with Next/ESLint as configured inapps/web/eslint.config.mjs
Message content should always use the message parts structure with{ parts: [{ type: 'text', text: '...' }] }
Use centralized permission functions from@pagespace/lib/permissions(e.g.,getUserAccessLevel,canUserEditPage) instead of implementing permission logic locally
Always use Drizzle client from@pagespace/dbpackage for database access
Use ESM modules throughout the codebase
**/*.{ts,tsx}: Never useanytypes - always use proper TypeScript types
Write code that is explicit over implicit and self-documenting
Files:
packages/lib/src/monitoring/ai-context-calculator.tsapps/web/src/lib/ai/core/model-capabilities.tsapps/web/src/lib/ai/core/ai-providers-config.tspackages/lib/src/monitoring/ai-monitoring.ts
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: React hook files should use camelCase matching the exported hook name (e.g.,useAuth.ts)
Zustand store files should use camelCase withuseprefix (e.g.,useAuthStore.ts)
Files:
packages/lib/src/monitoring/ai-context-calculator.tsapps/web/src/lib/ai/core/model-capabilities.tsapps/web/src/lib/ai/core/ai-providers-config.tspackages/lib/src/monitoring/ai-monitoring.ts
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Format code with Prettier
Files:
packages/lib/src/monitoring/ai-context-calculator.tsapps/web/src/lib/ai/core/model-capabilities.tsapps/web/src/lib/ai/core/ai-providers-config.tspackages/lib/src/monitoring/ai-monitoring.ts
**/*ai*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Vercel AI SDK for AI integrations
Files:
packages/lib/src/monitoring/ai-context-calculator.tsapps/web/src/lib/ai/core/ai-providers-config.tspackages/lib/src/monitoring/ai-monitoring.ts
apps/web/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
apps/web/src/**/*.{ts,tsx}: Use message parts structure for message content:{ parts: [{ type: 'text', text: '...' }] }
For database access, always use Drizzle client from@pagespace/db:import { db, pages } from '@pagespace/db';
Use centralized Drizzle ORM with PostgreSQL for all database operations - no direct SQL or other ORMs
Use Socket.IO for real-time collaboration features - imported from the realtime service at port 3001
Use Vercel AI SDK with async/await for all AI operations and streaming
Use Next.js 15 App Router and TypeScript for all routes and components
Files:
apps/web/src/lib/ai/core/model-capabilities.tsapps/web/src/lib/ai/core/ai-providers-config.ts
🧠 Learnings (2)
📚 Learning: 2025-12-14T14:54:45.713Z
Learnt from: CR
Repo: 2witstudios/PageSpace PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-14T14:54:45.713Z
Learning: When adding AI providers, follow the integration pattern documented in `docs/3.0-guides-and-tools/adding-ai-provider.md`
Applied to files:
apps/web/src/lib/ai/core/ai-providers-config.ts
📚 Learning: 2025-12-22T20:04:40.910Z
Learnt from: CR
Repo: 2witstudios/PageSpace PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-22T20:04:40.910Z
Learning: Applies to **/*ai*.{ts,tsx} : Use Vercel AI SDK for AI integrations
Applied to files:
packages/lib/src/monitoring/ai-monitoring.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Lint & TypeScript Check
- GitHub Check: Unit Tests
🔇 Additional comments (7)
packages/lib/src/monitoring/ai-monitoring.ts (4)
24-27: LGTM! GPT-5.2 OpenRouter pricing entries are complete and consistent.All four GPT-5.2 variants (base, codex, mini, nano) are added with appropriate pricing tiers.
97-101: LGTM! OpenAI Direct pricing entries mirror OpenRouter entries correctly.The pricing values are consistent across both provider sections, ensuring accurate cost calculations regardless of the access path.
200-203: LGTM! Context window sizes align with PR specifications.The 400k tokens for full models and 256k for mini/nano variants are correctly applied to OpenRouter entries.
277-280: LGTM! OpenAI Direct context windows match OpenRouter entries.Context window consistency is maintained across both provider sections.
packages/lib/src/monitoring/ai-context-calculator.ts (1)
142-152: LGTM! Context window logic correctly handles GPT-5.2 and GPT-5.1 model families.The ordering is correct—checking
gpt-5.2andgpt-5.1before the genericgpt-5branch ensures proper matching. The mini/nano distinction for GPT-5.2 (256k vs 400k) aligns with theMODEL_CONTEXT_WINDOWSconstants.apps/web/src/lib/ai/core/model-capabilities.ts (1)
15-30: LGTM! Vision capability entries are comprehensive for GPT-5.2 and GPT-5.1 families.All variants are explicitly registered with both direct model IDs and
openai/prefixed versions. The fallback logic at line 122 (gpt-5pattern) provides additional coverage for any variants not explicitly listed.apps/web/src/lib/ai/core/ai-providers-config.ts (1)
166-170: LGTM! OpenAI direct model entries are complete.All four GPT-5.2 variants (base, codex, mini, nano) are properly registered with appropriate display names.
Add GPT-5.2 model family to PageSpace AI providers:
Includes vision capabilities, pricing ($12/$48 per 1M tokens for full model), and context windows (500k tokens for full models, 256k for mini).
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.