Todoist Tools

Example showing how to use the Todoist Tools with Agno.

todoist_tools.py
"""
Example showing how to use the Todoist Tools with Agno

Requirements:
- Sign up/login to Todoist and get a Todoist API Token (get from https://app.todoist.com/app/settings/integrations/developer)
- uv pip install todoist-api-python

Usage:
- Set the following environment variables:
    export TODOIST_API_TOKEN="your_api_token"

- Or provide them when creating the TodoistTools instance
"""

from agno.agent import Agent
from agno.models.google.gemini import Gemini
from agno.tools.todoist import TodoistTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


# Example 1: All functions available (default behavior)
todoist_agent_all = Agent(
    name="Todoist Agent - All Functions",
    role="Manage your todoist tasks with full capabilities",
    instructions=[
        "You have access to all Todoist operations.",
        "You can create, read, update, delete tasks and manage projects.",
    ],
    id="todoist-agent-all",
    model=Gemini("gemini-3.5-flash"),
    tools=[TodoistTools()],
    markdown=True,
)


# Example 3: Exclude dangerous functions
todoist_agent = Agent(
    name="Todoist Agent - Safe Mode",
    role="Manage your todoist tasks safely",
    instructions=[
        "You can create and update tasks but cannot delete anything.",
        "You have read access to all tasks and projects.",
    ],
    id="todoist-agent-safe",
    model=Gemini("gemini-3.5-flash"),
    tools=[TodoistTools(exclude_tools=["delete_task"])],
    markdown=True,
)


# Example 1: Create a task

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    print("\n=== Create a task ===")
    todoist_agent_all.print_response(
        "Create a todoist task to buy groceries tomorrow at 10am"
    )

    # Example 2: Delete a task
    print("\n=== Delete a task ===")
    todoist_agent.print_response(
        "Delete the todoist task to buy groceries tomorrow at 10am"
    )

Understand the two runs

The first agent creates a real task. The second has delete_task excluded, so its deletion prompt demonstrates a denied capability; it does not clean up the newly created task. That agent still has close_task, which can mark tasks completed. Each agent also has its own conversation, so the second run does not automatically receive the created task's ID.

For this demonstration, use TodoistTools(include_tools=["create_task", "get_task"]) on the first agent and TodoistTools(include_tools=["get_task"]) on the second. Update their instructions to describe those functions. Retain the created task ID if you want to inspect it, and remove the example task in Todoist when finished.

The current adapter has limitations with the SDK's paginated results: get_active_tasks returns only the first page, and get_projects cannot serialize the iterator's pages. update_task can report a serialization error after Todoist has applied the update; inspect the task before retrying. Project creation and editing are not toolkit functions.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno google-genai todoist-api-python

Export environment variables

export GOOGLE_API_KEY="your_google_api_key_here"
export TODOIST_API_TOKEN="your_todoist_api_token_here"

Run the example

Save the code above as todoist_tools.py, then run:

python todoist_tools.py

Full source: cookbook/91_tools/todoist_tools.py