Defining your Agent logic

CARTO AI Agents adapt to your specific geospatial needs through two key configuration fields that define their logic and behavior. Effective Agent logic combines a focused use case with comprehensive Instructions.

Understanding agent logic components

  • Use Case: A concise mission statement defining your Agent's primary goal and target audience

  • Instructions: Detailed rules, tasks, and contextual knowledge that guide the Agent's behavior

When properly configured, these fields work together to ensure your Agent produces accurate, reliable, and actionable insights for both technical analysts and non-technical users.

Remember that your use case and instructions can override some of the default agent behaviors added by CARTO

Crafting the Use Case

The Use Case field contains your Agent's mission statement, a focused description of what the Agent achieves and who benefits from the results.

Best practices for the Use Case field

  • Keep it concise but complete (2-4 sentences).

  • Include three elements:

    • Target users and decision makers.

    • Specific analytical goal.

    • Business outcomes and measurable impact

Example:

Enable expansion managers to identify optimal store locations by analyzing demographic data, competitor presence, and foot traffic. The Agent should rank potential sites by revenue potential and provide market penetration maps for executive approval.

Writing Instructions

Instructions are your Agent's detailed playbook, the comprehensive guide that defines how it behaves, data definitions, and the analytical steps it follows. Write your Instructions in Markdown format for better structure and readability.

Instructions Sections

Your Instructions should include these key sections, each serving a specific purpose in guiding the Agent's behavior.

1. Context & Constraints

Define operating boundaries and limitations to keep your Agent focused and reliable.

2. Behavior

Define the Agent's communication style and output preferences.

3. Data definition

Describe the key datasets and fields using $ to reference fields from your connected sources.

4. Reasoning framework

Define how your Agent analyzes problems and makes decisions.

5. Tasks & flows

Describe operational capabilities.

Tasks are atomic, reusable actions:

Flows are multi-step sequences where each step depends on the previous:

6. Handling specific scenarios

Define edge cases and error handling.

7. Example questions

Seed the Agent with natural queries aligned to your Use Case.

Best Practices

Write with precision

  • Use imperative verbs: filter, calculate, rank, visualize

  • Reference tools with /: /execute_query, /add_layer

  • Reference fields with $: $sites.revenue, $sites.location_id

The / shortcut provides simplified names for:

  • All Core Tools available in CARTO for your Agent

  • Any MCP Tools you've added to your Agent (these appear with the same name)

While the / notation shows all Core Tools and your added MCP Tools, not all may be accessible to your Agent. Tool availability still depends on:

  • Your map configuration (widgets and parameters must exist to be filtered/accessed)

  • Enabled capabilities (e.g., /execute_query requires "Query sources" to be enabled)

Scope to your Use Case

  • Include only relevant fields and flows

  • Remove generic instructions that don't apply

  • Focus on your specific business logic

Test and iterate

  • Start with core functionality

  • Test with real user queries

  • Add edge cases as discovered

  • Refine based on feedback patterns

Quick-start template

Copy and customize this template to get started quickly:

Last updated

Was this helpful?