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

Chiusa Adatta ai principianti
#20,266 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@riasvdv ci sta già lavorando.

Dal 3/11/2026.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend

Direzione di ricerca

Il controllo che fallisce riguarda lo strumento anonimo in src/Ai/Agents/ToolCallingProbe.php, intorno alla riga 34, che non ha un metodo name(), quindi laravel/ai ricade su un class_basename che Anthropic rifiuta. Inizia leggendo quel file e confrontandolo con gli altri strumenti dell'assistente di Craft che definiscono name(). È completato quando la sonda dichiara un name() come get_verification_code e il controllo delle chiamate agli strumenti supera con claude-sonnet-5-5.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
PHP
Stelle
3.6k
Fork
712
Merge medio
12h 44m
PR unite (30g)
381

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di craftcms/cms

Tutte le issue di craftcms/cms

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.