Skip to content

SDK Explanation

Deep-dive documentation explaining SDK architecture and design.

The SDK is built around the pack file as the single source of truth:

Diagram
  1. Reduced Boilerplate - No manual provider/manager setup
  2. Tested Configuration - Packs are validated by Arena
  3. Portable - Same pack works across environments
  4. Versioned - Pack files are version controlled
conv, _ := sdk.Open("./pack.json", "chat")
defer conv.Close()
resp, _ := conv.Send(ctx, "Hello")

Three lines to a working conversation.

  1. Open - sdk.Open() loads pack, creates conversation
  2. Configure - SetVar(), OnTool() setup
  3. Use - Send(), Stream() interactions
  4. Close - Close() cleanup

Tools are registered with handlers:

LLM Request
Tool Call Decision
Handler Lookup
├─► OnTool handler → Execute immediately
└─► OnToolAsync handler
├─► Auto-approve → Execute
└─► Pending → Wait for ResolveTool/RejectTool

Events flow through the hooks package:

Send() ─────► EventSend
Provider Call
Response ───► EventResponse
├─► Tool Call ───► EventToolCall
│ │
│ ▼
│ Handler
│ │
│ ▼
│ EventToolResult
└─► Error ───► EventError