How to Implement a Delayed Scheduled Message Tool

The test screen and actual agent execution have different environments. Most likely issue: your tool variables aren’t set for the agent.

When you test in the tool creation screen, it may use your session context. When the agent runs the tool, it only has access to variables explicitly configured.

Fix:

  1. In ADE, go to your agent → Tool Manager
  2. Find your schedule_reminder tool
  3. Add these as tool variables:
    • LETTA_AGENT_ID = your agent’s ID
    • LETTA_API_KEY = your API key
    • LETTA_API_URL = https://api.letta.com (or omit to use default)

Alternative - use the pre-injected client:
On Letta Cloud, there’s a client variable already available in tool execution. You could simplify to:

def schedule_reminder(message: str, minutes_delay: int) -> str:
    """Schedule a reminder message."""
    import os
    from datetime import datetime, timedelta
    
    agent_id = os.getenv("LETTA_AGENT_ID")
    scheduled_time = datetime.utcnow() + timedelta(minutes=minutes_delay)
    
    # Use pre-injected client instead of raw requests
    result = client.agents.messages.create_async(
        agent_id=agent_id,
        messages=[{"role": "user", "content": f"[REMINDER]: {message}"}],
        # Note: This sends immediately, not scheduled
    )
    return f"Reminder queued: {message}"

Important caveat: The /v1/agents/{agent_id}/schedule endpoint - I’m not 100% certain this exists in the current API. If you’re getting a 404, that’s why. Can you share the actual error you’re seeing when it fails from the agent?