[6.x]: AI tool-calling check fails with a 400 on Anthropic, so Ask AI can't use Claude models

Closed Beginner friendly
#20,266 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@riasvdv is already working on this.

Since Nov 3, 2026.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
backend

Research direction

The failing check is the anonymous tool in src/Ai/Agents/ToolCallingProbe.php around line 34, which has no name() method, so laravel/ai falls back to a class_basename that Anthropic rejects. Start by reading that file and comparing it with the other Craft assistant tools that do define name(). Done when the probe declares a name() such as get_verification_code and the tool-calling check passes against claude-sonnet-5-5.

Written by the indexing model from the issue text.

Description

bug repo:cms
What happened?
Steps to reproduce
  1. Add an Anthropic provider to config/ai.php (the stock laravel/ai config has one) and set ANTHROPIC_API_KEY.
  2. In Settings → Extend → Connections, set the default text provider to anthropic and the model to claude-sonnet-5-5.
  3. Save.
Expected behavior

Craft confirms the model supports tool calling, and the AI assistant task becomes available.

Actual behavior

The check fails, and the AI assistant task is reported as unavailable:

Craft couldn’t check whether the claude-sonnet-5-5 model on the anthropic provider supports tool calling, which AI assistant needs: HTTP request returned status code 400: {"type":"error","error":{"type":"invalid_request_error","message":"tools.0.custom.name: String should match pattern '^[a (truncated...)

Cause

The test tool in src/Ai/Agents/ToolCallingProbe.php:34 is an anonymous class without a name() method. laravel/ai's ToolNameResolver falls back to class_basename(), which for an anonymous class gives a name like ToolCallingProbe.php:34$398. Anthropic rejects the ., : and $. Craft's other assistant tools all define name(), so only this check is affected.

Suggested fix
  • Add a name() method to the anonymous tool, e.g. returning get_verification_code.
Notes

With that method added locally, the tool name resolves to get_verification_code and the check passes with claude-sonnet-5-5. config/ai.php is the stock laravel/ai config, so the config isn't involved.

Craft CMS version

6.x-dev (395aae2)

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions
Dominant language
PHP
Stars
3.6k
Forks
712
Avg merge
12h 44m
Merged PRs (30d)
381

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from craftcms/cms

All issues in craftcms/cms

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.