> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tryflavia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Built-in Agent

> The quickest way to automate tasks, with batteries included

## Overview

The easiest way to get things done is by using our proprietary computer-use agent—either through the Playground or via the agent endpoint. It’s optimized for long-running tasks and, based on our internal benchmarking, excels at leveraging the instance’s knowledge.

When given a task, the agent retrieves knowledge from the instance (which includes a summary of previous agent runs), captures a screenshot, and initiates a computer-use loop to interact with the instance. Internally, we use Anthropic’s Sonnet 3.7 model.

## Run Agent

<CodeGroup>
  ```python Python theme={null}
  import os
  from skylight_sdk import Skylight

  with Skylight(
  apikey=os.getenv("SKYLIGHT_APIKEY", ""),
  ) as skylight:

      res = skylight.agent.run(instance_id="<id>",
            query="Make a 5 slide pitch deck about Pied Piper")

  ```

  ```typescript TypeScript theme={null}
  import { Skylight } from "skylight-sdk";

  const skylight = new Skylight({
    apikey: process.env["SKYLIGHT_APIKEY"] ?? "",
  });

  async function run() {
    const result = await skylight.agent.run("<id>", {
      query: "Make a 5 slide pitch deck about Pied Piper",
    });

   }
  ```
</CodeGroup>

When the agent is done, it will generate a summary, which will be used to update the instance's [knowledge](../instances#knowledge).

## Stop Agent

You can stop a running agent with the instance ID.

<CodeGroup>
  ```python Python theme={null}
  res = skylight.agent.stop(instance_id="<id>")
  ```

  ```typescript TypeScript theme={null}
  async function run() {
  const result = await skylight.agent.stop("<id>");
  }
  run()
  ```
</CodeGroup>

The response is a JSON with status and message confirming the agent was stopped successfully.

## Get Agent State

You can check the current status of an agent with the agent ID.

**Note**: `agent_id` is different from `instance_id`. Every time you run the agent on an instance, it gets assigned a new `agent_id`.

<CodeGroup>
  ```python Python theme={null}
  res = skylight.agent.status(agent_id="<agent_id>")
  print(res.agent_status)  # "running"
  print(res.total_steps)   # 5
  ```

  ```typescript TypeScript theme={null}
  async function run() {
    const res = await skylight.agent.status("<agent_id>");
    console.log(res.agent_status);  // "running"
    console.log(res.total_steps);   // 5
  }
  run()
  ```
</CodeGroup>

The response includes A JSON with information about the agent's current state:

| Field           | Type           | Description                                        |
| --------------- | -------------- | -------------------------------------------------- |
| `agent_status`  | string         | Current status of the agent (e.g., "running")      |
| `is_running`    | boolean        | Indicates if the agent is currently active         |
| `total_steps`   | integer        | Number of steps executed so far                    |
| `files`         | object\[]      | List of files downloaded by the agent              |
| `messages`      | string\[]      | List of steps executed by the agent                |
| `created_at`    | string         | Timestamp when the agent was created               |
| `query`         | string         | Original query given to the agent                  |
| `agent_id`      | string         | Unique identifier for the agent                    |
| `final_summary` | string \| null | Summary of agent execution (null if still running) |

## Pricing

The built-in Skylight agent is billed at \$0.03 per agent step (tool call).
