Skip to content

Invalid constructor argument 3 for service "ai.platform.anthropic": argument 2 must be defined before in dev-main #363

@Krystopher88

Description

@Krystopher88

Bug Report

Environment:

  • symfony/ai-bundle: dev-main (installed from git on 2025-08-25)
  • Symfony: 7.3
  • PHP: 8.3
  • Platform: Docker with FrankenPHP

Issue:
When configuring Anthropic agents in ai.yaml, the application fails to clear cache and throws a service definition error.

Error Message:
In DefinitionErrorExceptionPass.php line 48:
Invalid constructor argument 3 for service "ai.platform.anthropic": argument 2 must be defined before. Check your service definition.

Configuration Used:

  ai:
      platform:
          anthropic:
              api_key: '%env(ANTHROPIC_API_KEY)%'

      agent:
          blog_generator:
              platform: 'ai.platform.anthropic'
              model:
                  class: 'Symfony\AI\Platform\Bridge\Anthropic\Claude'
                  name: !php/const Symfony\AI\Platform\Bridge\Anthropic\Claude::SONNET_35
              system_prompt: "Tu es un rédacteur web expert."

Steps to Reproduce:

  1. Install symfony/ai-bundle from dev-main
  2. Configure Anthropic platform with valid API key
  3. Configure at least one agent using Anthropic Claude models
  4. Run symfony console cache:clear

Expected Behavior:
Cache should clear successfully and Anthropic agents should be available.

Actual Behavior:
Cache clear fails with service definition error related to constructor arguments.

Additional Context:

  • Mistral configuration works perfectly with the same setup
  • The error suggests an issue with the service definition in the Anthropic bridge
  • This prevents using Anthropic agents entirely
  • Switching to Mistral platform works as expected

Workaround:
Currently using Mistral as alternative, but Anthropic support is needed for production requirements.

Service Definition Debug:
The error seems to indicate that the ai.platform.anthropic service has incorrect constructor argument ordering or missing dependencies.

Would appreciate guidance on:

  1. Is this a known issue with dev-main?
  2. Are there specific configuration requirements for Anthropic not documented?
  3. Is there a fix or workaround available?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions