|
12 | 12 |
|
13 | 13 | A TypeScript agent framework for Azure OpenAI. Build multi-agent systems with tools, handoffs, guardrails, streaming, structured output, and more. |
14 | 14 |
|
15 | | -`agents` `tools` `streaming` `structured output` `handoffs` `subagents` `guardrails` `hooks` `tracing` `sessions` `abort signals` |
| 15 | +`agents` `tools` `streaming` `structured output` `handoffs` `subagents` `guardrails` `hooks` `tracing` `sessions` `abort signals` `todo tracking` `cost tracking` |
16 | 16 |
|
17 | 17 | ## Install |
18 | 18 |
|
@@ -331,6 +331,55 @@ try { |
331 | 331 | } |
332 | 332 | ``` |
333 | 333 |
|
| 334 | +### Todo Tracking |
| 335 | + |
| 336 | +Track task progress during agent execution: |
| 337 | + |
| 338 | +```ts |
| 339 | +import { todoTool, TodoList } from "stratus-sdk"; |
| 340 | + |
| 341 | +const todos = new TodoList(); |
| 342 | +todos.onUpdate((items) => { |
| 343 | + for (const item of items) { |
| 344 | + const icon = item.status === "completed" ? "+" : item.status === "in_progress" ? ">" : "-"; |
| 345 | + console.log(`${icon} ${item.content}`); |
| 346 | + } |
| 347 | +}); |
| 348 | + |
| 349 | +const agent = new Agent({ |
| 350 | + name: "planner", |
| 351 | + instructions: "Break tasks into steps and track progress with todo_write.", |
| 352 | + model, |
| 353 | + tools: [todoTool(todos)], |
| 354 | +}); |
| 355 | + |
| 356 | +await run(agent, "Set up a new TypeScript project"); |
| 357 | +``` |
| 358 | + |
| 359 | +### Usage & Cost Tracking |
| 360 | + |
| 361 | +Track token usage and estimate costs: |
| 362 | + |
| 363 | +```ts |
| 364 | +import { createCostEstimator } from "stratus-sdk"; |
| 365 | + |
| 366 | +const estimator = createCostEstimator({ |
| 367 | + inputTokenCostPer1k: 0.01, |
| 368 | + outputTokenCostPer1k: 0.03, |
| 369 | +}); |
| 370 | + |
| 371 | +const result = await run(agent, "Hello", { costEstimator: estimator }); |
| 372 | +console.log(result.usage.totalTokens); // token counts |
| 373 | +console.log(result.totalCostUsd); // estimated cost |
| 374 | +console.log(result.numTurns); // model call count |
| 375 | + |
| 376 | +// Set budget limits |
| 377 | +const result = await run(agent, "Hello", { |
| 378 | + costEstimator: estimator, |
| 379 | + maxBudgetUsd: 0.50, // throws MaxBudgetExceededError if exceeded |
| 380 | +}); |
| 381 | +``` |
| 382 | + |
334 | 383 | ### Tool Choice & Tool Use Behavior |
335 | 384 |
|
336 | 385 | Control how the model uses tools: |
|
0 commit comments