> ## Documentation Index
> Fetch the complete documentation index at: https://docs.taskguru.so/llms.txt
> Use this file to discover all available pages before exploring further.

# AutoGPT & Autonomous Agents

> How to use TaskGuru as the memory and orchestration system for AutoGPT and BabyAGI.

# Hooking AutoGPT into TaskGuru

Autonomous agents like **AutoGPT**, **BabyAGI**, and **Devin** are incredible at breaking down massive goals into smaller steps. However, their internal memory is often a black box CLI terminal, making it difficult for humans to understand what the agent is actually planning to do next.

TaskGuru solves this. By writing a simple custom plugin for AutoGPT, you can force the agent to use TaskGuru as its "Workspace".

## Use Case: AI Software Developer

Imagine you give AutoGPT the prompt: *"Build a weather web app in React."*

Instead of AutoGPT just vomiting terminal text, we teach it to:

1. Create a `Board` in TaskGuru called "⛅ Weather App Build".
2. Generate all the sub-tasks it thinks it needs (e.g., "Setup Vite", "Fetch Weather API", "Design CSS").
3. Assign the tricky tasks (like "Approve CSS Design") to you, the human.
4. Mark tasks as `COMPLETED` as it finishes writing the code.

You can literally watch the AI move cards across the Kanban board.

## Building the AutoGPT Custom Tool (Python)

If you are using the modern AutoGPT architecture or any generic LangChain agent toolkit, you can wrap the TaskGuru REST API directly into a custom tool.

### Step 1: Wrap the Create Task Endpoint

```python theme={null}
import os
import requests
from typing import Optional, Type
from pydantic import BaseModel, Field
from langchain.tools import BaseTool

class CreateTaskguruTaskInput(BaseModel):
    name: str = Field(description="The name/title of the task the AI wants to complete.")
    description: str = Field(description="Markdown description of the steps needed.")
    board_id: str = Field(description="The UUID of the TaskGuru board to place this task on.")
    urgency: Optional[str] = Field("medium", description="none, low, medium, high, or urgent")

class CreateTaskguruTaskTool(BaseTool):
    name = "create_taskguru_task"
    description = "Use this tool to break down a large goal into smaller actionable tasks on the human's TaskGuru board."
    args_schema: Type[BaseModel] = CreateTaskguruTaskInput

    def _run(self, name: str, description: str, board_id: str, urgency: str = "medium") -> str:
        headers = {
            "Authorization": f"Bearer {os.getenv('TASKGURU_API_KEY')}",
            "Content-Type": "application/json"
        }

        payload = {
            "tasks": [{
                "name": name,
                "description": description,
                "board_id": board_id,
                "urgency": urgency
            }]
        }

        # Notice we are calling the precise OpenAPI spec endpoint
        response = requests.post(
            "https://api.taskguru.com/v1/tasks",
            json=payload,
            headers=headers
        )

        if response.status_code == 201:
            return f"Successfully created task '{name}'. Human can now view it."
        else:
            return f"Failed to create task: {response.text}"

    def _arun(self, name: str, description: str, board_id: str):
        raise NotImplementedError("create_taskguru_task does not support async yet")
```

### Step 2: Providing Agent Scratchpad Context

AutoGPT frequently forgets its previous steps when the context window fills up. TaskGuru's threading architecture solves this.

Before AutoGPT attempts a Python script, teach it to pull previous context from the Task's message thread:

```python theme={null}
def read_task_context(task_id: str) -> str:
    """Reads all messages attached to a task to regain context."""
    headers = {"Authorization": f"Bearer {os.getenv('TASKGURU_API_KEY')}"}
    response = requests.get(f"https://api.taskguru.com/v1/tasks/{task_id}/messages", headers=headers)

    messages = response.json()
    context = ""
    for msg in messages:
        context += f"Previous note: {msg['content']}\n"

    return context
```

## Why this is better than local JSON files

By forcing AutoGPT to use TaskGuru instead of its local `workspace/` directory for task tracking:

* You get a beautiful mobile app to monitor your AI engine.
* You can step in and leave a comment on a task: *"Hey AutoGPT, don't use React for this, use vanilla JS."* The agent will read that message on the next loop and adjust its plan.
