スケジューラー
Astreusのドキュメントでスケジューラーについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。
最小限のセットアップで済む、シンプルな時間ベースの実行
概要
Astreusスケジューラーは、直感的なスケジュール文字列を使って、タスクやグラフのシンプルな時間ベースの実行を提供します。複雑な設定は不要です。scheduleフィールドを追加するだけで完了です!
基本的なタスクのスケジューリング
シンプルな構文で個々のタスクをスケジュールします。
import { Agent } from '@astreus-ai/astreus';
const agent = await Agent.create({
name: 'SchedulerAgent',
model: 'gpt-4o'
});
// Create a scheduled task - scheduler starts automatically when needed
const scheduledTask = await agent.createTask({
prompt: 'Generate monthly report for December',
schedule: 'once@2024-12-25@09:00'
});
// Create a recurring task
const dailyTask = await agent.createTask({
prompt: 'Daily health check and status report',
schedule: 'daily@08:00'
});
// Execute the task - scheduler will handle the scheduling automatically
await agent.executeTask(scheduledTask.id);スケジュールの設定
簡単な設定のために、シンプルなスケジュール文字列を使用します。
// Supported schedule formats:
'daily@07:00' // Daily at 7 AM
'weekly@monday@09:00' // Weekly on Monday at 9 AM
'monthly@1@10:00' // Monthly on 1st day at 10 AM
'hourly' // Every hour (default time)
'@15:30' // Once today at 3:30 PM
'once@2024-12-25@10:00' // Once on specific date and time
// Delay-based schedules:
'after:5s' // Run after 5 seconds
'after:30m' // Run after 30 minutes
'after:2h' // Run after 2 hours
// Examples:
await agent.createTask({
prompt: 'Morning briefing',
schedule: 'daily@08:00'
});
await agent.createTask({
prompt: 'Weekly report',
schedule: 'weekly@friday@17:00'
});依存関係を伴うグラフのスケジューリング
知的な依存関係解決とともにグラフをスケジュールします。
import { Graph } from '@astreus-ai/astreus';
const graph = new Graph({
name: 'Morning Workflow',
defaultAgentId: agent.id
}, agent);
// Node A: Data collection at 6 AM
const nodeA = graph.addTaskNode({
name: 'Data Collection',
prompt: 'Collect overnight data from all sources',
schedule: 'once@2024-12-20@06:00'
});
// Node B: Processing (depends on A completing first)
const nodeB = graph.addTaskNode({
name: 'Data Processing',
prompt: 'Process collected data and generate insights',
schedule: 'once@2024-12-20@07:00',
dependsOn: ['Data Collection'] // Must wait for A
});
// Node C: Report generation at 8 AM
const nodeC = graph.addTaskNode({
name: 'Report Generation',
prompt: 'Generate morning executive report',
schedule: 'once@2024-12-20@08:00',
dependsOn: ['Data Processing']
});
// Execute - scheduler starts automatically for scheduled nodes
await graph.run();
// Result: A runs at 06:00, B waits and runs after A (~06:05), C runs at 08:00繰り返しパターン
高度な繰り返しスケジュールを作成します。
毎日のスケジュール
// Every day at 8 AM
{
type: 'recurring',
executeAt: new Date('2024-12-20T08:00:00Z'),
recurrence: {
pattern: 'daily',
interval: 1,
maxExecutions: 365 // Stop after 1 year
}
}
// Every 3 days
{
type: 'recurring',
executeAt: new Date('2024-12-20T08:00:00Z'),
recurrence: {
pattern: 'daily',
interval: 3
}
}毎週のスケジュール
// Every Monday at 9 AM
{
type: 'recurring',
executeAt: new Date('2024-12-23T09:00:00Z'), // Monday
recurrence: {
pattern: 'weekly',
interval: 1,
daysOfWeek: [1] // Monday
}
}
// Every Monday and Friday
{
type: 'recurring',
executeAt: new Date('2024-12-23T09:00:00Z'),
recurrence: {
pattern: 'weekly',
interval: 1,
daysOfWeek: [1, 5] // Monday and Friday
}
}毎月・毎年のスケジュール
// 15th of every month
{
type: 'recurring',
executeAt: new Date('2024-12-15T10:00:00Z'),
recurrence: {
pattern: 'monthly',
interval: 1,
dayOfMonth: 15
}
}
// Every January 1st
{
type: 'recurring',
executeAt: new Date('2025-01-01T00:00:00Z'),
recurrence: {
pattern: 'yearly',
interval: 1,
monthOfYear: 1
}
}依存関係解決のロジック
スケジューラーは、スケジュールと依存関係の間の競合を知的に解決します。
| シナリオ | 挙動 |
|---|---|
| 依存関係より前にスケジュールされたノード | 依存関係が完了するまで待機 |
| 依存関係より後にスケジュールされたノード | スケジュールされた時刻に実行 |
| 複数の依存関係 | すべての依存関係が完了するまで待機 |
| 循環依存関係 | 検証時にエラーがスローされる |
| スケジュール実行と即時実行の混在ノード | シームレスに連携して動作 |
スケジューラーは、依存関係を尊重しつつニーズに応じてスケールする、自動化された時間ベースのAIワークフローを構築するための堅牢な基盤を提供します。
最終更新日: 2026年7月6日
このセクション内
はじめに
実世界のタスクを効果的に解決する自律システムを構築するための、オープンソースAIエージェントフレームワーク。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。
インストール
npm、yarn、pnpmでAstreusをインストールし、必要なNode.jsのバージョンを確認して、フレームワークでAIエージェントを構築するためのローカルプロジェクトを準備します。
クイックスタート
Astreusのドキュメントでクイックスタートについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。
エージェント
Astreusのドキュメントでエージェントについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。