Skip to content

Feat: Prompt optimizations and Gemini 3 flash#274

Merged
AshishKumar4 merged 9 commits intonightlyfrom
feat/prompt-optimizations
Dec 18, 2025
Merged

Feat: Prompt optimizations and Gemini 3 flash#274
AshishKumar4 merged 9 commits intonightlyfrom
feat/prompt-optimizations

Conversation

@AshishKumar4
Copy link
Collaborator

@AshishKumar4 AshishKumar4 commented Dec 18, 2025

Summary

Introduces Gemini 3 Flash Preview model support for multiple AI operations and significantly refactors the phase implementation prompts for improved maintainability and reduced token usage. Also adds a safety gate enhancement to detect module-level JSX anti-patterns.

Changes

Model Configuration Updates

  • Add new GEMINI_3_FLASH_PREVIEW model (1M context, $0.5 credit cost)
  • Migrate multiple operations from Gemini 2.5 Pro/Grok to Gemini 3 Flash Preview:
    • Phase generation, first phase implementation, phase implementation
    • Deep debugger, agentic project builder
  • Move templateSelection config to shared COMMON_AGENT_CONFIGS

Prompt Optimizations

  • Extract phase implementation prompts to dedicated module (phaseImplementationPrompts.ts)
  • Reduce system prompt verbosity while maintaining key guidelines (UX rubric, reliability rules, Zustand patterns)
  • Add clearer changes field format guidance in phase generation with DO/DON'T examples
  • Remove ~400 lines of redundant prompt content

Safety & Bug Fixes

  • Add module-level JSX detection to pre-deploy safety gate (prevents memory leaks and render issues)
  • Fix preview switching logic to correctly handle phasic vs agentic behavior types
  • Change default phaseNumber from 1 to 0

Motivation

  • Cost reduction: Gemini 3 Flash Preview offers competitive performance at lower cost
  • Token efficiency: Condensed prompts reduce context usage without sacrificing quality
  • Code maintainability: Extracted prompts are easier to maintain and test
  • Bug prevention: Module-level JSX detection catches common anti-patterns early

Testing

  • Verify phase generation produces valid phase descriptions
  • Test phasic code generation with the new condensed prompts
  • Confirm preview switching works correctly for both phasic and agentic modes
  • Check that module-level JSX patterns are detected by the safety gate

Breaking Changes

None - this is a backward-compatible change to model selection and internal prompt structure.

Related Issues

None identified

- Clarify `changes` field format in PhaseGeneration with concrete examples showing WHAT/HOW/CONSTRAINTS without code syntax
- Streamline REACT_RENDER_LOOP_PREVENTION prompt from verbose warnings to concise validation checklist
- Add explicit Zustand selector patterns (allowed vs banned) with clear anti-patterns
- Simplify state update rules focusing on event handlers vs render phase violations
- Remove redundant formatting
- Reduce MAX_PHASES from 12 to 10 for tighter project scope
- Show only last phase with full file details, redact older phases to save context
- Add codebaseContext utility to filter out readme.md and .bootstrap.js from file serialization
- Simplify completion criteria: remove verbose quality assurance points, emphasize timeline adherence
- Clarify feature implementation scope: stick to blueprint roadmap, conclude at final phase
- Remove config
- Adjust temperature settings for platform agents (gemini-3-flash: 1→0.7, fileRegeneration: 0.2→0.0)
- Switch deepDebugger from gemini-3-flash to grok-4-1-fast for platform config
- Update default agent fallback models for better reliability
- Replace gemini-3-flash with gemini-2-5-pro for agenticProjectBuilder in default config
- Clarify phase completion criteria: conclude when blueprint roadmap is complete, not for polish/
@AshishKumar4 AshishKumar4 force-pushed the feat/prompt-optimizations branch from 171450c to 69c8642 Compare December 18, 2025 03:06
@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2025

Claude finished @AshishKumar4's task in 2m 3s —— View job


Code Quality & Security Review

Recommendation: APPROVE

PR Summary

This PR introduces Gemini 3 Flash Preview model support, significantly refactors phase implementation prompts for reduced token usage (~400 lines removed), and adds a safety gate enhancement to detect module-level JSX anti-patterns.

PR Description

  • Updated: No - The description is already comprehensive with clear sections for Summary, Changes, Motivation, Testing, and Breaking Changes.
  • Notes: Well-documented PR with appropriate categorization of changes.

Addressed Issues

  • None identified (PR description confirms this)

Code Quality

Critical: None found

High: None found

Medium:

  1. worker/agents/utils/codebaseContext.ts:5 - Parameter reassignment pattern
    allFiles = allFiles.filter(file => {
    While this works (filter creates a new array), it's clearer to use a new variable name to avoid confusion about whether the original is mutated. Consider:
    const relevantFiles = allFiles.filter(file => { ... });
    return relevantFiles;

Low:

  1. worker/agents/utils/codebaseContext.ts:10-18 - Contains commented-out code for redacting config files. This should either be removed or converted to a proper TODO/documentation comment explaining why it's preserved.

Security

Critical: None found
High: None found
Medium: None found
Low: None found

The changes are internal configuration updates and prompt optimizations with no security implications.


Code Review Highlights

Positive Changes:

  1. Prompt Extraction (phaseImplementationPrompts.ts) - Well-structured separation of concerns. The new module cleanly exports system prompt and user prompt builder functions.

  2. Preview Switching Logic Fix (chat.tsx:485-488) - The new logic is more explicit and correctly handles the edge case where phasic mode should only switch on phase 1 completion:

    const shouldSwitch =
        behaviorType === 'agentic' ||
        (behaviorType === 'phasic' && isPhase1Complete) ||
        (isExistingChat && behaviorType !== 'phasic');
  3. Module-Level JSX Detection (preDeploySafetyGate.ts:138-146) - Good safety enhancement with clear error messaging. Correctly uses function depth tracking to only flag JSX at module level.

  4. Phase Generation Guidance (PhaseGeneration.ts:137-147) - The DO/DON'T examples for the changes field format are helpful for guiding LLM behavior.

  5. Import Path Fix (PhaseImplementation.ts:12) - Changed from 'worker/utils/images' to '../../utils/images' - relative imports are more maintainable.

Notable Configuration Changes:

Setting Old Value New Value
MAX_PHASES 12 10
phaseNumber default 1 0
phaseGeneration model GROK_4_1_FAST GEMINI_3_FLASH_PREVIEW
phaseImplementation model GEMINI_2_5_PRO GEMINI_3_FLASH_PREVIEW
deepDebugger model (default) GEMINI_2_5_PRO GEMINI_3_PRO_PREVIEW

Testing Recommendations

  1. Verify phase numbering - The default phaseNumber change from 1 to 0 should be tested to ensure no UI displays or logic expects 1-indexed phases
  2. Test preview switching - Verify both phasic and agentic modes correctly switch to preview view
  3. Module-level JSX detection - Test that the safety gate correctly catches patterns like const icon = <Icon /> at module level
  4. Model migration - Verify code generation quality with the new Gemini 3 Flash Preview model

Final Recommendation

Approve - This is a well-structured PR with meaningful improvements to maintainability (prompt extraction), cost efficiency (model migration), and safety (JSX detection). The code changes are clean and follow existing patterns. The minor issues noted (commented code, parameter reassignment) are low-impact and don't block approval.

@AshishKumar4 AshishKumar4 merged commit 54ff07f into nightly Dec 18, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant