Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

Added log messages for task and step creation

SwiftyOS040c6bcd8c98
diff --git a/autogpts/forge/forge/agent.py b/autogpts/forge/forge/agent.py
index d220fa142f..89a248895e 100644
--- a/autogpts/forge/forge/agent.py
+++ b/autogpts/forge/forge/agent.py
@@ -1,4 +1,6 @@
-from forge.sdk import Agent, AgentDB, Step, StepRequestBody, Workspace
+from forge.sdk import Agent, AgentDB, Step, StepRequestBody, Workspace, ForgeLogger, Task, TaskRequestBody
+
+LOG = ForgeLogger(__name__)
class ForgeAgent(Agent):
@@ -62,6 +64,19 @@ class ForgeAgent(Agent):
Feel free to create subclasses of the database and workspace to implement your own storage
"""
super().__init__(database, workspace)
+
+ async def create_task(self, task_request: TaskRequestBody) -> Task:
+ """
+ The agent protocol, which is the core of the Forge, works by creating a task and then
+ executing steps for that task. This method is called when the agent is asked to create
+ a task.
+
+ We are hooking into function to add a custom log message. Though you can do anything you
+ want here.
+ """
+ task = await super().create_task(task_request)
+ LOG.info(f"📦 Task created: {task.task_id} input: {task.input[:40]}{'...' if len(task.input) > 40 else ''}")
+ return task
async def execute_step(self, task_id: str, step_request: StepRequestBody) -> Step:
"""
@@ -88,12 +103,17 @@ class ForgeAgent(Agent):
multiple steps. Returning a request to continue in the step output, the user can then decide
if they want the agent to continue or not.
"""
-
# An example that
self.workspace.write(task_id=task_id, path="output.txt", data=b"Washington D.C")
step = await self.db.create_step(
task_id=task_id, input=step_request, is_last=True
)
+ message = f'\t🔄 Step executed: {step.step_id} input: {step.input[:19]}'
+ if step.is_last:
+ message = f'\t✅ Final Step completed: {step.step_id} input: {step.input[:19]}'
+
+ LOG.info(message)
+
artifact = await self.db.create_artifact(
task_id=task_id,
step_id=step.step_id,