Skip to content

Copilot

Copilot turns a natural-language prompt into a step-by-step plan and runs that plan against a loan. In the dashboard this is Copilot Agent. In the API, an agent is a task group.

Admins write prompts and generate actions. Anyone on the loan can run a task and watch the result.

sequenceDiagram
    participant User as User
    participant API as Areal API
    participant Copilot as Copilot

    rect rgb(191, 223, 255)
        User->>API: Save a prompt on a task
        API->>Copilot: Generate actions
        Copilot-->>API: Plan
        API-->>User: Task with plan
    end

    rect rgb(200, 255, 200)
        User->>API: Run the task on a loan
        API->>Copilot: Execute plan
        Copilot-->>API: Step results
        API-->>User: WebSocket update (COPILOT_TASK_UPDATED)
    end
  • Agent (task group). A named set of automations for your organization. The API calls this a task group. It can include a starting condition and a post-run action.
  • Task. One prompt, the generated plan, and the latest run for the current loan.
  • Run. One execution of a task against a loan. Status is pending, success, failed, or n/a.
  • Generated actions. The plan Copilot builds from the prompt. The dashboard shows these as numbered steps.
  • Best next action. Guidance Copilot returns when a run fails.

Each task is scoped to a loan through session_id. Create a loan first; see Loans.

Open a loan, then Copilot Agent.

  • Everyone sees executions for that loan, can run a task, and can open the result (plan, documents used, best next action).
  • Admins can switch to admin view to create agents, write prompts, generate actions, and mark tasks active.
List agents and run a task
import requests
BASE_URL = 'http://dev-api.v2.areal.ai/api/v2'
SESSION_ID = 'your-loan-id'
# 0. Login - details in Authentication section
# 1. List Copilot agents (task groups) for this loan
agents = client.get(
url=f'{BASE_URL}/copilot/task-group/',
params={'session_id': SESSION_ID},
).json()
for agent in agents['task_groups']:
print(f"{agent['id']} - {agent['name']} - {agent['status']}")
task_group_id = agent['id']
# 2. List tasks in an agent
tasks = client.get(
url=f'{BASE_URL}/copilot/task-group/{task_group_id}/tasks/',
params={'session_id': SESSION_ID},
).json()
for task in tasks['objects']:
print(f"{task['id']} - {task['name']} - {task['results']['status']}")
task_id = task['id']
# 3. Run a task against this loan
run_response = client.post(
url=f'{BASE_URL}/copilot/task/{task_id}/execute/',
json={'session_id': SESSION_ID},
headers={'Content-Type': 'application/json'},
)
print(run_response.json())

To run every active task in an agent, POST /api/v2/copilot/task-group/{task_group_id}/execute/ with { "session_id": "..." }.

For the full Copilot API see Copilot.