From 8989369b17ef6bfbf62cda56d39d4c2865c984fe Mon Sep 17 00:00:00 2001 From: Cameron Pfiffer Date: Wed, 2 Jul 2025 12:06:59 -0700 Subject: [PATCH] Add bluesky_reply tool for Letta agent responses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created new reply.py tool module with bluesky_reply function - Added 300 character validation to match Bluesky's limit - Registered the tool in register_tools.py - This simple tool allows the Letta agent to indicate when it wants to send a reply 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- register_tools.py | 7 +++++++ tools/reply.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tools/reply.py diff --git a/register_tools.py b/register_tools.py index 0b1e0b1..849a508 100755 --- a/register_tools.py +++ b/register_tools.py @@ -14,6 +14,7 @@ from tools.search import search_bluesky_posts, SearchArgs from tools.post import create_new_bluesky_post, PostArgs from tools.feed import get_bluesky_feed, FeedArgs from tools.blocks import attach_user_blocks, detach_user_blocks, AttachUserBlocksArgs, DetachUserBlocksArgs +from tools.reply import bluesky_reply, ReplyArgs load_dotenv() logging.basicConfig(level=logging.INFO) @@ -53,6 +54,12 @@ TOOL_CONFIGS = [ "description": "Detach user-specific memory blocks from the agent. Blocks are preserved for later use.", "tags": ["memory", "blocks", "user"] }, + { + "func": bluesky_reply, + "args_schema": ReplyArgs, + "description": "Simple reply indicator for the Letta agent (max 300 chars)", + "tags": ["bluesky", "reply", "response"] + }, ] diff --git a/tools/reply.py b/tools/reply.py new file mode 100644 index 0000000..d44a62d --- /dev/null +++ b/tools/reply.py @@ -0,0 +1,34 @@ +"""Reply tool for Bluesky - a simple tool for the Letta agent to indicate a reply.""" +from pydantic import BaseModel, Field, validator + + +class ReplyArgs(BaseModel): + message: str = Field( + ..., + description="The reply message text (max 300 characters)" + ) + + @validator('message') + def validate_message_length(cls, v): + if len(v) > 300: + raise ValueError(f"Message cannot be longer than 300 characters (current: {len(v)} characters)") + return v + + +def bluesky_reply(message: str) -> str: + """ + This is a simple function that returns a string. MUST be less than 300 characters. + + Args: + message: The reply text (max 300 characters) + + Returns: + Confirmation message + + Raises: + Exception: If message exceeds 300 characters + """ + if len(message) > 300: + raise Exception(f"Message cannot be longer than 300 characters (current: {len(message)} characters)") + + return 'Reply sent' \ No newline at end of file -- 2.51.2