mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 05:58:08 +01:00
Improve implementation of is_mcp_tool (#53)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import inspect
|
||||
from datetime import timedelta
|
||||
from typing import Any, Deque, Dict
|
||||
|
||||
@@ -6,7 +7,7 @@ from temporalio.common import RetryPolicy
|
||||
from temporalio.exceptions import ActivityError
|
||||
|
||||
from models.data_types import ConversationHistory, ToolPromptInput
|
||||
from models.tool_definitions import AgentGoal
|
||||
from models.tool_definitions import AgentGoal, ToolDefinition
|
||||
from prompts.agent_prompt_generators import (
|
||||
generate_missing_args_prompt,
|
||||
generate_tool_completion_prompt,
|
||||
@@ -25,60 +26,15 @@ def is_mcp_tool(tool_name: str, goal: AgentGoal) -> bool:
|
||||
if not goal.mcp_server_definition:
|
||||
return False
|
||||
|
||||
# Check if the tool name matches any MCP tools that were loaded
|
||||
# We can identify MCP tools by checking if they're not in the original static tools
|
||||
from tools.tool_registry import (
|
||||
book_pto_tool,
|
||||
book_trains_tool,
|
||||
change_goal_tool,
|
||||
create_invoice_tool,
|
||||
current_pto_tool,
|
||||
ecomm_get_order,
|
||||
ecomm_list_orders,
|
||||
ecomm_track_package,
|
||||
financial_check_account_is_valid,
|
||||
financial_get_account_balances,
|
||||
financial_move_money,
|
||||
financial_submit_loan_approval,
|
||||
find_events_tool,
|
||||
food_add_to_cart_tool,
|
||||
future_pto_calc_tool,
|
||||
give_hint_tool,
|
||||
guess_location_tool,
|
||||
list_agents_tool,
|
||||
paycheck_bank_integration_status_check,
|
||||
search_fixtures_tool,
|
||||
search_flights_tool,
|
||||
search_trains_tool,
|
||||
# Identify MCP tools by checking if they're not in the original static tools
|
||||
import tools.tool_registry
|
||||
|
||||
return not any(
|
||||
tool.name == tool_name
|
||||
for _, tool in inspect.getmembers(tools.tool_registry)
|
||||
if isinstance(tool, ToolDefinition)
|
||||
)
|
||||
|
||||
static_tool_names = {
|
||||
list_agents_tool.name,
|
||||
change_goal_tool.name,
|
||||
give_hint_tool.name,
|
||||
guess_location_tool.name,
|
||||
search_flights_tool.name,
|
||||
search_trains_tool.name,
|
||||
book_trains_tool.name,
|
||||
create_invoice_tool.name,
|
||||
search_fixtures_tool.name,
|
||||
find_events_tool.name,
|
||||
current_pto_tool.name,
|
||||
future_pto_calc_tool.name,
|
||||
book_pto_tool.name,
|
||||
paycheck_bank_integration_status_check.name,
|
||||
financial_check_account_is_valid.name,
|
||||
financial_get_account_balances.name,
|
||||
financial_move_money.name,
|
||||
financial_submit_loan_approval.name,
|
||||
ecomm_list_orders.name,
|
||||
ecomm_get_order.name,
|
||||
ecomm_track_package.name,
|
||||
food_add_to_cart_tool.name,
|
||||
}
|
||||
|
||||
return tool_name not in static_tool_names
|
||||
|
||||
|
||||
async def handle_tool_execution(
|
||||
current_tool: str,
|
||||
|
||||
Reference in New Issue
Block a user