Skip to main content

Introduction

Maxw AI features a sophisticated AI assistant powered by Anthropic Claude Sonnet 4.5 with native tool support through the AI SDK v6. The agent uses the ToolLoopAgent pattern for multi-step reasoning and tool execution.

Core Architecture

Model Configuration

import { anthropic } from "@ai-sdk/anthropic";
import { ToolLoopAgent } from "ai-sdk-tools";

const agent = new ToolLoopAgent({
  model: anthropic("claude-sonnet-4-5"),
  instructions: buildSystemPrompt(context),
  tools: getGeneralAgentTools(context),
  providerOptions: {
    anthropic: {
      thinking: { type: "enabled", budgetTokens: 10000 },
      container: { skills: [...] },
    },
  },
});

Agent Context

Every request builds a dynamic AgentContext with current date/time and user information:
userId
string
required
Unique user identifier
fullName
string
required
User’s full name
schoolName
string
required
Name of the user’s educational institution
classes
CanvasCourse[]
required
Array of user’s Canvas LMS courses
currentDateTime
string
required
Current date and time formatted in the user’s timezone
timezone
string
required
User’s timezone (e.g., “America/New_York”)
chatId
string
required
Unique identifier for the current conversation
country
string
User’s country for location-aware search
city
string
User’s city for location-aware search
region
string
User’s region/state for location-aware search

Container-Based Execution

The agent uses Anthropic’s code execution containers for running Python code:
  • Persistence: Files persist across the conversation (~4.5 minute inactivity timeout)
  • Skills: Documentation files loaded into the container for reference
  • Programmatic Tools: Tools can be called directly from Python code
  • Parallel Processing: Multiple operations can run concurrently via asyncio

Container Session Management

Container IDs are stored per chat for reuse:
export const containerSession = pgTable("container_session", {
  id: text("id").primaryKey(),
  chatId: text("chat_id").notNull().unique(),
  containerId: text("container_id").notNull(),
  createdAt: timestamp("created_at").defaultNow().notNull(),
  expiresAt: timestamp("expires_at").notNull(),
});

Skills System

Skills are documentation files loaded into the code execution container:
  • canvas-assignments: Canvas assignment data structure and patterns
  • todo-management: Todo data structure and CRUD operations
  • llm-invocation: Guide for parallel LLM processing
These skills provide reference documentation that the agent can access during code execution.

Tool Categories

Native Anthropic Tools

code_execution

Python sandbox for calculations and programmatic tool calling

web_search

Location-aware web search (max 5 per conversation)

memory

Filesystem-like persistent user memory

web_fetch

Fetch and process web content

Custom Tools

Canvas LMS

Search content, fetch assignments

Todo Management

CRUD operations for user tasks

Study Tools

Create flashcards and practice questions

Programmatic Tool Calling

Tools marked “programmatic only” are called from within Python code execution:
import json
import asyncio

# Fetch assignments from all classes
result = await getClassAssignments({})
assignments = json.loads(result)

# Create todos for overdue assignments
for assignment in assignments:
    if assignment.get('due_at'):
        await createTodo({
            "title": f"Complete {assignment['name']}",
            "dueDate": assignment['due_at'],
            "canvasContentType": "assignment",
            "canvasContentId": assignment['id'],
            "canvasClassId": int(assignment['_classId'])
        })
Benefits:
  • Reduced latency (no round trips to model)
  • Token savings (filter data in Python)
  • Conditional logic based on intermediate results
  • Parallel processing with asyncio.gather

Extended Thinking

The agent uses Claude’s extended thinking feature with a 10,000 token budget:
providerOptions: {
  anthropic: {
    thinking: { type: "enabled", budgetTokens: 10000 }
  }
}
This enables deeper reasoning for complex tasks like assignment prioritization and study planning.

Next Steps

General Agent

Explore the system prompt and capabilities

Available Tools

Complete tool reference and parameters

Memory System

Learn about persistent user memory

Build docs developers (and LLMs) love