System Prompts
Relevant source files
The following files were used as context for generating this wiki page:
System Prompts define the persona, domain expertise, and operational constraints of the LV.AI assistant. The system configures these prompts to ensure the AI acts as an expert for AVA (Ausschreibung, Vergabe, Abrechnung) within the D/A/CH region (Germany, Austria, Switzerland).
The prompting engine generates instructions that govern how the model handles construction industry standards like GAEB, VOB, and DIN. It also defines the rules for interacting with the UI through artifacts like spreadsheets and text documents.
Sources: lib/ai/prompts.ts:11-30, CLAUDE.md:6-12
Core Persona and Expertise
The regularPrompt serves as the foundation for the AI's identity. It establishes LV.AI as a specialist in construction bidding and billing.
Technical Expertise Areas
The system prompt enforces knowledge in specific regulatory and technical frameworks:
- Data Formats: GAEB DA XML (X81–X86).
- Legal Frameworks: VOB/A (DE), ÖNORM B2110 (AT), and SIA 118 (CH).
- Calculations: Cost estimation according to DIN 276.
- E-Invoicing: XRechnung and ZUGFeRD standards.
- Trade Classification: DIN 18299 sections for Earthworks, Roofing, and MEP (SHK).
Sources: lib/ai/prompts.ts:15-28, lib/ai/prompts.test.ts:24-42
Language and Formatting
The system mandates the use of German for all conversational outputs. It requires specific fields for Bill of Quantities (LV) positions, including:
- OZ (Ordnungszahl/Item number)
- Kurztext (Short description)
- Langtext (Long description)
- Mengeneinheit (Unit of measurement)
- Menge (Quantity)
- EP (Unit price)
Sources: lib/ai/prompts.ts:30-35, lib/ai/prompts.test.ts:44-58
Prompt Modularization and Caching
The system employs a modular architecture to optimize performance and reduce token costs. The systemPromptParts function divides the prompt into stable and dynamic components.
The diagram shows the logic used to separate cacheable instructions from request-specific metadata.
Sources: lib/ai/prompts.ts:98-124
Components of the System Message
| Component | Content Type | Caching Behavior |
|---|---|---|
| Stable Content | Persona, domain expertise, and artifact interaction rules. | High (Cacheable across sessions). |
| Dynamic Content | User geo-location (Lat/Lon/City) and specific project context. | None (Unique per request). |
Sources: lib/ai/prompts.ts:108-123, CLAUDE.md:62-65
Artifact Interaction Rules
The artifactsPrompt defines strict operational rules for managing the side panel content. These rules prevent the AI from overwhelming the chat interface while ensuring accurate document manipulation.
- Tool Limitation: The AI must only call one tool per response and stop immediately after.
- Output Suppression: The AI must never output the full content of an artifact in the chat window; a 1-2 sentence confirmation is required.
- Type Selection: It mandates
kind: 'sheet'for tables with positions andkind: 'text'for reports. - Modification Logic: It prioritizes
editDocumentfor targeted changes using find-and-replace, whileupdateDocumentis reserved for full rewrites.
Sources: lib/ai/prompts.ts:39-71, lib/ai/tools/create-document.ts:19-25
Specialized Sub-Prompts
The system utilizes specialized prompts for specific tools and artifact types to maintain technical accuracy.
Spreadsheet Generation (sheetPrompt)
This prompt guides the sheetDocumentHandler to create raw CSV data. It enforces GAEB-compliant headers and German decimal notation (using commas).
Sources: lib/ai/prompts.ts:139-148, artifacts/sheet/server.ts:12-16
Writing Suggestions
The requestSuggestions tool uses a dedicated system message to act as a writing assistant. It restricts the model to offering up to 5 suggestions, each requiring the original sentence, the suggested improvement, and a description of the change.
Sources: lib/ai/tools/request-suggestions.ts:46-49
Chat Titling (titlePrompt)
The system generates chat titles using a specific format:
- Length: 2 to 5 words.
- Language: German.
- Format: Raw text without hashtags or quotes.
- Examples: "LV Rohbauarbeiten" or "Kostenschätzung DIN 276".
Sources: lib/ai/prompts.ts:169-182, lib/ai/prompts.test.ts:153-162
Configuration Summary
The configuration of system prompts is handled by the systemPrompt wrapper. It accepts parameters to toggle functionality based on the environment and current task.
// Example from lib/ai/prompts.ts:80-87
export const systemPrompt = ({
requestHints,
supportsTools,
projectContext,
}: {
requestHints: RequestHints;
supportsTools: boolean;
projectContext?: string;
}) => {
// Logic to assemble prompts based on context
}
The system ensures that the AI is aware of the user's location (latitude, longitude, city, country) through the getRequestPromptFromHints helper, allowing for regional regulatory adjustments.
Sources: lib/ai/prompts.ts:73-95, lib/ai/prompts.test.ts:98-112
LV.AI uses a highly structured prompting system to maintain its role as an AVA specialist. By separating static domain knowledge from dynamic project data, the system optimizes for both technical accuracy and operational performance.