Open PortfolioOpen Portfolio.
โ† Back to Blog

Prompt Grounding โ€” Layers in app/api/ai/chat/route.ts

May 15, 2026By Pocket Portfoliotechnical
Prompt Grounding โ€” Layers in app/api/ai/chat/route.ts
#prompting#ai#gemini

Sovereign Engineering ยท Part 6

Stacked system string:

const contextBlock = context
  ? `\n\nPortfolio context:\n${context}`
  : '\n\n(No portfolio context provided.)';
const attachedBlock = attachedContent
  ? `\n\nFile the user included (use this):\n${attachedContent}`
  : '';
const systemPrompt = SYSTEM_PROMPT + contextBlock + quoteBlock + attachedBlock;

Quotes: extractSymbolHints(message) โ†’ internal /api/quote. Attachments: paid path, 60k server cap.


Read the Sovereign Intelligence book or try Pocket Portfolio.

Prompt Grounding โ€” Layers in app/api/ai/chat/route.ts | Open Portfolio Blog | Open Portfolio