Skip to content

Conversation

@sirwolfgang
Copy link
Contributor

@sirwolfgang sirwolfgang commented Nov 19, 2025

Write tool definitions once, use everywhere. Connect to external services via MCP.

Tools: One Format, All Providers

# Works with Anthropic, OpenAI, OpenRouter, Ollama, Mock
tools: [{
  name: "get_weather",
  description: "Get current weather",
  parameters: {
    type: "object",
    properties: {
      location: { type: "string", description: "City and state" }
    },
    required: ["location"]
  }
}]

Before: 4 different formats across providers
After: Single format auto-converts to native formats
Backwards compatible: Old formats still work

Auto-Conversion

  • Anthropic: parametersinput_schema (gem models)
  • OpenAI: Flat/nested formats with proper objects
  • OpenRouter: Maps "required""any"
  • Ollama: Inherits transformations

Refactoring

Unified tool choice logic prevents infinite loops:

  • Before: ~100 lines duplicated
  • After: 62-line concern + hooks

Tests: 30 integration tests, 47 VCR cassettes, 0 failures

MCP: Connect External Services

class ResearchAgent < ActiveAgent::Base
  def research
    prompt(
      "Research AI developments",
      mcps: [{
        name: "github",
        url: "https://api.githubcopilot.com/mcp/",
        authorization: ENV["GITHUB_MCP_TOKEN"]
      }]
    )
  end
end

Common format: {name, url, authorization} → auto-converts to:

  • Anthropic: {type: "url", name, url, authorization_token}
  • OpenAI: {type: "mcp", server_label, server_url, authorization}

Features:

  • Anthropic: Beta API, up to 20 servers
  • OpenAI: Pre-built connectors (Dropbox, Drive, GitHub)
  • Backwards compatible: mcps or mcp_servers

Docs: /actions/mcps with 8 tested examples
Tests: 25 tests (14 unit + 11 integration), real MCP servers
Bug fix: Corrected Anthropic native format detection

Migration

No breaking changes:

# Old - still works
tools: [{ type: "function", function: { name: "...", parameters: {...} } }]

# New - recommended
tools: [{ name: "...", description: "...", parameters: {...} }]

@sirwolfgang sirwolfgang changed the title Create Common Functions/Tools Format Universal Tools Format Nov 19, 2025
@sirwolfgang sirwolfgang changed the title Universal Tools Format Universal Tools & MCP Support Nov 19, 2025
@sirwolfgang sirwolfgang marked this pull request as ready for review November 25, 2025 01:22
Copilot AI review requested due to automatic review settings November 25, 2025 01:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces universal tool definitions and MCP (Model Context Protocol) support, enabling developers to write tool definitions once and use them across all providers. It adds automatic format conversion, standardizes tool choice logic, and implements MCP server connectivity for external services.

Key Changes:

  • Universal tool format with automatic provider-specific conversion
  • MCP server integration for Anthropic and OpenAI
  • Refactored tool choice logic to prevent infinite loops

Reviewed changes

Copilot reviewed 73 out of 92 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/fixtures/vcr_cassettes/integration/open_router/common_format/tools_test/test_agent_common_format_input_schema.yml VCR cassette for OpenRouter common format tool testing
test/fixtures/vcr_cassettes/integration/open_ai/responses/*.yml VCR cassettes for OpenAI Responses API with tools and MCP
test/fixtures/vcr_cassettes/integration/open_ai/chat/common_format/tools_test/*.yml VCR cassettes for OpenAI Chat API common format tool testing
test/fixtures/vcr_cassettes/integration/ollama/chat/common_format/tools_test/test_agent_common_format_tool_choice_specific.yml VCR cassette for Ollama common format tool choice testing
test/docs/actions_examples_test.rb Added MCP example and removed redundant type field from tool definition
lib/active_agent/providers/open_router_provider.rb Added tool preparation and tool_choice_forces_required? method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TonsOfFun TonsOfFun merged commit 3953aa0 into activeagents:main Nov 25, 2025
9 checks passed
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.

2 participants