Skip to content

Conversation

@jankinf
Copy link

@jankinf jankinf commented Nov 24, 2025

Features

  • Fix _is_special_tool so that MCP-wrapped tools (named like mcp_{server_id}_{tool_name}) are correctly recognized as special tools.
  • Ensure the terminate tool is treated as special even when invoked via MCP, e.g. mcp_server_id_terminate.
  • Align _should_finish_execution logic with MCP naming conventions so that calls to MCP terminate tools correctly finish the agent execution.

Influence

  • Without this change, MCP terminate tools are not recognized as special, so:

    • _handle_special_tool is never invoked for mcp_{server_id}_terminate.
    • The agent may continue executing instead of terminating after a tool-initiated stop signal.
  • With the new detection logic:

    • MCP terminate tools behave consistently with non-MCP terminate tools.
    • Tool-initiated termination works reliably in both direct and MCP scenarios, reducing the chance of agents “running on” after a termination request.

Result

  • _is_special_tool now correctly detects:
    • Plain terminate (and other special tools) by exact name.
    • MCP-wrapped variants like mcp_server_id_terminate by suffix match.
  • _should_finish_execution now uses a lowercase name and supports both terminate and names ending in _terminate, aligning with the MCP naming scheme.
  • Verified locally that:
    • Calling a non-MCP terminate tool still terminates the agent as before.
    • Calling an MCP terminate tool (e.g. mcp_test_terminate) correctly triggers special-tool handling and finishes execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant