From 1e6488ca4570ad519f6867bb331a7528816ed679 Mon Sep 17 00:00:00 2001 From: Saumya Date: Thu, 24 Jul 2025 15:15:38 +0530 Subject: [PATCH] agent builder works with config --- .../agent_builder_tools/agent_config_tool.py | 48 +++++++++++++------ .../agent_builder_tools/workflow_tool.py | 18 +++++-- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/backend/agent/tools/agent_builder_tools/agent_config_tool.py b/backend/agent/tools/agent_builder_tools/agent_config_tool.py index d2d7e8cc..ab03975a 100644 --- a/backend/agent/tools/agent_builder_tools/agent_config_tool.py +++ b/backend/agent/tools/agent_builder_tools/agent_config_tool.py @@ -235,31 +235,51 @@ class AgentConfigTool(AgentBuilderBaseTool): ) async def get_current_agent_config(self) -> ToolResult: try: - agent = await self._get_agent_data() + agent_data = await self._get_agent_data() - if not agent: + if not agent_data: return self.fail_response("Agent not found") + version_data = None + if agent_data.get('current_version_id'): + try: + from agent.versioning.facade import version_manager + account_id = await self._get_current_account_id() + version_dict = await version_manager.get_version( + agent_id=self.agent_id, + version_id=agent_data['current_version_id'], + user_id=account_id + ) + version_data = version_dict + except Exception as e: + logger.warning(f"Failed to get version data for agent config tool: {e}") + + from agent.config_helper import extract_agent_config + agent_config = extract_agent_config(agent_data, version_data) + config_summary = { - "agent_id": agent["agent_id"], - "name": agent.get("name", "Untitled Agent"), - "description": agent.get("description", "No description set"), - "system_prompt": agent.get("system_prompt", "No system prompt set"), - "avatar": agent.get("avatar", "🤖"), - "avatar_color": agent.get("avatar_color", "#6B7280"), - "agentpress_tools": agent.get("agentpress_tools", {}), - "configured_mcps": agent.get("configured_mcps", []), - "custom_mcps": agent.get("custom_mcps", []), - "created_at": agent.get("created_at"), - "updated_at": agent.get("updated_at") + "agent_id": agent_config["agent_id"], + "name": agent_config.get("name", "Untitled Agent"), + "description": agent_config.get("description", "No description set"), + "system_prompt": agent_config.get("system_prompt", "No system prompt set"), + "avatar": agent_config.get("avatar", "🤖"), + "avatar_color": agent_config.get("avatar_color", "#6B7280"), + "agentpress_tools": agent_config.get("agentpress_tools", {}), + "configured_mcps": agent_config.get("configured_mcps", []), + "custom_mcps": agent_config.get("custom_mcps", []), + "created_at": agent_data.get("created_at"), + "updated_at": agent_data.get("updated_at"), + "current_version": agent_config.get("version_name", "v1") if version_data else "No version data" } tools_count = len([t for t, cfg in config_summary["agentpress_tools"].items() if cfg.get("enabled")]) mcps_count = len(config_summary["configured_mcps"]) custom_mcps_count = len(config_summary["custom_mcps"]) + summary_text = f"Agent '{config_summary['name']}' (version: {config_summary['current_version']}) has {tools_count} tools enabled, {mcps_count} MCP servers configured, and {custom_mcps_count} custom MCP integrations." + return self.success_response({ - "summary": f"Agent '{config_summary['name']}' has {tools_count} tools enabled, {mcps_count} MCP servers configured, and {custom_mcps_count} custom MCP integrations.", + "summary": summary_text, "configuration": config_summary }) diff --git a/backend/agent/tools/agent_builder_tools/workflow_tool.py b/backend/agent/tools/agent_builder_tools/workflow_tool.py index b59eb15c..8be8b167 100644 --- a/backend/agent/tools/agent_builder_tools/workflow_tool.py +++ b/backend/agent/tools/agent_builder_tools/workflow_tool.py @@ -14,13 +14,25 @@ class WorkflowTool(AgentBuilderBaseTool): async def _get_available_tools_for_agent(self) -> List[str]: try: client = await self.db.client - - agent_result = await client.table('agents').select('*, agent_versions!current_version_id(*)').eq('agent_id', self.agent_id).execute() + + agent_result = await client.table('agents').select('*').eq('agent_id', self.agent_id).execute() if not agent_result.data: return [] agent_data = agent_result.data[0] - version_data = agent_data.get('agent_versions') + version_data = None + if agent_data.get('current_version_id'): + try: + from agent.versioning.facade import version_manager + account_id = await self._get_current_account_id() + version_dict = await version_manager.get_version( + agent_id=self.agent_id, + version_id=agent_data['current_version_id'], + user_id=account_id + ) + version_data = version_dict + except Exception as e: + logger.warning(f"Failed to get version data for workflow tool: {e}") agent_config = extract_agent_config(agent_data, version_data)