···250 The thread data or None if not found
251 """
252 try:
253- thread = client.app.bsky.feed.get_post_thread({'uri': uri, 'parent_height': 80, 'depth': 10})
254 return thread
255 except Exception as e:
256 logger.error(f"Error fetching post thread: {e}")
···250 The thread data or None if not found
251 """
252 try:
253+ thread = client.app.bsky.feed.get_post_thread({'uri': uri, 'parent_height': 60, 'depth': 10})
254 return thread
255 except Exception as e:
256 logger.error(f"Error fetching post thread: {e}")
+26-26
register_tools.py
···16 get_bluesky_feed,
17 attach_user_blocks,
18 detach_user_blocks,
19- update_user_blocks,
20)
2122# Import Pydantic models for args_schema
23from tools.search import SearchArgs
24from tools.post import PostArgs
25from tools.feed import FeedArgs
26-from tools.blocks import AttachUserBlockArgs, DetachUserBlockArgs, UpdateUserBlockArgs
2728load_dotenv()
29logging.basicConfig(level=logging.INFO)
···63 "description": "Detach user-specific memory blocks from the agent. Blocks are preserved for later use.",
64 "tags": ["memory", "blocks", "user"]
65 },
66- {
67- "func": update_user_blocks,
68- "args_schema": UpdateUserBlockArgs,
69- "description": "Update the content of user-specific memory blocks",
70- "tags": ["memory", "blocks", "user"]
71- },
72]
737475def register_tools(agent_name: str = "void", tools: List[str] = None):
76 """Register tools with a Letta agent.
77-78 Args:
79 agent_name: Name of the agent to attach tools to
80 tools: List of tool names to register. If None, registers all tools.
···82 try:
83 # Initialize Letta client with API key
84 client = Letta(token=os.environ["LETTA_API_KEY"])
85-86 # Find the agent
87 agents = client.agents.list()
88 agent = None
···90 if a.name == agent_name:
91 agent = a
92 break
93-94 if not agent:
95 console.print(f"[red]Error: Agent '{agent_name}' not found[/red]")
96 console.print("\nAvailable agents:")
97 for a in agents:
98 console.print(f" - {a.name}")
99 return
100-101 # Filter tools if specific ones requested
102 tools_to_register = TOOL_CONFIGS
103 if tools:
···105 if len(tools_to_register) != len(tools):
106 missing = set(tools) - {t["func"].__name__ for t in tools_to_register}
107 console.print(f"[yellow]Warning: Unknown tools: {missing}[/yellow]")
108-109 # Create results table
110 table = Table(title=f"Tool Registration for Agent '{agent_name}'")
111 table.add_column("Tool", style="cyan")
112 table.add_column("Status", style="green")
113 table.add_column("Description")
114-115 # Register each tool
116 for tool_config in tools_to_register:
117 func = tool_config["func"]
118 tool_name = func.__name__
119-120 try:
121 # Create or update the tool using the standalone function
122 created_tool = client.tools.upsert_from_function(
···124 args_schema=tool_config["args_schema"],
125 tags=tool_config["tags"]
126 )
127-128 # Get current agent tools
129 current_tools = client.agents.tools.list(agent_id=str(agent.id))
130 tool_names = [t.name for t in current_tools]
131-132 # Check if already attached
133 if created_tool.name in tool_names:
134 table.add_row(tool_name, "Already Attached", tool_config["description"])
···139 tool_id=str(created_tool.id)
140 )
141 table.add_row(tool_name, "✓ Attached", tool_config["description"])
142-143 except Exception as e:
144 table.add_row(tool_name, f"✗ Error: {str(e)}", tool_config["description"])
145 logger.error(f"Error registering tool {tool_name}: {e}")
146-147 console.print(table)
148-149 except Exception as e:
150 console.print(f"[red]Error: {str(e)}[/red]")
151 logger.error(f"Fatal error: {e}")
···157 table.add_column("Tool Name", style="cyan")
158 table.add_column("Description")
159 table.add_column("Tags", style="dim")
160-161 for tool_config in TOOL_CONFIGS:
162 table.add_row(
163 tool_config["func"].__name__,
164 tool_config["description"],
165 ", ".join(tool_config["tags"])
166 )
167-168 console.print(table)
169170171if __name__ == "__main__":
172 import argparse
173-174 parser = argparse.ArgumentParser(description="Register Void tools with a Letta agent")
175 parser.add_argument("agent", nargs="?", default="void", help="Agent name (default: void)")
176 parser.add_argument("--tools", nargs="+", help="Specific tools to register (default: all)")
177 parser.add_argument("--list", action="store_true", help="List available tools")
178-179 args = parser.parse_args()
180-181 if args.list:
182 list_available_tools()
183 else:
184 console.print(f"\n[bold]Registering tools for agent: {args.agent}[/bold]\n")
185- register_tools(args.agent, args.tools)
···16 get_bluesky_feed,
17 attach_user_blocks,
18 detach_user_blocks,
19+ # update_user_blocks,
20)
2122# Import Pydantic models for args_schema
23from tools.search import SearchArgs
24from tools.post import PostArgs
25from tools.feed import FeedArgs
26+from tools.blocks import AttachUserBlockArgs, DetachUserBlockArgs #, UpdateUserBlockArgs
2728load_dotenv()
29logging.basicConfig(level=logging.INFO)
···63 "description": "Detach user-specific memory blocks from the agent. Blocks are preserved for later use.",
64 "tags": ["memory", "blocks", "user"]
65 },
66+ # {
67+ # "func": update_user_blocks,
68+ # "args_schema": UpdateUserBlockArgs,
69+ # "description": "Update the content of user-specific memory blocks",
70+ # "tags": ["memory", "blocks", "user"]
71+ # },
72]
737475def register_tools(agent_name: str = "void", tools: List[str] = None):
76 """Register tools with a Letta agent.
77+78 Args:
79 agent_name: Name of the agent to attach tools to
80 tools: List of tool names to register. If None, registers all tools.
···82 try:
83 # Initialize Letta client with API key
84 client = Letta(token=os.environ["LETTA_API_KEY"])
85+86 # Find the agent
87 agents = client.agents.list()
88 agent = None
···90 if a.name == agent_name:
91 agent = a
92 break
93+94 if not agent:
95 console.print(f"[red]Error: Agent '{agent_name}' not found[/red]")
96 console.print("\nAvailable agents:")
97 for a in agents:
98 console.print(f" - {a.name}")
99 return
100+101 # Filter tools if specific ones requested
102 tools_to_register = TOOL_CONFIGS
103 if tools:
···105 if len(tools_to_register) != len(tools):
106 missing = set(tools) - {t["func"].__name__ for t in tools_to_register}
107 console.print(f"[yellow]Warning: Unknown tools: {missing}[/yellow]")
108+109 # Create results table
110 table = Table(title=f"Tool Registration for Agent '{agent_name}'")
111 table.add_column("Tool", style="cyan")
112 table.add_column("Status", style="green")
113 table.add_column("Description")
114+115 # Register each tool
116 for tool_config in tools_to_register:
117 func = tool_config["func"]
118 tool_name = func.__name__
119+120 try:
121 # Create or update the tool using the standalone function
122 created_tool = client.tools.upsert_from_function(
···124 args_schema=tool_config["args_schema"],
125 tags=tool_config["tags"]
126 )
127+128 # Get current agent tools
129 current_tools = client.agents.tools.list(agent_id=str(agent.id))
130 tool_names = [t.name for t in current_tools]
131+132 # Check if already attached
133 if created_tool.name in tool_names:
134 table.add_row(tool_name, "Already Attached", tool_config["description"])
···139 tool_id=str(created_tool.id)
140 )
141 table.add_row(tool_name, "✓ Attached", tool_config["description"])
142+143 except Exception as e:
144 table.add_row(tool_name, f"✗ Error: {str(e)}", tool_config["description"])
145 logger.error(f"Error registering tool {tool_name}: {e}")
146+147 console.print(table)
148+149 except Exception as e:
150 console.print(f"[red]Error: {str(e)}[/red]")
151 logger.error(f"Fatal error: {e}")
···157 table.add_column("Tool Name", style="cyan")
158 table.add_column("Description")
159 table.add_column("Tags", style="dim")
160+161 for tool_config in TOOL_CONFIGS:
162 table.add_row(
163 tool_config["func"].__name__,
164 tool_config["description"],
165 ", ".join(tool_config["tags"])
166 )
167+168 console.print(table)
169170171if __name__ == "__main__":
172 import argparse
173+174 parser = argparse.ArgumentParser(description="Register Void tools with a Letta agent")
175 parser.add_argument("agent", nargs="?", default="void", help="Agent name (default: void)")
176 parser.add_argument("--tools", nargs="+", help="Specific tools to register (default: all)")
177 parser.add_argument("--list", action="store_true", help="List available tools")
178+179 args = parser.parse_args()
180+181 if args.list:
182 list_available_tools()
183 else:
184 console.print(f"\n[bold]Registering tools for agent: {args.agent}[/bold]\n")
185+ register_tools(args.agent, args.tools)