mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-30 01:18:07 -05:00
chore: add debug logging for find_library_agent tool
Added logging to help diagnose library search issues: - Log the query and user_id when tool is called - Log the number of results returned from database
This commit is contained in:
@@ -153,12 +153,18 @@ async def search_agents(
|
||||
|
||||
# If no results from UUID lookup, do text search
|
||||
if not agents:
|
||||
logger.info(f"Searching user library for: {query}")
|
||||
logger.info(
|
||||
f"Searching user library for: {query!r} (user_id={user_id})"
|
||||
)
|
||||
results = await library_db.list_library_agents(
|
||||
user_id=user_id, # type: ignore[arg-type]
|
||||
search_term=query,
|
||||
page_size=10,
|
||||
)
|
||||
logger.info(
|
||||
f"Library search returned {len(results.agents)} agents "
|
||||
f"(total_items={results.pagination.total_items})"
|
||||
)
|
||||
for agent in results.agents:
|
||||
agents.append(
|
||||
AgentInfo(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Tool for searching agents in the user's library."""
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from backend.api.features.chat.model import ChatSession
|
||||
@@ -8,6 +9,8 @@ from .agent_search import search_agents
|
||||
from .base import BaseTool
|
||||
from .models import ToolResponseBase
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FindLibraryAgentTool(BaseTool):
|
||||
"""Tool for searching agents in the user's library."""
|
||||
@@ -44,8 +47,10 @@ class FindLibraryAgentTool(BaseTool):
|
||||
async def _execute(
|
||||
self, user_id: str | None, session: ChatSession, **kwargs
|
||||
) -> ToolResponseBase:
|
||||
query = kwargs.get("query", "").strip()
|
||||
logger.info(f"find_library_agent called: query={query!r}, user_id={user_id}")
|
||||
return await search_agents(
|
||||
query=kwargs.get("query", "").strip(),
|
||||
query=query,
|
||||
source="library",
|
||||
session_id=session.session_id,
|
||||
user_id=user_id,
|
||||
|
||||
Reference in New Issue
Block a user