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

オープン 初心者向け
#20,266 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
backend

調査の方向性

失敗しているチェックは、src/Ai/Agents/ToolCallingProbe.php の34行目付近にある無名のツールです。このツールには name() メソッドがないため、laravel/ai は Anthropic が拒否する class_basename にフォールバックします。まずそのファイルを読み、name() を定義している他の Craft アシスタントツールと比較してください。プローブが get_verification_code などの name() を宣言し、claude-sonnet-5-5 に対してツール呼び出しチェックが通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
PHP
スター
3.6k
フォーク
712
平均マージ
12時間 40分
マージ済み PR(30日)
344

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

craftcms/cms のほかの issue

craftcms/cms の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。