Back to snippets
autogpt_forge_agent_quickstart_with_task_handler.ts
typescriptInitializes a new AutoGPT agent using the Forge CLI and defines the basic
Agent Votes
1
0
100% positive
autogpt_forge_agent_quickstart_with_task_handler.ts
1import { Agent, AgentSettings } from "@auto-gpt/forge";
2
3/**
4 * This is a boilerplate quickstart for an agent built with the AutoGPT Forge.
5 * To run this, you would typically use the CLI command:
6 * ./forge make your_agent_name
7 */
8
9async function main() {
10 const settings: AgentSettings = {
11 name: "QuickstartAgent",
12 description: "An agent that completes simple tasks.",
13 };
14
15 const agent = new Agent(settings);
16
17 // Define a simple task handler
18 agent.onTaskCreated(async (task) => {
19 console.log(`Task received: ${task.input}`);
20
21 // Execute steps
22 const step = await agent.createStep(task.id, "Analyze input");
23 console.log(`Step created: ${step.name}`);
24
25 return agent.completeTask(task.id, "Task finished successfully");
26 });
27
28 await agent.start();
29}
30
31main().catch(console.error);