Customizing Ask AI chat with a semantic layer
The Ask AI chat agent can be customized to understand your specific business logic, data structures, and domain knowledge through AGENTS.md—a special saved query that acts as a semantic layer over the agent's system prompt.
By creating an AGENTS.md file, you can provide custom instructions that are injected at the start of every conversation to guide SQL query generation and data analysis based on your organization's unique requirements, calculations, and conventions.
How it works
When you save a query named "AGENTS.md" (case-sensitive) in the Cloud Console:
- The Ask AI chat agent automatically loads this file when a message is sent
- The content is placed within a structured content tag and injected into the agent's system prompt
- The instructions are applied to all Ask AI chat conversations in that service
Creating AGENTS.md
Create the saved query
- In the Cloud Console, create a new query
- Name it exactly: "AGENTS.md" (case-sensitive)
- Write your custom instructions in the query text editor (not actual SQL)
- Save the query
Add your instructions
Structure your instructions using clear, actionable language. Include:
- Business rules and calculations
- Data structure guidance
- Domain-specific terminology
- Common query patterns
- Performance optimization rules
Best practices
Treat context as a finite resource
Context is precious—every token depletes the agent's "attention budget." Like humans with limited working memory, language models experience performance degradation as context grows. This means finding the smallest possible set of high-signal tokens that maximize the likelihood of your desired outcome.
Find the right altitude
Strike a balance between two extremes:
- Too specific: Hardcoding brittle if-else logic that creates fragility and maintenance complexity
- Too vague: High-level guidance that fails to give concrete signals or falsely assumes shared context
The optimal altitude is specific enough to guide behavior effectively, yet flexible enough for the model to apply strong heuristics. Start with a minimal prompt on the best model available, then add clear instructions based on observed failure modes.
Organize with structured sections
Use XML tags or Markdown headers to create distinct, scannable sections:
Provide diverse, canonical examples
Examples are the "pictures worth a thousand words." Rather than stuffing every edge case into your prompt, curate a focused set of diverse examples that effectively portray expected behavior.
Keep it minimal yet complete
- Include only frequently-needed instructions
- Be concise—larger context degrades performance due to "context rot"
- Remove outdated or rarely-used rules
- Ensure sufficient information to guide desired behavior
Minimal doesn't necessarily mean short. You need enough detail to ensure the agent adheres to expected behavior, just avoid unnecessary verbosity.
Example: Calculated Metrics from raw data
Guide the agent when metrics require specific calculations rather than direct column access:
Example: Business logic rules
Define domain-specific calculations and categorizations:
Example: Data structure quirks
Document unconventional data formats or legacy schema decisions:
Example: domain terminology
Map business terms to technical implementation: