---
description: Goals in the cApp Framework
---

# Goals Module

**Goals** are one of the fundamental primitives in the cApp framework. They define what an AI agent should accomplish and serve as the guiding structure for its task execution. Goals are designed to encapsulate the desired outcomes, constraints, and preferences that guide the agent's actions, enabling it to operate effectively and autonomously in a wide range of commerce-related scenarios.

**Characteristics of Goals**

1. **Purpose-driven:** Goals articulate specific outcomes or tasks for the agent.
2. **Flexible:** Goals adapt to varying user needs and contexts.
3. **Parameterizable:** Goals can include user preferences, constraints, and dynamic inputs to fine-tune the agent’s behavior.
4. **Composable:** Multiple Goals can be combined or sequenced for complex workflows.

***

#### Example Goal: Finding a Flight for a User

Below is a sample Goal that instructs an agent to find a flight for a user based on their preferences and requirements.

**Sample Goal Definition**

```json
{
  "name": "Find Flight",
  "description": "Find a flight for the user based on their specified preferences and constraints.",
  "parameters": {
    "origin": {
      "type": "string",
      "description": "The departure city or airport.",
      "example": "San Francisco (SFO)"
    },
    "destination": {
      "type": "string",
      "description": "The arrival city or airport.",
      "example": "New York City (JFK)"
    },
    "departure_date": {
      "type": "string",
      "description": "The date of departure in YYYY-MM-DD format.",
      "example": "2025-02-15"
    },
    "return_date": {
      "type": "string",
      "description": "The return date for round-trip flights in YYYY-MM-DD format.",
      "example": "2025-02-20"
    },
    "class": {
      "type": "string",
      "description": "The preferred class of travel.",
      "example": "Economy"
    },
    "budget": {
      "type": "number",
      "description": "The maximum budget for the flight in USD.",
      "example": 500
    },
    "non_stop": {
      "type": "boolean",
      "description": "Whether the user prefers non-stop flights only.",
      "example": true
    }
  },
  "output": {
    "type": "FlightDetails",
    "description": "Details of the recommended flight(s), including airline, flight times, and pricing."
  },
  "constraints": [
    "Departure and return dates must be valid future dates.",
    "Budget cannot be less than $50."
  ],
  "example_usage": {
    "input": {
      "origin": "San Francisco (SFO)",
      "destination": "New York City (JFK)",
      "departure_date": "2025-02-15",
      "return_date": "2025-02-20",
      "class": "Economy",
      "budget": 400,
      "non_stop": true
    },
    "output": {
      "airline": "Delta Airlines",
      "flight_number": "DL1234",
      "departure_time": "2025-02-15T08:30:00",
      "arrival_time": "2025-02-15T16:00:00",
      "price": 350,
      "class": "Economy",
      "non_stop": true
    }
  }
}
```

This example showcases how Goals in the cApp framework can be precisely defined to guide the agent’s actions while maintaining flexibility to accommodate user needs.
