アップグレードノート
2.1.0 へのアップグレード
意思決定モデル
新規: DecisionModel API
org.springframework.ai.decision に含まれる新しい DecisionModel API は、はいまたはいいえ、複数のカテゴリのいずれか、スケール上のレベルなど、既知の結果セットの中から選択し、それぞれの結果の可能性を報告します。他のモデル API と同様の構造で、DecisionPrompt が入力として、DecisionResponse が出力として、DecisionOptions が呼び出しを調整します。3 つの実装が利用可能です。
OpenAiDecisionModelは、OpenAI Decisions API によってサポートされ、spring.ai.openai.decisionの OpenAI スターターによって自動構成されます。OpenAI 意思決定モデルを参照してください。OllamaDecisionModelは、spring-ai-systemoneのSystemOneClientを介して Ollama/v1/systemoneエンドポイントによってサポートされ、spring.ai.ollama.decisionの Ollama スターターによって自動構成され、d1-omni:600mがデフォルトモデルとして、spring.ai.ollama.init.decisionが起動時に意思決定モデルをプルします。Ollama 意思決定モデルを参照してください。SystemOneDecisionModel, designed for the/v1/systemoneendpoint, with theSystemOneClientof the protocol in thespring-ai-systemonemodule, and usable with TypeSafe, Laya, llmman, Ollama, and other compatible inference services, auto-configured by thespring-ai-starter-model-systemonestarter underspring.ai.systemone. See システム 1 意思決定モデル。
Decision models are observed with the decision operation name, and the new spring-ai-autoconfigure-model-decision-observation module adds token usage metrics. See 意思決定モデル。
メッセージパーツ
新規: AssistantMessage と UserMessage で MessagePart コンテンツを順序付けされます
AssistantMessage and UserMessage now hold their content as an ordered list of MessagePart entries (TextPart、ReasoningPart、ToolCallPart、ToolResultPart、MediaPart、UnknownPart), available through getParts(). getText()、getMedia()、getToolCalls() and the new getReasoning() are views over the parts. See メッセージパーツ。
インパクト
The constructors and the existing builder methods keep working and produce the parts in the order text, tool calls, media, so no code change is required.
getMedia()andgetToolCalls()return unmodifiable lists; add media and tool calls through the builder instead of mutating the returned list.equals()andhashCode()of both message types compare the parts, so media now takes part in equality;Mediagained value equality over id, MIME type and data (the name is excluded because it defaults to a random value).A message with parts but no text part has an empty text;
getText()isnullonly for a message without any part.On a builder that also holds parts, for example one returned by
mutate(), the legacy setter replace the parts of their type in place instead of adding to them:content(…)the text parts,toolCalls(…)the tool call parts,media(…)the media parts and, onToolResponseMessage,responses(…)the tool result parts. To keep the existing text parts and append a new one at the end of the parts, usepart(TextPart.of(…))instead.
非推奨
The following are still written or accepted for one release and will be removed afterwards.
The protected
textContentfield for all subclasses of AbstractMessage, is kept, but should be accessed viagetText()The protected
mediafield ofAssistantMessageandUserMessage, kept for subclasses that read it.The protected
responsesfield ofToolResponseMessage, kept for subclasses that read it.
新規: Streaming Contract for Parts
Streamed chunks carry indexed partial parts (StreamingParts) and the response id, and MessageAggregator rebuilds the complete parts from them. Raw ChatModel.stream() subscribers that only read getText() see the text deltas exactly as before. Reasoning deltas now carry their text in a ReasoningPart.
インパクト
A streamed chunk never has a null text, so map(AssistantMessage::getText).collect(Collectors.joining()) keeps working. The chat models whose API streams tool call arguments (Anthropic, OpenAI Chat Completions and Responses, Bedrock Converse, DeepSeek) emit each argument delta as a chunk holding a partial ToolCallPart, before the complete call arrives once, as before. A partial ToolCallPart is not a tool call: getToolCalls() and hasToolCalls() skip it, so nothing executes on it, and MessageAggregator skips it, so chat memory never persists it. ChatClient passes these chunks through so that a UI can show the call in progress; .stream().content() is unaffected, as they carry no text. See ストリーミングツール呼び出し引数。
In 2.1.0-M1 and 2.1.0-RC1, MessageAggregator appended the arguments of partial ToolCallPart`s to their call. It now skips them, so a custom chat model that streams a tool call only as partial `ToolCallPart`s aggregates to a message without that tool call. Such a chat model must also emit the complete `ToolCallPart, at the same index as its deltas, as the built-in chat models do.
Anthropic
変更: Anthropic Java SDK 3.x
The Anthropic module now uses Java SDK 3.4.0 and API version 2026-10-21. Remove temperature、topP、topK from model defaults and request options, including explicit default values. Remove spring.ai.anthropic.chat.temperature、spring.ai.anthropic.chat.top-p、spring.ai.anthropic.chat.top-k, including their legacy .options aliases. The retained Java methods and Boot properties are deprecated since 2.1.0; the legacy aliases remain deprecated since 2.0.0. Sampling values in model defaults and request options are discarded and a WARN message is logged.
API keys now use Authorization: Bearer instead of X-Api-Key. Update proxies, interceptors and header allowlists that depend on the previous header. See Anthropic Java SDK 3.x migration for details.
変更: Thinking Is Returned as `ReasoningPart` s of a Single Generation
AnthropicChatModel maps every content block of a response to one MessagePart, in block order: thinking and redacted thinking become a ReasoningPart whose payload carries the signature or the redacted block data, and blocks Spring AI does not model yet (server tool use, server tool results, container upload) become an UnknownPart instead of being dropped. An assistant message is replayed to Anthropic in part order, so the signed thinking block stays in front of the tool call it justified, and server tool blocks go back as the JSON they arrived as; reasoning and `UnknownPart` s produced by another provider are not replayed. See レスポンス構造。
インパクト
A non-streaming response has a single
Generation; the separate thinking and redacted thinking generations are gone. Read the reasoning fromgetResult().getOutput().getReasoning().The package-private
AnthropicChatModel.AnthropicAssistantMessageis removed, together with theanthropicThinkingContentsmetadata entry. Messages restored from a chat memory written by an earlier version lose their thinking blocks on replay.The
signatureanddatametadata keys are no longer set on the non-streaming response.A redacted thinking
ReasoningParthas no text; its payload kind isAnthropicChatModel.PAYLOAD_REDACTED_THINKING.
Google GenAI
変更: One Generation per Candidate, with Ordered Message Parts
GoogleGenAiChatModel now returns one Generation per response candidate, whose message holds the Gemini parts in order: thoughts as ReasoningPart, text as TextPart, function calls as ToolCallPart, inline data as MediaPart, and server-side tool calls and responses, executable code, code execution results and file data as UnknownPart. Each thought signature is the OpaquePayload of the part that carried it, and is replayed on that same part. See メッセージパーツ。
インパクト
With
includeThoughtsenabled, thoughts are no longer separate generations flagged with theisThoughtmetadata key, and a function call candidate is no longer split into a thought, a tool call and an answer generation.getResult()is the whole candidate, soChatClient…content()returns the answer instead of the first thought. Read the thoughts withAssistantMessage.getReasoning().Text that precedes a function call in the same candidate is part of the message text.
Server-side tool parts, executable code and code execution results are sent back to Gemini when the message is replayed, instead of being dropped.
Streamed chunks carry the response id and indexed partial parts, as described in the streaming contract above.
マイグレーション
Replace code that iterates over getResults() and filters on the isThought metadata key:
// Before
List<String> thoughts = response.getResults().stream()
.filter(g -> Boolean.TRUE.equals(g.getOutput().getMetadata().get("isThought")))
.map(g -> g.getOutput().getText())
.toList();
// After
List<String> thoughts = response.getResult().getOutput().getReasoning().stream()
.map(ReasoningPart::text)
.toList();除去
GoogleGenAiChatModel.THOUGHT_METADATA_KEYand theisThoughtmetadata key it named, which were added on the 2.0.x line, are gone. An assistant message that still carries the key, for example one restored from a chat memory written by 2.0.x, is no longer replayed to Gemini as a thought: its text is sent as plain text, which Gemini accepts.
OpenAI Chat Completions
変更: OpenAiChatModel Builds Its Messages from Message Parts
OpenAiChatModel maps each choice of a Chat Completions response to ordered message parts: the reasoning_content (or reasoning) field of OpenAI-compatible servers becomes a ReasoningPart, the content a TextPart, each function tool call a ToolCallPart, and the audio output a MediaPart. The extra fields a server returns on a tool call, such as the Gemini thought signature in extra_content, are the OpaquePayload of that ToolCallPart (provider OpenAiChatModel.CHAT_COMPLETIONS_PROVIDER, kind OpenAiChatModel.PAYLOAD_TOOL_CALL_ADDITIONAL_PROPERTIES). An assistant message is replayed from its parts, and user message parts are sent in their order, so text and media can interleave. See メッセージパーツ。
インパクト
A tool-call-only choice no longer holds an empty
TextPart;getText()still returns an empty string.Reasoning parts without a payload are replayed as
reasoning_content, including those produced by another chat model, such as the reasoning textOpenAiResponsesChatModelreturns for a reasoning item without encrypted content (for example fromgpt-ossbehind a Responses-compatible server). Reasoning signed by another provider is not replayed, and neither is any reasoning of a message that holds some. SetreplayReasoningContenttofalsefor a server that rejectsreasoning_content.Streamed chunks carry indexed partial reasoning and text parts, as described in the streaming contract above.
Text a server streams alongside or after the tool call deltas of a turn is no longer cut to its first fragment.
非推奨
The following message metadata keys are still written, and read on replay when the parts do not carry the value, for one release; read the parts instead.
reasoningContent: useAssistantMessage.getReasoning(). On a streamed chunk it holds the reasoning accumulated so far, not the delta.openai.tool_calls.additional_properties: use the payload of theToolCallPart.
変更: A Finish Reason That the API Does Not Define Is Kept
An OpenAI-compatible provider may send a finish reason that the OpenAI API does not define, such as eos. OpenAiChatModel used to report null for it. ChatGenerationMetadata.getFinishReason() now returns the value as it was sent. The finish reasons that the API defines are reported by their name, such as STOP, as before.
DeepSeek
変更: DeepSeekChatModel Builds Its Messages from Message Parts
DeepSeekChatModel maps each choice to ordered message parts: the reasoning_content becomes a ReasoningPart, the content a TextPart and each tool call a ToolCallPart. An assistant message is replayed from its parts, and the chat prefix completion flag is the new DeepSeekChatModel.PREFIX_METADATA_KEY (deepseek.prefix) metadata entry, so a plain AssistantMessage can carry both. See メッセージパーツ。
インパクト
A tool-call-only choice no longer holds an empty
TextPart;getText()returns an empty string.A choice without any content has an empty text instead of a
nullone.Streamed responses now keep the reasoning: the aggregated message holds the
ReasoningPart, and it is replayed asreasoning_content, which the DeepSeek documentation requires in thinking mode for every assistant message of a request that carries tools.The reasoning of earlier assistant messages, including streamed ones, is sent as
reasoning_contentin requests without tools too, where the API ignores it.Reasoning sent in the same streamed chunks as a tool call, which DeepSeek normally streams before the tool call, is no longer cut to its last fragment.
The prefix flag is only honored on the last message of a prompt.
非推奨
DeepSeekAssistantMessage is deprecated for removal. DeepSeekChatModel still returns it, so existing casts keep working, and its accessors are views over the plain AssistantMessage state:
getReasoningContent()joins the text of theReasoningPart`s, and the builder’s `reasoningContent(…)replaces them; useAssistantMessage.getReasoning()instead.setReasoningContent(…)cannot change the immutable parts: it overrides whatgetReasoningContent()returns and what is replayed, andcopy()ormutate()turn the override into the reasoning part of the new message.getPrefix(),setPrefix(…)and the builder’sprefix(…)read and write theDeepSeekChatModel.PREFIX_METADATA_KEYmetadata entry; set that entry instead.
除去
The DeepSeekAssistantMessage.prefixAssistantMessage(…) factory methods, deprecated since 2.0.0, are removed.
マイグレーション
// Before
String reasoning = ((DeepSeekAssistantMessage) response.getResult().getOutput()).getReasoningContent();
Message prefix = DeepSeekAssistantMessage.builder().content("```python\n").prefix(true).build();
// After
List<ReasoningPart> reasoning = response.getResult().getOutput().getReasoning();
Message prefix = AssistantMessage.builder()
.content("```python\n")
.properties(Map.of(DeepSeekChatModel.PREFIX_METADATA_KEY, true))
.build();Add the reasoning content of a prefix message as a ReasoningPart, for example with AssistantMessage.builder().part(ReasoningPart.of(…)).
変更: DeepSeekChatModel Streams Through DeepSeekApi.chatCompletionStreamRaw
DeepSeekChatModel streams through the new DeepSeekApi.chatCompletionStreamRaw, which returns the chunks as the server sends them, so that it can stream the tool call argument deltas. DeepSeekApi.chatCompletionStream still merges the chunks of a tool call, and is no longer used by DeepSeekChatModel.
OpenAI Service Connections
新規: OpenAiConnectionDetails
The OpenAI auto-configurations now resolve the base URL and API key through a Spring Boot ConnectionDetails bean, OpenAiConnectionDetails. By default the bean is backed by the spring.ai.openai.base-url and spring.ai.openai.api-key properties, so existing configuration keeps working. Declaring your own OpenAiConnectionDetails bean supersedes those two properties, while the model-level overrides such as spring.ai.openai.chat.base-url and spring.ai.openai.chat.api-key still take precedence. This is the hook for pointing the OpenAI models at an OpenAI-compatible server running in a container, for example via Testcontainers or Docker Compose. See 接続詳細。
Bedrock コンバース
変更: A Response Is a Single Generation of Ordered `MessagePart` s
BedrockProxyChatModel maps every content block of a response to one MessagePart, in block order: text becomes a TextPart, tool use a ToolCallPart, and signed or redacted reasoning a ReasoningPart whose payload carries the signature or the Base64 encoded redacted content. An assistant message is replayed to Bedrock in part order, and the parts of a UserMessage are sent in their order, so text and media can interleave. Streamed responses now carry the reasoning they previously dropped, so a streaming tool loop with extended thinking replays its reasoning too. See 推論。
インパクト
A non-streaming response has a single
Generation. A response with several text blocks, or with text and tool use, used to produce one generation per text block plus one for the tool calls; read the joined text fromgetResult().getOutput().getText()and the tool calls fromgetResult().getOutput().getToolCalls().The package-private
BedrockAssistantMessageandBedrockReasoningContentare removed. Read the reasoning fromgetResult().getOutput().getReasoning().Reasoning returned without a signature, for example by the OpenAI gpt-oss models, is replayed only when its
ReasoningPartcarries theproviderattribute (MessagePart.PROVIDER_ATTRIBUTE) set tobedrock, so it is lost when the conversation history is stored or rebuilt without part attributes; unsigned reasoning produced by another provider is not replayed.Streamed text deltas now carry their text in an indexed partial
TextPart;getText()on each chunk returns the same delta as before.Streams now emit additional chunks for reasoning deltas, the reasoning signature and redacted reasoning. They have an empty
getText()and carry no tool calls, so code that counts chunks or treats every chunk as answer text sees them.
BedrockChatOptions.requestParameters widened to Map<String, Object>
BedrockChatOptions.requestParameters (and its Spring Boot property mirror BedrockConverseProxyChatProperties.requestParameters) has been widened from Map<String, String> to Map<String, Object>. This allows nested maps and lists as values, which is required for structured provider-specific fields such as Anthropic’s output_config passed through Bedrock Converse’s additionalModelRequestFields.
インパクト
This is a source-level breaking change for callers that hold an explicitly typed Map<String, String> variable assigned to or read from this API. Inline map literals and callers already using Map<String, Object> (or var) are unaffected.
マイグレーション
Change any explicitly typed Map<String, String> variable to Map<String, Object>:
// Before
Map<String, String> params = Map.of("anthropic_version", "bedrock-2023-05-31");
BedrockChatOptions options = BedrockChatOptions.builder()
.requestParameters(params)
.build();
// After
Map<String, Object> params = Map.of("anthropic_version", "bedrock-2023-05-31");
BedrockChatOptions options = BedrockChatOptions.builder()
.requestParameters(params)
.build();Nested values are now supported:
BedrockChatOptions options = BedrockChatOptions.builder()
.requestParameters(Map.of("output_config", Map.of("effort", "low")))
.build();spring:
ai:
bedrock:
converse:
chat:
request-parameters:
output_config:
effort: low
anthropic_version: bedrock-2023-05-31Map keys bind literally — use the exact provider field name (e.g. output_config, not output-config). |
Mistral AI
変更: MistralAiChatModel Builds Its Messages from Message Parts
MistralAiChatModel maps every content chunk of a response to one MessagePart, in chunk order: thinking becomes a ReasoningPart, text a TextPart, and a citation reference or an image chunk an UnknownPart; the tool calls follow as ToolCallPart`s. An assistant message that carries Mistral reasoning or other Mistral chunks is replayed as content chunks in part order, so a reasoning model gets its thinking back, as Mistral recommends. The parts of a `UserMessage with media are sent in their order, so text and images can interleave. See 推論内容。
インパクト
getText()joins the text chunks of a response without a separator; it used to join them with the platform line separator, which split the text around a citation.Streamed chunks now always carry the response id and model in their
ChatResponseMetadata; chunks without usage report an empty usage.Reasoning is replayed only when its
ReasoningPartcarries theproviderattribute (MessagePart.PROVIDER_ATTRIBUTE) set tomistral_ai, so it is lost when the conversation history is stored or rebuilt without part attributes.An assistant message without reasoning parts, such as one built by an earlier version, has the thinking under the
thinking_contentmetadata key replayed as a thinking chunk; earlier versions never sent the thinking back.A
UserMessagewith media no longer sends an empty text chunk when it has no text.MistralAiApi.ChatCompletionMessage.ThinkChunkgains asignaturecomponent; code that deconstructs it with a record pattern must add the component.
PgVector ストア
distance is a reserved metadata key in PgVectorStore
PgVectorStore writes the computed similarity distance into each returned document’s metadata under the key distance (via DocumentMetadata.DISTANCE). Previously, if a stored document already contained a distance key in its own metadata, it was silently overwritten with the computed value. This has been fixed: the stored value is now preserved and a warning is logged when the collision is detected.
インパクト
If your documents store a field named distance for domain-specific data (e.g. a geographic distance), that value now survives a similarity search. A WARN -level log entry is emitted for each affected document:
Skipping computed similarity distance for document <id> because its metadata already contains a 'distance' key
The computed similarity score is still available via Document.getScore() regardless of whether the metadata key was written.
マイグレーション
If you rely on reading the computed similarity distance from document.getMetadata().get("distance"), switch to document.getScore() instead, which is always populated and returns 1.0 - distance (higher means more similar). If your documents use distance for domain-specific data, consider renaming that field to avoid the collision and the warning.
チャットクライアント
新規: 終了理由カテゴリ
ChatGenerationMetadata.getFinishReasonCategory() maps the finish reason of a provider onto a FinishReasonCategory (COMPLETED、TRUNCATED、TOOL_CALL、FILTERED、OTHER、UNSPECIFIED), and ChatResponse.hasFinishReasonCategory(…) checks all generations of a response. getFinishReason() still returns the name the provider uses. The chat models of Spring AI classify their own finish reasons. A custom ChatModel can do the same with ChatGenerationMetadata.builder().finishReasonCategory(…). Without it the category is derived from the raw finish reason. See 終了理由カテゴリ。
変更: entity(…) Throws a ContentFilteredException for a Filtered Response It Cannot Convert
When the generation that entity(…) converts finished in the FILTERED category, for example with content_filter、refusal、guardrail_intervened or SAFETY, and its text is empty or cannot be converted, entity(…) throws a ContentFilteredException. In the same case responseEntity(…) returns the response with a null entity.
インパクト
A filtered response that converts is returned as before.
Before,
entity(…)failed with the parsing error of the converter, or returnednullwhen the response had no text. Code that catches the parsing error, or handlesnull, for a filtered response now gets aContentFilteredException. The parsing error is its cause.Before,
responseEntity(…)failed with the parsing error. It now returns anullentity.content(),chatResponse()and streaming are unchanged.
変更: StructuredOutputValidationAdvisor Does Not Repeat a Filtered Response
When a response fails the validation and finished in the FILTERED category, the advisor returns it without asking the model again. Before, it repeated the request with the validation error up to maxRepeatAttempts times, and each attempt was stopped the same way.
チャットメモリ
非推奨: ChatMemory in Favor of Session Memory
The ChatMemory API (ChatMemory、MessageWindowChatMemory、ChatMemoryRepository、InMemoryChatMemoryRepository), the MessageChatMemoryAdvisor, the JDBC, Cassandra, Neo4j, MongoDB and Redis chat memory repositories and their auto-configurations are deprecated for removal in 3.0.0. セッションメモリ replaces them; セッションメモリへの移行 maps one onto the other. Session stores for Cassandra, Neo4j, MongoDB and Redis, and session dialects for HSQLDB, Oracle, SQL Server and SQLite, are planned before 3.0.0, when the deprecated modules are removed.
インパクト
Nothing changes at runtime: the deprecated types keep working until 3.0.0.
The conversation key moves to
MemoryAdvisor.CONVERSATION_ID, with the same value asChatMemory.CONVERSATION_ID, so requests reach both the chat memory and the session advisors.getConversationId(context)moves fromBaseChatMemoryAdvisorup toMemoryAdvisor;BaseChatMemoryAdvisorinherits it, so its implementations need no change.VectorStoreChatMemoryAdvisoris not deprecated.
アドバイザー
変更: Guardrail Refusals Are Marked
The failure response of the SafeGuardAdvisor is now marked as the refusal of a guardrail, with the GuardrailRefusal.FINISH_REASON finish reason (guardrailRefusal). GuardrailRefusal.isRefusal(chatResponse) tells such a reply from an answer of the model, and GuardrailRefusal.generation(text) builds one in a guardrail advisor of your own. See アドバイザー。
インパクト
The text of the failure response and the result of content()、chatResponse()、stream() are the same as before.
ChatClient.entity(…)throws aGuardrailRefusalException, which carries the refusal, where it passed the failure response to the output converter before. It is aContentFilteredException. With the default JSON converters that conversion failed, so the type of the exception changes. With a converter that accepts plain text, such asListOutputConverter, the call returned the converted failure response and now throws.ChatClient.responseEntity(…)returns the response with anullentity in place of the conversion.The
StructuredOutputValidationAdvisorreturns a refusal as it is, without validating it or asking the model again.The
SemanticCacheAdvisordoes not cache a refusal.The failure response had no finish reason before. In a stream, advisors built on
BaseAdvisorrun theirafterstep on a response with a finish reason, so those ahead of theSafeGuardAdvisorin the chain now run it on the refusal, as they already did for a call.
Modern MCP Server
変更: Completions Belong to Their Prompt or Template
In Spring AI 2.1.0-RC2 the modern MCP server (spring.ai.mcp.server.protocol=MODERN) served completions from a separate List<SyncCompletionRegistration> bean and McpSyncCompletionRepository. Both are gone: a completion now belongs to its prompt or resource template. See 補完。
マイグレーション
Move a programmatic completion to
withCompletionHandleron its prompt or template.SyncResourceTemplateRegistrationnow holds the SDK’sMcpSyncResourceTemplate. Itsof(…)factories are unchanged, but the accessor istemplate(), whosedefinition()is theResourceTemplatethatresourceTemplate()returned, and the canonical constructor takes the SDK template.
2.0.3 へのアップグレード
キャッシュ機能付きプロンプトトークン使用
Anthropic および Bedrock Converse では、同期レスポンスとストリーミングレスポンスの両方について、Usage.getPromptTokens() および gen_ai.usage.input_tokens 観測属性にキャッシュ読み取りトークンとキャッシュ書き込みトークンが含まれるようになりました。以前は、これらの値はキャッシュされていない入力トークンのみをカウントしていました。Anthropic の Usage.getTotalTokens() にはキャッシュされた入力トークンも含まれ、Bedrock のプロバイダが報告する合計値にはすでに含まれています。個別のキャッシュ読み取りおよびキャッシュ書き込み使用状況フィールドは引き続き利用可能です。アプリケーションが以前の動作を補正するためにプロンプトトークン数にキャッシュトークンを手動で追加している場合は、二重カウントを避けるためにその調整を削除してください。
TikaDocumentReader テキスト抽出制限
TikaDocumentReader now extracts at most TikaDocumentReader.DEFAULT_MAX_CHARACTERS (10,000,000) characters from a document. Previously the whole document was extracted into memory, so the memory used by a read was bounded only by the size of the document.
インパクト
Reading a document whose text exceeds 10,000,000 characters now throws an IllegalStateException instead of returning a Document. That is roughly a few thousand pages of text, so typical documents are unaffected.
The constructor taking a ContentHandler is not affected, as the handler keeps controlling its own write limit.
マイグレーション
Pass an explicit limit to read larger documents, or -1 to restore the previous behavior. Because the extracted text is held in memory, disabling the limit is only safe for documents from trusted sources.
// Before
new TikaDocumentReader(resource, ExtractedTextFormatter.defaults());
// After, reading documents of up to 50,000,000 characters
new TikaDocumentReader(resource, 50_000_000, ExtractedTextFormatter.defaults());
// After, without any limit
new TikaDocumentReader(resource, -1, ExtractedTextFormatter.defaults());Typesense Vector Store Filter Value Escaping Hardened
TypesenseFilterExpressionConverter no longer serializes filter values as JSON. The filter_by grammar is not JSON: only backticks delimit string literals, and a double quote is matched as part of the value rather than as a delimiter. Values are now emitted as backtick literals, values containing a backtick are rejected, and java.util.Date values are emitted as epoch milliseconds.
インパクト
The generated
filter_bystring for string-valued filters changed format, delimiting values with backticks instead of double quotes:
# Before
metadata.country: "BG"
# After
metadata.country: `BG`Typesense evaluates both forms identically for values that do not contain a backtick, double quote, parenthesis, square bracket, comma, &&, or ||, so most applications will see no behavior change beyond the wire format. Values containing any of those characters were matched incorrectly before this change. * Filter values containing a literal backtick character are now rejected with IllegalArgumentException at conversion time. Typesense’s filter_by parser has no escape mechanism for an embedded backtick, so such values could not be represented safely and were already unreliable before this change. * Values that are neither Number, Boolean nor Date are converted with String#valueOf and emitted as backtick literals. Previously such values were JSON-serialized, which quoted them with double quotes. For example, an enum filter value now produces metadata.day: instead of MONDAY metadata.day: "MONDAY". * java.util.Date filter values are now emitted as epoch milliseconds, matching the representation the Typesense client uses when storing them:
# Before
metadata.activationDate: "1970-01-01T00:00:02.000Z"
# After
metadata.activationDate: 2000Date filters could not match any document before this change, because the stored value is a number while the filter compared against a quoted string.
マイグレーション
No code changes are required unless your application:
Asserts the exact string produced by
TypesenseFilterExpressionConverter#convertExpression(), for example in tests. Update expectations to the backtick-delimited format.Passes metadata values containing a backtick character into
SearchRequest.filterExpression()for a Typesense-backed vector store. Remove or replace the backtick, as such values are no longer accepted.Works around the previously broken date filtering, for example by passing epoch milliseconds as a number instead of a
Date. Such filters keep working, andDatevalues can now be passed directly.
2.0.2 へのアップグレード
音声合成および文字起こしモデルに関する考察
OpenAI テキスト音声変換および文字起こしモデル、ElevenLabs テキスト音声変換モデル、および Stability AI イメージモデルは、ObservationRegistry が利用可能な場合 (gen_ai.operation.name が text_to_speech、transcription、image に設定されている gen_ai.client.operation の場合) に観測結果を報告するようになりました。レジストリを持つアプリケーションでは、これらの呼び出しに対して新しいメトリクス系列とスパンが表示されます。コンテンツログハンドラーはデフォルトで無効になっています。可観測性を参照してください。
Neo4j チャットメモリリポジトリ
古いインデックスを正しいプロパティインデックスに置き換えました
Neo4jChatMemoryRepositoryConfig によって作成されたインデックスは誤ったノードプロパティを参照していたため、常に空であり、すべての会話検索が完全なラベルスキャンにフォールバックする原因となっていた。
インパクト
既存のデプロイには、どのノードにも存在しないプロパティをインデックス化した、2 つの古いインデックスがあります。
session_conversation_id_indexonSession.conversationId(リポジトリクエリSession.id)message_index_indexonMessage.index(リポジトリはMessage.idxによってオーダーされます)
起動時に、正しいプロパティを持つ 2 つの新しいインデックスが作成されます。
session_id_indexonSession.idmessage_idx_indexonMessage.idx
Mandatory Scope Resolver for SemanticCacheAdvisor
SemanticCacheAdvisor now requires a SemanticCacheScopeResolver that returns the scope of each request, such as a tenant or user identifier. Cached responses are only shared between requests that resolve to the same scope, so a response generated for one user is no longer returned to another user asking a similar question. See Cache Scope.
インパクト
The
SemanticCacheAdvisorconstructors take aSemanticCacheScopeResolveras second argument, andSemanticCacheAdvisor.Builder.build()fails if noscopeResolveris set.When the resolver returns
nullor a blank string, the request bypasses the cache: nothing is read from or written to it.The auto-configuration only registers a
SemanticCacheAdvisorbean when the application defines aSemanticCacheScopeResolverbean.The scope replaces the system prompt as isolation boundary: requests with different system prompts share cached responses within a scope, unless the resolver includes the system prompt in the scope.
Custom
SemanticCacheimplementations must implement the context hash methods, seeSemanticCacheInterface Changes.SemanticCacheAdvisoraccepts an optional time-to-live for cached responses throughSemanticCacheAdvisor.Builder.ttl(Duration), or thespring.ai.vectorstore.redis.semantic-cache.ttlproperty for the auto-configured advisor. Without it, cached responses never expire, as before.The context hash stored with each cache entry is now the hash of the scope, so entries cached by a previous version are no longer returned; remove them with
SemanticCache.clear()or let them expire if they were stored with a TTL.
マイグレーション
Provide a scope resolver deriving the scope from a trusted source, for example an advisor parameter set by the application from the authenticated principal:
SemanticCacheAdvisor cacheAdvisor = SemanticCacheAdvisor.builder()
.cache(semanticCache)
.scopeResolver(request -> (String) request.context().get("tenantId"))
.build();
chatClient.prompt()
.user(question)
.advisors(a -> a.param("tenantId", tenantId))
.call();When relying on the auto-configuration, declare the resolver as a bean:
@Bean
SemanticCacheScopeResolver semanticCacheScopeResolver() {
return request -> (String) request.context().get("tenantId");
}To keep the previous behavior of a single cache shared by all users and isolated by system prompt, include the system prompt in a constant scope, such as request → "shared|" + request.prompt().getSystemMessage().getText().
SemanticCache Interface Changes
The SemanticCacheAdvisor isolates cached responses by passing the hash of the scope as context hash to the SemanticCache. The context hash methods of SemanticCache used to be default methods that ignored the context hash, so a custom implementation that did not override them shared cached responses across all scopes.
インパクト
set(String query, ChatResponse response, @Nullable String contextHash)andget(String query, @Nullable String contextHash)are now abstract.The new abstract method
set(String query, ChatResponse response, @Nullable String contextHash, Duration ttl)stores a cached response that expires after the given time-to-live. It is used by theSemanticCacheAdvisorwhen a TTL is configured.Custom
SemanticCacheimplementations no longer compile until they implement these methods.DefaultSemanticCacheimplements them; its TTL variant requires the underlying vector store to be aRedisVectorStoreand throwsUnsupportedOperationExceptionotherwise.
マイグレーション
Implement the three methods in custom SemanticCache implementations. Store the context hash with each entry and only return entries stored with the same context hash:
@Override
public void set(String query, ChatResponse response, @Nullable String contextHash) {
// store the entry together with the context hash
}
@Override
public void set(String query, ChatResponse response, @Nullable String contextHash, Duration ttl) {
// store the entry together with the context hash, expiring after the TTL
}
@Override
public Optional<ChatResponse> get(String query, @Nullable String contextHash) {
// only match entries stored with the same context hash
}Do not delegate to set(String, ChatResponse) or get(String) while ignoring the context hash, as this shares cached responses across scopes.
2.0.1 へのアップグレード
Redis チャットメモリリポジトリ自動構成モジュールの名称変更
Redis チャットメモリ自動構成モジュールは spring-ai-autoconfigure-model-chat-memory-repository-redis に名称変更されました。
インパクト
Redis チャットメモリ自動構成モジュールのアーティファクト ID と構成プロパティが変更されました。
成果物 :
spring-ai-autoconfigure-model-chat-memory-redis→spring-ai-autoconfigure-model-chat-memory-repository-redis構成プロパティ :
spring.ai.chat.memory.redis.→spring.ai.chat.memory.repository.redis.
マイグレーション
Maven/Gradle の依存関係を更新して、新しいアーティファクト ID を使用するようにしてください。
<!-- Before -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-model-chat-memory-redis</artifactId>
</dependency>
<!-- After -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-model-chat-memory-repository-redis</artifactId>
</dependency>構成プロパティを更新して、新しいプレフィックスを使用するようにしてください。
# Before
spring.ai.chat.memory.redis.*=xxx
# After
spring.ai.chat.memory.repository.redis.*=xxxスムーズな移行
新しいモジュールは、非推奨となりたモジュールからのスムーズな移行を実現します。
非推奨となった
spring-ai-autoconfigure-model-chat-memory-redisモジュールは依然として存在し、推移的な依存関係を通じて新しいモジュールに依存しているため、既存の依存関係は変更なしで引き続き機能します。非推奨となった
RedisChatMemoryProperties(spring.ai.chat.memory.redis) は、すべてのプロパティを現在のRedisChatMemoryRepositoryProperties(spring.ai.chat.memory.repository.redis) に委譲します。これは、このページの下部で説明されている.optionsの非推奨化で使用されているのと同じ委譲メカニズムであるため、既存のプロパティ構成は引き続き機能します。
| 非推奨モジュールと旧式の設定プレフィックスは、今後のリリースで削除されます。 |
Mistral AI モデレーションカテゴリの再編成
Mistral AI モデレーションモデルは、mistral-moderation-2411 (2026 年 6 月 30 日廃止)から mistral-moderation-2603 に移行しました。この移行に伴い、単一の dangerousAndCriminalContent カテゴリは dangerous と criminal の 2 つのカテゴリに分割されました。また、新たに jailbreaking カテゴリが追加されました。
インパクト
Categories および CategoryScores の以下のメソッドは非推奨となり、今後のリリースで削除されます。
Categories.isDangerousAndCriminalContent()Categories.Builder.dangerousAndCriminalContent(boolean)CategoryScores.getDangerousAndCriminalContent()CategoryScores.Builder.dangerousAndCriminalContent(double)
マイグレーション
非推奨となった dangerousAndCriminalContent メソッドの使用箇所を、新しい criminal および dangerous の同等のメソッドに置き換えてください。
// Before
boolean flagged = categories.isDangerousAndCriminalContent();
double score = categoryScores.getDangerousAndCriminalContent();
Categories categories = Categories.builder()
.dangerousAndCriminalContent(true)
.build();
// After
boolean flagged = categories.isCriminal() || categories.isDangerous();
double score = categoryScores.getCriminal() + categoryScores.getDangerous();
Categories categories = Categories.builder()
.criminal(true)
.dangerous(true)
.build(); また、これまで同等のカテゴリがなかった新しいカテゴリ " jailbreaking " もご確認ください。
boolean jailbreakAttempt = categories.isJailbreaking();
double jailbreakScore = categoryScores.getJailbreaking();Mistral AI チャットモデルの列挙が更新されました
MistralAiApi.ChatModel は、Mistral AI の現在のモデルラインナップ (英語) を追跡するように更新されました。いくつかの定数は、Mistral AI がすでに廃止したモデルを指していました。
インパクト
ChatModel.MAGISTRAL_MEDIUM、ChatModel.MAGISTRAL_SMALL、ChatModel.DEVSTRAL、ChatModel.OPEN_MISTRAL_NEMOは削除されました。それらが参照していたモデル(magistral-medium-latest、magistral-small-latest、devstral-latest、open-mistral-nemo)はすべてサポート終了日を過ぎているため、これらの定数を参照するコードはコンパイルできなくなります。ChatModel.MISTRAL_SMALLは現在、mistral-small-2603(以前はmistral-small-latest)を標的としています。ChatModel.MISTRAL_MEDIUMは現在、mistral-medium-3-5(以前はmistral-medium-latest)を標的としています。ChatModel.MISTRAL_LARGEはmistral-medium-3-5も対象とするようになりました。Mistral Large は廃止され、Mistral AI は後継として Mistral Medium 3.5 を推奨しています。MISTRAL_LARGEは後方互換性のためのエイリアスとしてのみ残されています。
マイグレーション
削除された定数への参照を、サポートされているモデルに置き換えてください。
// Before
String model = MistralAiApi.ChatModel.MAGISTRAL_MEDIUM.getValue();
// After
String model = MistralAiApi.ChatModel.MISTRAL_MEDIUM.getValue();Magistral の推論(「思考」)出力に依存していた場合は、代わりに MistralAiApi.ChatCompletionRequest.ReasoningEffort と MISTRAL_SMALL または MISTRAL_MEDIUM を組み合わせて使用してください。
MCP ツールの例外処理
変更: @McpTool の例外処理が @Tool と同期されました
@McpTool アノテーション付きサーバーメソッドの例外処理契約は、@Tool に準拠するようになりました。以前は、宣言されたチェック例外、Error サブ型、およびモデルに渡されたプロトコルレベルの McpError`s — were caught and silently converted into an error `CallToolResult を含む、@McpTool メソッドによってスローされるすべての例外が対象でした。2.0.1 以降、例外ディスパッチは @Tool で使用される型ベースのルールと同じものに従います。
| 例外型 | 振る舞い |
|---|---|
|
Converted to an error |
Declared checked exception |
Bubbles up as |
|
Bubbles up unchanged — hard failure |
| 泡は変化せず上昇する — ハード障害 (プロトコルレベルのシグナル、例: URL の取得) |
インパクト
意図的にチェック例外をスローする @McpTool メソッド、または問題を通知するために Error メソッドは、例外がエラーメッセージとしてモデルに伝達されることを想定していましたが、今後は例外を伝播するようになります。
マイグレーション
@McpTool メソッドがチェック例外または Error をスローし、モデルにエラーメッセージを表示させたい場合は、例外をスローする前にメソッド本体で RuntimeException (またはそのサブクラス) に変換してください。
// Before — checked exception was silently converted to an error result
@McpTool(description = "Look up an order")
public String lookupOrder(String orderId) throws NotFoundException {
throw new NotFoundException("Order not found: " + orderId);
}
// After — wrap in RuntimeException to convey error to model,
// or remove the checked-exception declaration and let it propagate
@McpTool(description = "Look up an order")
public String lookupOrder(String orderId) {
throw new RuntimeException("Order not found: " + orderId); // reaches model as error result
} チェック例外をハードエラーにしたい場合は、変更する必要はありません。デフォルトではすでに UndeclaredThrowableException としてバブルアップされます。
非推奨: toolCallExceptionClass コンストラクターパラメーター
以下のクラスの toolCallExceptionClass パラメーターは非推奨となり、2.1.0 で削除されます。実行時には無視されます。例外ディスパッチはクラスベースではなく、型ベースで行われるようになりました。
SyncMcpToolMethodCallback(ReturnMode, Method, Object, Class<? extends Throwable>)AsyncMcpToolMethodCallback(ReturnMode, Method, Object, Class<? extends Throwable>)SyncStatelessMcpToolMethodCallback(ReturnMode, Method, Object, Class<? extends Throwable>)AsyncStatelessMcpToolMethodCallback(ReturnMode, Method, Object, Class<? extends Throwable>)AbstractMcpToolProvider.doGetToolCallException()
ツール呼び出し
新規: ツール呼び出し制限
DefaultToolCallingManager では、1 回転あたりのツール呼び出し回数に制限が設けられました。DefaultToolCallingManager.DEFAULT_MAX_CALLS_PER_TOOL ではツール 1 つあたり 40 回、DEFAULT_MAX_TOTAL_TOOL_CALLS では全体で 150 回に制限されています。以前は制限は全くありませんでした。
これらのデフォルト値は余裕があるため、ほとんどのアプリケーションは気づきません。正当なワークロードがこれらの値を超える場合は、ToolCallingManager.builder().maxCallsPerTool(…) / .unlimitedCallsPerTool() (または spring.ai.tools.limits.* プロパティ) を使用して制限をプルアップするか無効にしてください。ツール呼び出し制限を参照してください。
OpenAI
変更: ツール呼び出しの厳密モードのデフォルトが false になりました
OpenAiChatModel は、ツールスキーマのデフォルトを strict(true) に設定しなくなりました。JsonSchemaGenerator は、OpenAI の厳密モードで要求される null 許容型パターンを使用する代わりに、required からオプションパラメーターを省略します。そのため、以前のデフォルト設定では、オプションパラメーターを持つツールはすべて OpenAI によって 400 エラーで拒否されていました。
変更: OpenAiAudioSpeechModel ストリーミングがリアルな音声チャンクを出力
OpenAiAudioSpeechModel.stream(TextToSpeechPrompt) は以前はレスポンス全体をバッファリングし、単一の Flux 要素として出力していました。現在は OpenAI から stream_format=audio をリクエストし、到着次第チャンクを出力するようになりました。
マイグレーション
最初の要素を取得するのではなく、出力されたすべてのチャンクを連結します。完全な例については、ストリーミングレスポンスの橋渡しを参照してください。
TranscriptionModel が StreamingTranscriptionModel を拡張
TranscriptionModel は StreamingTranscriptionModel を継承し、ストリーミング文字起こしをすべての文字起こしモデルの第一級機能として提供するようになりました。
StreamingTranscriptionModel は、Flux.error(new UnsupportedOperationException(…)) を返すデフォルトの stream(AudioTranscriptionPrompt) 実装を提供するため、既存のカスタム TranscriptionModel 実装は変更なしでコンパイルされ続けます。
マイグレーション
カスタム TranscriptionModel でストリーミング文字起こしをサポートする必要がある場合は、stream(AudioTranscriptionPrompt) メソッドをオーバーライドします。ネイティブのストリーミング実装を提供するか、同期 call() の結果を単一要素の Flux でラップすることができます。
public class CustomTranscriptionModel implements TranscriptionModel {
@Override
public AudioTranscriptionResponse call(AudioTranscriptionPrompt prompt) {
// ...
}
@Override
public Flux<AudioTranscriptionResponse> stream(AudioTranscriptionPrompt prompt) {
// Wrap the synchronous call result as a single-element Flux
return Flux.just(call(prompt));
}
}ストリーミングが不要な場合は、何もする必要はありません。デフォルトの実装が自動的に継承されます。
メディアビルダー: data() オーバーロードを data(Object) に置き換える
Media.Builder.data(Object) は型付きオーバーロード data(byte[])、data(String)、data(URI)、data(URL)、data(Resource) に置き換えられました。
マイグレーション
.data(…) を呼び出す前に、具体的な種類を絞り込んでください。
// Before
Object data = getMediaData();
Media.builder().mimeType(mimeType).data(data).build();
// After
Object data = getMediaData();
if (data instanceof byte[] bytes) {
Media.builder().mimeType(mimeType).data(bytes).build();
}
else if (data instanceof String s) {
Media.builder().mimeType(mimeType).data(s).build();
}ツール解決のフォールバックはデフォルトで無効になっています
Bean として登録されているものの、リクエストに紐付けられていないツールを解決して実行するフォールバック機能は、デフォルトで無効になりました。以前は、モデルがリクエストに紐付けられていないツールのツール呼び出しを返した場合、DefaultToolCallingManager はアプリケーション全体の ToolCallbackResolver (アプリケーションコンテキスト内のすべての ToolCallback Bean によってサポートされる)にフォールバックし、解決されたツールを実行していました。2.0.1 以降では、.tools(…)、.defaultTools(…)、ToolCallingChatOptions.toolCallbacks(…) を介してリクエストに紐付けられたツールのみが、そのリクエストに対して実行可能になります。
以前の動作に戻すには、解決フォールバックを再度有効にします。
spring.ai.tools.resolution.fallback.enabled=trueToolCallingManager を直接構築する場合は、代わりにビルダースイッチを使用してください。
ToolCallingManager toolCallingManager = ToolCallingManager.builder()
.toolCallbackResolver(toolCallbackResolver)
.resolutionFallbackEnabled(true) // default is false
.build();詳細はツール解決を参照してください。
2.0.0 へのアップグレード
このセクションでは、Spring AI 1.1.x から 2.0.0 へのアップグレード時に発生するすべての互換性のない変更点と移行手順について説明します。
アドバイザー
spring-ai-advisors-vector-store が spring-ai-vector-store-advisor に名称変更されました
spring-ai-advisors-vector-store モジュールは、他の Spring AI モジュールの命名規則との整合性を高めるため、spring-ai-vector-store-advisor に名称変更されました。
新規: ToolSearchToolCallingAdvisor 自動構成およびスターター
Spring Boot 自動構成(spring-ai-autoconfigure-tool-search-advisor)とそれに対応するスターター(spring-ai-starter-tool-search-advisor)が利用可能になりました。ToolSearchToolCallingAdvisor を有効にすると、自動構成の ChatClient 内のデフォルトの ToolCallingAdvisor が置き換えられ、呼び出しごとに LLM に送信されるツール定義が、最も関連性の高いもの(キーワード検索または意味検索による)のみに制限されます。
スターターを追加してプロパティを設定することでオプトインできます。
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-tool-search-advisor</artifactId>
</dependency>spring.ai.chat.client.tool-search-advisor.enabled=true
# Choose the index type: regex (default), lucene, or vector
spring.ai.chat.client.tool-search-advisor.tool-index-type=regexregex インデックスには追加の依存関係は必要ありません。lucene インデックスにはクラスパス上に org.apache.lucene:lucene-core が必要です。vector インデックスにはクラスパス上に VectorStore Bean(spring-ai-vector-store)が必要です。
変更: Advisor.DEFAULT_CHAT_MEMORY_PRECEDENCE_ORDER のデフォルト値
Advisor.DEFAULT_CHAT_MEMORY_PRECEDENCE_ORDER は Ordered.HIGHEST_PRECEDENCE + 1000 から Ordered.HIGHEST_PRECEDENCE + 200 に変更され、メモリアドバイザーを ToolCallingAdvisor (HIGHEST_PRECEDENCE + 300)の外側のデフォルトの順序で配置しました。
ToolCallingAdvisor は、デフォルトでツール呼び出しの反復処理全体にわたって会話履歴を内部的に管理するようになりました。メモリアドバイザーは最終的なユーザー / アシスタント間のやり取りのみを保存し、ツール呼び出しメッセージを ChatMemoryRepository に書き込むことはありません。これは、ほとんどのリポジトリ実装がこれらのメッセージ型をサポートしていないため、正しいデフォルト設定です。
ループ内でメモリが必要な場合(たとえば InMemoryChatMemoryRepository を使用する場合)、アドバイザーの順序を明示的に ToolCallingAdvisor.DEFAULT_ORDER より上に設定し、.disableInternalConversationHistory() を呼び出します。
var toolCallingAdvisor = ToolCallingAdvisor.builder()
.disableInternalConversationHistory()
.build();
var chatMemoryAdvisor = MessageChatMemoryAdvisor.builder(chatMemory)
.advisorOrder(Ordered.HIGHEST_PRECEDENCE + 400)
.build();Since 2.1.0, session memory replaces ChatMemory: it keeps tool-call messages, runs inside the tool loop by default, and builds each prompt from a turn-aware view of the conversation. See セッションメモリへの移行。 |
ツール呼び出し
除去: ToolCallingChatOptions からの internalToolExecutionEnabled
internalToolExecutionEnabled オプションは、ToolCallingChatOptions およびすべてのプロバイダ固有の ChatOptions クラス (例: OpenAiChatOptions、AnthropicChatOptions) から削除されました。対応する Spring Boot 構成プロパティ spring.ai.<provider>.chat.internal-tool-execution-enabled も削除されました。
インパクト
.internalToolExecutionEnabled(false) を設定してユーザー制御ツール実行を有効にするコードはコンパイルされなくなります。.internalToolExecutionEnabled(true) を設定するコード(内部ループを明示的に有効にするコード)もコンパイルされなくなり、そのコードが提案していた動作はもはや存在しません。モデルごとの内部ツール実行は、すべての ChatModel 実装から削除されました。
マイグレーション
.internalToolExecutionEnabled(…) へのすべての呼び出しを削除してください。推奨される方法は以下のとおりです。
ToolCallingAdvisor(ChatClient経由) (推奨) — ツールが存在する場合は自動的に登録されます。フラグは不要です。ChatModelを介してユーザーが直接ループを制御する —ToolCallingAdvisorを使用せずにChatModelを呼び出すだけで済みます。ツール呼び出しは自動的に実行されません。chatResponse.hasToolCalls()を自分で確認し、ToolCallingManagerでループを駆動してください。
// Before
ChatOptions options = ToolCallingChatOptions.builder()
.toolCallbacks(ToolCallbacks.from(new MyTools()))
.internalToolExecutionEnabled(false) // <-- remove this line
.build();
// After
ChatOptions options = ToolCallingChatOptions.builder()
.toolCallbacks(ToolCallbacks.from(new MyTools()))
.build(); 除去: ToolExecutionEligibilityPredicate および DefaultToolExecutionEligibilityPredicate
ToolExecutionEligibilityPredicate (2.0.0 以降非推奨)とそのデフォルト実装である DefaultToolExecutionEligibilityPredicate は削除されました。これらのインターフェースは、オプションベースのポリシーチェック(internalToolExecutionEnabled)とレスポンスチェック(hasToolCalls())を組み合わせたものでした。オプションベースのフラグがなくなったため、ChatModel レベルでの代替機能はありません。
新規: ToolExecutionEligibilityChecker の ToolCallingAdvisor
ToolExecutionEligibilityChecker (Function<ChatResponse, Boolean>) は、ツール呼び出しループの反復タイミングをカスタマイズするために、ToolCallingAdvisor.Builder に設定できるようになりました。デフォルトは chatResponse → chatResponse != null && chatResponse.hasToolCalls() です。
これは、プロバイダ固有の停止理由ロジック(ツール呼び出しの有無に加えて終了理由を確認するなど)の拡張ポイントです。
ToolCallingAdvisor advisor = ToolCallingAdvisor.builder()
.toolExecutionEligibilityChecker(response ->
response != null && response.hasToolCalls()
&& !"stop".equals(response.getResult().getMetadata().getFinishReason()))
.build();Spring Boot ユーザーは ToolExecutionEligibilityChecker Bean を提供できます。これは自動構成された ToolCallingAdvisor.Builder によって自動的に取得されます。
@Bean
ToolExecutionEligibilityChecker myChecker() {
return response -> response != null && response.hasToolCalls();
} 新規: spring.ai.chat.client.tool-calling.enabled プロパティ
新しいプロパティ spring.ai.chat.client.tool-calling.enabled (デフォルトは true)は、自動構成された ChatClient によって ToolCallingAdvisor が自動登録されるかどうかを制御します。これを false に設定すると、すべての呼び出しでツールの自動実行が無効になります。ツールは定義として AI モデルに送信されますが、ツール呼び出しのレスポンスは自動的に実行されません。
spring.ai.chat.client.tool-calling.enabled=false これは、個々の呼び出しごとに AdvisorParams.toolCallingAdvisorAutoRegister(false) を使用する代わりに、グローバルな代替手段を提供するものです。
除去: Advisor Builders と自動構成による streamToolCallResponses
streamToolCallResponses オプションは、ToolCallingAdvisor.Builder、ToolCallAdvisor.Builder、ToolSearchToolCallingAdvisor.Builder および対応する Spring Boot 自動構成プロパティから削除されました。
spring.ai.chat.client.tool-calling.stream-tool-call-responsesspring.ai.chat.client.tool-search-advisor.stream-tool-call-responses
なぜでしょうか
streamToolCallResponses=true の場合、中間ツール呼び出しリクエストチャンクは下流にストリーミングされていましたが、対応する ToolResponseMessage (LLM に返送されるもの) はストリーミングされていませんでした。これらのチャンクを記録した下流のメモリアドバイザは、対応するツールレスポンスのないツール呼び出しリクエストを受け取り、会話履歴が破損していました。この設計上の欠陥は、ChatClientResponse に互換性のない変更を導入しない限り修正できないため、このオプションは完全に削除されました。
インパクト
アドバイザービルダー上で
.streamToolCallResponses(true)または.streamToolCallResponses(false)を呼び出すコードは、コンパイルに失敗します。削除されたプロパティに関する
application.propertiesまたはapplication.ymlのエントリは、すべて無視されます。
マイグレーション
ビルダーチェーンから .streamToolCallResponses(…) への呼び出しをすべて削除してください。
// Before
var advisor = ToolCallingAdvisor.builder()
.streamToolCallResponses(true) // <-- remove this line
.build();
// After
var advisor = ToolCallingAdvisor.builder().build(); ツール呼び出しループの各反復を可視化するには(これは streamToolCallResponses=true が対処することを意図したユースケースです)、自動登録されたアドバイザーを無効にして、AdvisorParams.toolCallingAdvisorAutoRegister(false) を使用してループを手動で実行します。
ToolCallingManager toolCallingManager = ToolCallingManager.builder().build();
ToolCallback[] tools = ToolCallbacks.from(new WeatherTools());
ChatOptions chatOptions = ToolCallingChatOptions.builder()
.toolCallbacks(tools)
.build();
String question = "What is the weather in Amsterdam and Paris?";
Prompt prompt = new Prompt(List.of(new UserMessage(question)), chatOptions);
ChatClientResponse response = chatClient.prompt()
.user(question)
.options(chatOptions)
.advisors(AdvisorParams.toolCallingAdvisorAutoRegister(false))
.call()
.chatClientResponse();
while (response.chatResponse() != null && response.chatResponse().hasToolCalls()) {
// inspect or forward the tool-call chunk here before executing
ToolExecutionResult result = toolCallingManager.executeToolCalls(prompt, response.chatResponse());
prompt = new Prompt(result.conversationHistory(), chatOptions);
response = chatClient.prompt()
.messages(result.conversationHistory())
.options(chatOptions)
.advisors(AdvisorParams.toolCallingAdvisorAutoRegister(false))
.call()
.chatClientResponse();
}
// forward or process the final answer hereストリーミングパスを含む完全な例については、ユーザー制御ツールの実行 — ChatClient 付を参照してください。
除去: ChatModel における内部ツール実行ループ
Spring AI 1.x では、すべての ChatModel 実装に独自の内部ツール実行ループが含まれていました。ツールを指定して chatModel.call(prompt) を呼び出すと、レスポンス内のツール呼び出しが実行され、モデルが自動的に再呼び出しされ、モデルがツール呼び出し以外のレスポンスを生成するまでループが繰り返されました。
2.0 では、この内部ループはすべての ChatModel 実装(OpenAI、Anthropic、Ollama、DeepSeek、Bedrock、MiniMax、Mistral、Google GenAI)から削除されました。ChatModel.call(prompt) と ChatModel.stream(prompt) はモデルの生のレスポンスを返すようになり、ツール呼び出しは自動的に実行されなくなりました。
マイグレーション
ほとんどのアプリケーションでは、ChatClient に切り替えてください。自動登録された ToolCallingAdvisor がループ処理を実行します。
ChatClient.create(chatModel)
.prompt(question)
.tools(new MyTools())
.call()
.content();ChatModel を直接使用する必要がある場合(カスタムオーケストレーター、インフラストラクチャコードなど)、ToolCallingManager を使用してループを手動で駆動してください。ChatModel ツール呼び出し: ループを手動で運転するを参照してください。
除去: SpringBeanToolCallbackResolver および toolNames()
SpringBeanToolCallbackResolver および toolNames() API(Function/Supplier/Consumer のベアビーンから名前でツールを解決する機能)は削除されました。ツールは、明示的な ToolCallback インスタンスまたは @Tool アノテーション付きオブジェクトとして登録する必要があります。
マイグレーション
ToolCallback Bean を直接宣言します(関数スタイルのツールの場合は、FunctionToolCallback.builder() を使用します)。
// Before (1.x) — bare Function bean resolved by name
@Bean
@Description("Get the weather in location")
Function<WeatherRequest, WeatherResponse> currentWeather() {
return weatherService::getWeather;
}
chatClient.prompt().toolNames("currentWeather"); // no longer exists
// After (2.0) — explicit ToolCallback bean
@Bean
ToolCallback currentWeather() {
return FunctionToolCallback.builder("currentWeather", weatherService::getWeather)
.description("Get the weather in location")
.inputType(WeatherRequest.class)
.build();
}
@Autowired ToolCallback currentWeather;
chatClient.prompt()
.user("What's the weather in Copenhagen?")
.tools(currentWeather)
.call()
.content(); メソッドベースのツールも @Tool で宣言できます。
class WeatherTools {
@Tool(description = "Get the weather in location")
WeatherResponse currentWeather(WeatherRequest request) {
return weatherService.getWeather(request);
}
}
chatClient.prompt().tools(new WeatherTools()).call().content(); 名前変更: ToolCallAdvisor → ToolCallingAdvisor
再帰的なツール呼び出しアドバイザークラスの名前が、より分かりやすくするために変更されました。ToolCallAdvisor を直接参照していた場合(たとえば、カスタムインスタンスを登録したり、ToolCallAdvisor を継承したりした場合)、参照先を ToolCallingAdvisor に更新してください。
// Before (1.x)
var advisor = ToolCallAdvisor.builder()...;
// After (2.0)
var advisor = ToolCallingAdvisor.builder()...; 名前変更: FunctionCallback API → ToolCallback API
Spring AI 1.0 では、旧バージョンの FunctionCallback API に代わるものとして ToolCallback が導入されました。2.0 では、非推奨となった FunctionCallback の型とメソッドが完全に削除されました。用語も統一され、「ツール」という用語が至るところで使われ、「関数」という用語は一切使われなくなりました。
旧バージョンの FunctionCallback API を使用していたバージョンからアップグレードする場合:
| 前 (既存) | 後 (2.0) |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
例:
// Before — function-style callback
FunctionCallback.builder()
.function("getCurrentWeather", new MockWeatherService())
.description("Get the weather in location")
.inputType(MockWeatherService.Request.class)
.build();
// After — explicit ToolCallback via FunctionToolCallback
FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
.description("Get the weather in location")
.inputType(MockWeatherService.Request.class)
.build();// Before — defaultFunctions in builder
ChatClient.builder(chatModel)
.defaultFunctions(
FunctionCallback.builder()
.function("WeatherInfo", new MockWeatherService())
.description("Get the current weather")
.inputType(MockWeatherService.Request.class)
.build())
.build();
// After — defaultTools in builder
ChatClient.builder(chatModel)
.defaultTools(
FunctionToolCallback.builder("WeatherInfo", new MockWeatherService())
.description("Get the current weather")
.inputType(MockWeatherService.Request.class)
.build())
.build();// Before — per-call functions()
chatClient.prompt()
.user("...")
.functions(callback)
.call();
// After — per-call tools()
chatClient.prompt()
.user("...")
.tools(callback)
.call(); 新しいコードの場合は、宣言的な @Tool アノテーションを使用することをお勧めします。定義ツールを参照してください。
JDBC チャットメモリ sequence_id 列
JdbcChatMemoryRepository スキーマでは、会話内のメッセージの順序を決定する sequence_id BIGINT 列が追加されます。以前は、順序は timestamp 列に依存していましたが、TIMESTAMP の精度はデータベースによって異なり、MySQL と MariaDB ではデフォルトの精度が 1 秒であるため、同じ秒内に保存されたメッセージは非決定的な順序で返されていました。専用の整数シーケンスを使用することで、サポートされているすべてのデータベースで同じ順序でメッセージが処理されます。
timestamp 列は保持されます。この列にはメッセージの作成時刻が格納され、JdbcChatMemoryRepository.CONVERSATION_TS キー(java.time.Instant)のメッセージメタデータに公開されるため、アプリケーションはメッセージの作成日時を表示できます。タイムスタンプは保存後も保持されます。会話を再保存しても、既存の各メッセージの元の作成時刻が保持されます。
インパクト
SPRING_AI_CHAT_MEMORYテーブルには、sequence_id列(Oracle ではBIGINTまたはNUMBER(19)、SQLite ではINTEGER)とSPRING_AI_CHAT_MEMORY_CONVERSATION_ID_SEQUENCE_ID_IDXインデックスが追加されます。timestamp列とそのインデックスは変更されません。Spring AI 1.x によって作成された既存のテーブルは、メッセージが
sequence_idで順序付けられるようになったため、機能するには新しい列が必要です。リポジトリから読み取られたメッセージには、メタデータに作成日時が記録されるようになりました。メタデータが異なるため、取得したメッセージは、コード内で作成された同一のメッセージと等しくありません(
Message.equals)。値によってメッセージを比較するコード、またはセットやマップ内でメッセージの同一性に依存するコードは、この点を考慮する必要があります。
マイグレーション
変化は加算的である: 新しい列を追加し、既存の会話ごとの順序からバックフィルします。データは失われず、timestamp 列は変更されません。PostgreSQL の場合:
ALTER TABLE SPRING_AI_CHAT_MEMORY ADD COLUMN sequence_id BIGINT;
WITH ordered AS (
SELECT ctid, ROW_NUMBER() OVER (PARTITION BY conversation_id ORDER BY "timestamp") - 1 AS seq
FROM SPRING_AI_CHAT_MEMORY
)
UPDATE SPRING_AI_CHAT_MEMORY t
SET sequence_id = o.seq
FROM ordered o
WHERE t.ctid = o.ctid;
ALTER TABLE SPRING_AI_CHAT_MEMORY ALTER COLUMN sequence_id SET NOT NULL;
CREATE INDEX SPRING_AI_CHAT_MEMORY_CONVERSATION_ID_SEQUENCE_ID_IDX
ON SPRING_AI_CHAT_MEMORY(conversation_id, sequence_id); 識別子の引用と行識別子式(上記の ctid)を、ご使用のデータベースに合わせて調整してください。ROW_NUMBER() OVER (PARTITION BY conversation_id ORDER BY <timestamp>) パターンは、サポートされているすべてのエンジンで、既存の会話ごとの順序を再現します。あるいは、チャットメモリには永続的な履歴ではなく、最近の会話のコンテキストが保持されるため、更新された schema-<platform>.sql スクリプトからテーブルを削除して再作成することもできます。
オプションの不変性とデフォルト値
オプションの厳密な不変性
オプションクラス(ChatOptions、EmbeddingOptions など)は、完全に不変になりました。オプション内のコレクション(toolCallbacks、stopSequences、customHeaders など)は、変更不可能なコレクションとして格納されます。さらに、値がない状態をより適切に表現するために、空のコレクションの代わりに null 許容コレクションが使用されるようになりました。
デフォルト値がオプションコンストラクターに移動されました
オプションのデフォルト値(デフォルトのモデル名、温度など)は、Model の実装および *Properties の設定クラスから、オプションのコンストラクター自体に移動されました。*Properties クラスのデフォルト設定プロパティは不要になったため削除され、オプションレベルのデフォルト値と整合性が取れるようになりました。
構成プロパティのフラット化
上記で説明したチャット設定の変更に基づき、その他のすべてのモデル(埋め込み、イメージ、音声、モデレーション、OCR など)の設定プロパティでは、.options プレフィックスは使用されなくなりました。例: 以前の spring.ai.openai.embedding.options.model は、spring.ai.openai.embedding.model に変更されました。.options バリアントには、よりスムーズな移行を実現するために、非推奨の設定プロパティが提供されています。
インパクト
*PropertiesクラスのgetOptions()メソッドは非推奨です。*Properties内にネストされたOptionsクラスは非推奨です。toOptions()メソッドは、ネストされたOptionsクラスからルートクラスである*Propertiesクラスに移動されました。
マイグレーション
application.properties または application.yml を更新して、プロパティキーから .options セグメントを削除してください。
# Before
spring.ai.openai.embedding.options.model=text-embedding-3-small
# After
spring.ai.openai.embedding.model=text-embedding-3-smallJava コードでは、ルートプロパティクラスを直接使用してオプションにアクセスするか、toOptions() を呼び出します。
// Before
String model = properties.getOptions().getModel();
OpenAiEmbeddingOptions options = properties.getOptions().toOptions();
// After
String model = properties.getModel();
OpenAiEmbeddingOptions options = properties.toOptions();Ollama
名前変更: spring.ai.ollama.chat.think-option から spring.ai.ollama.chat.think
spring.ai.ollama.chat.think-option 構成プロパティは spring.ai.ollama.chat.think に名称変更されました。
application.properties または application.yml を適切にアップデートしてください。
# Before
spring.ai.ollama.chat.think-option=true
# After
spring.ai.ollama.chat.think=trueMinimax 専用サポートは Anthropic サポートに置き換えられました
Minimax 専用サポートは、ミニマックス自身 (英語) の推奨に従い、Anthropic サポートを使用するように変更されました。代わりに、https://api.minimax.io/anthropic ベース URL と MiniMax モデルを使用して、Spring AI および Anthropic サポートをご利用ください。埋め込み機能はサポートされなくなりました。
JSON ユーティリティリファクタリング
新規: JsonHelper とアップデートされた JacksonUtils
spring-ai-commons では、JSON の直列化と逆直列化を実行するための標準的な方法として、新しい JsonHelper クラスが導入されました。このクラスはインスタンス化可能で、カスタムの JsonMapper を受け入れるため、ユースケースごとに JSON の動作を簡単にカスタマイズできます。JacksonUtils には、共有の事前設定済み JsonMapper インスタンスを返す新しい静的メソッド getDefaultJsonMapper() が追加されました。
JsonHelper は、これまで JsonParser、ModelOptionsUtils、McpJsonParser に分散していた JSON 操作を一元化します。デフォルトのコンストラクターは、JacksonUtils.getDefaultJsonMapper() の共有マッパーを使用します。異なるシリアライゼーション設定が必要な場合は、カスタムの JsonMapper を挿入してください。
// Default — uses the shared JsonMapper from JacksonUtils
JsonHelper jsonHelper = new JsonHelper();
// Custom — supply your own JsonMapper
JsonMapper myMapper = JsonMapper.builder()
.addModule(new JavaTimeModule())
.build();
JsonHelper customHelper = new JsonHelper(myMapper); 非推奨: JsonParser
JsonParser (org.springframework.ai.util.json 内)は非推奨となり、削除予定です。すべてのメソッドは JsonHelper に処理を委譲するようになりました。
マイグレーション
| 前 | 後 |
|---|---|
|
|
|
|
|
|
|
|
|
|
除去: ModelOptionsUtils の JSON メソッド
モデルオプションが Jackson に直接依存しなくなったため、ModelOptionsUtils の以下のメンバーが削除されました。
| メンバーを削除しました | 置換文字列 |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
マイグレーション
// Before
import org.springframework.ai.model.ModelOptionsUtils;
Map<String, Object> map = ModelOptionsUtils.jsonToMap(jsonString);
String json = ModelOptionsUtils.toJsonString(myObject);
JsonMapper mapper = ModelOptionsUtils.JSON_MAPPER;
// After
import org.springframework.ai.util.JsonHelper;
import org.springframework.ai.util.JacksonUtils;
private static final JsonHelper jsonHelper = new JsonHelper();
Map<String, Object> map = jsonHelper.fromJsonToMap(jsonString);
String json = jsonHelper.toJson(myObject);
JsonMapper mapper = JacksonUtils.getDefaultJsonMapper();MCP 誘発 API: TypeReference は ParameterizedTypeReference に置き換えられました
以前は McpAsyncRequestContext および McpSyncRequestContext で tools.jackson.core.type.TypeReference<T> を受け入れていた elicit(…) オーバーロードは、現在 org.springframework.core.ParameterizedTypeReference<T> を受け入れるようになりました。
インパクト
これらのメソッドを Jackson TypeReference で呼び出すコードはコンパイルに失敗します。
影響を受けるメソッドのシグネチャー:
McpAsyncRequestContext.elicit(TypeReference<T>)McpAsyncRequestContext.elicit(Consumer<ElicitationSpec>, TypeReference<T>)McpSyncRequestContext.elicit(TypeReference<T>)McpSyncRequestContext.elicit(Consumer<ElicitationSpec>, TypeReference<T>)
マイグレーション
Jackson TypeReference 匿名クラスを Spring ParameterizedTypeReference 匿名クラスに置き換えてください。
// Before
import tools.jackson.core.type.TypeReference;
Mono<StructuredElicitResult<Map<String, Object>>> result =
context.elicit(e -> e.message("Please fill in the form"),
new TypeReference<Map<String, Object>>() {});
// After
import org.springframework.core.ParameterizedTypeReference;
Mono<StructuredElicitResult<Map<String, Object>>> result =
context.elicit(e -> e.message("Please fill in the form"),
new ParameterizedTypeReference<Map<String, Object>>() {});McpSyncRequestContext にも同じ変更が適用されます。
// Before
StructuredElicitResult<Person> result =
context.elicit(e -> e.message("Provide your details"),
new TypeReference<Person>() {});
// After
StructuredElicitResult<Person> result =
context.elicit(e -> e.message("Provide your details"),
new ParameterizedTypeReference<Person>() {});Google GenAI 埋め込み: GoogleGenAiEmbeddingConnectionDetails パッケージの変更
GoogleGenAiEmbeddingConnectionDetails は org.springframework.ai.google.genai から org.springframework.ai.google.genai.embedding に移動されました。
ChatClient ツール呼び出し
自動 ToolCallingAdvisor 登録
ChatClient は、明示的に無効にしない限り、アドバイザーチェーンに ToolCallingAdvisor を常に自動登録するようになりました。そのため、モデルによってリクエストされたツール呼び出しは、ツールが静的に構成されているか、実行時に別のアドバイザーによって注入されたかに関わらず、自動的に処理されます。
インパクト
すでに ToolCallingAdvisor を明示的に追加している既存のコードでは、アドバイザーがチェーンに 2 回存在することになります。1 回は明示的な追加によるもので、もう 1 回は自動登録によるものです。
マイグレーション
チェーンから明示的な ToolCallingAdvisor を削除し、自動登録に任せましょう。カスタム構成が必要な場合は、ChatClient 構築時に事前構成済みの ToolCallingAdvisor.Builder を指定するか ( デフォルトの ToolCallingAdvisor をカスタマイズするのセクションを参照)、自動登録を無効にしてアドバイザーを手動で登録してください。
// Before — manual registration
chatClient.prompt("What's the weather?")
.tools(weatherTool)
.advisors(ToolCallingAdvisor.builder().build())
.call().content();
// After — auto-registration handles it; no explicit advisor needed
chatClient.prompt("What's the weather?")
.tools(weatherTool)
.call().content();
// Or, to keep full control, disable auto-registration explicitly
chatClient.prompt("What's the weather?")
.tools(weatherTool)
.advisors(
AdvisorParams.toolCallingAdvisorAutoRegister(false),
ToolCallingAdvisor.builder().build()
)
.call().content(); 新規: ToolAdvisor マーカーインターフェース
ToolAdvisor マーカーインターフェースが追加されました。ToolCallingAdvisor はこのインターフェースを実装しています。DefaultChatClient はこのマーカーをチェックして、ToolCallingAdvisor を自動登録するかどうかを決定します。チェーン内のいずれかのアドバイザーがすでに ToolAdvisor を実装している場合は、自動登録はスキップされます。
ツール呼び出しのライフサイクルを管理するカスタムアドバイザーは、ToolCallingAdvisor が重複して自動的に追加されないように、ToolAdvisor を実装する必要があります。
新規: MemoryAdvisor マーカーインターフェース
MemoryAdvisor マーカーインターフェースが追加されました。BaseChatMemoryAdvisor はこのインターフェースを継承します。DefaultChatClient はこのマーカーを使用して下流のメモリアドバイザーを検出し、存在する場合は ` ToolCallingAdvisor の内部会話履歴を無効にします。
BaseChatMemoryAdvisor を継承しないが、ツール呼び出しの自動登録ロジックと統合する必要があるカスタムメモリアドバイザーは、MemoryAdvisor を実装する必要があります。
新規: カスタム ToolCallingAdvisor 構成のための ChatClient.builder() オーバーロード
新しい 5 引数 ChatClient.builder() 静的メソッドと、それに対応する DefaultChatClientBuilder コンストラクターは、自動登録中に使用されるアドバイザーを設定するために ToolCallingAdvisor.Builder<?> を受け取ります。
ChatClient chatClient = ChatClient
.builder(chatModel, observationRegistry, null, null,
ToolCallingAdvisor.builder().toolCallingManager(myToolCallingManager))
.build();Spring Boot ユーザーは、代わりに以下のいずれかを選択してください。
spring.ai.chat.client.tool-calling.advisor-orderを設定して、チェーンにおけるアドバイザーの位置を制御します。自動構成されたビルダーを完全に置き換えるために、
ToolCallingAdvisor.Builder<?>Bean を宣言します (@ConditionalOnMissingBeanによって抑制されます)。
除去: ChatClient 上の ToolSpec コンシューマー API
tools(Consumer<ToolSpec>) / defaultTools(Consumer<ToolSpec>) API および ChatClient.ToolSpec インターフェースは削除されました。tools(Object…) / defaultTools(Object…) メソッドは、ToolCallback、ToolCallbackProvider、@Tool アノテーションが付与された POJO インスタンス、およびこれらの型のコレクションまたは配列を直接受け入れるようになりました。コンテキストは、専用の toolContext() / defaultToolContext() メソッドを使用して別途設定されます。
マイグレーション
// Before
chatClient.prompt()
.tools(t -> t.callbacks(myCallback).context("tenantId", "acme"))
.call().content();
// After
chatClient.prompt()
.tools(myCallback)
.toolContext(Map.of("tenantId", "acme"))
.call().content();ChatClientRequestSpec 上の toolCallbacks() メソッドと ChatClient.Builder 上の defaultToolCallbacks() メソッドは、tools(Object…) / defaultTools(Object…) に置き換えられたため、非推奨となりました。
変更: MethodToolCallbackProvider は IllegalStateException の代わりに IllegalArgumentException をスローする
MethodToolCallbackProvider は、以下の 2 つのケースで IllegalArgumentException (IllegalStateException の代わりに) をスローするようになりました。
ツールオブジェクトに
@Toolアノテーション付きメソッドがない場合。複数のツールオブジェクトが、重複する名前のコールバックを生成する場合。
除去: Spring Bean ツールの解決 (SpringBeanToolCallbackResolver)
SpringBeanToolCallbackResolver と、裸の Function / Supplier / Consumer Bean を宣言し、toolNames() を介して名前で参照するパターンは削除されました。toolNames() メソッドは、すべてのチャットオプションクラスと ChatClient から削除されました。
マイグレーション
生の関数型ビーンではなく、ToolCallback ビーンを直接宣言します。
// Before — bare Function bean resolved by name at runtime
@Bean
@Description("Get the weather in location")
Function<WeatherRequest, WeatherResponse> currentWeather() {
return weatherService::getWeather;
}
// After — explicit ToolCallback bean
@Bean
ToolCallback currentWeather() {
return FunctionToolCallback.builder("currentWeather", weatherService::getWeather)
.description("Get the weather in location")
.inputType(WeatherRequest.class)
.build();
} 次に、Bean を tools() に直接登録します。
chatClient.prompt("What's the weather like in Copenhagen?")
.tools(currentWeather)
.call().content(); あるいは、宣言的なアプローチには、@Tool アノテーション付きメソッドを使用してください(ツール API を参照)。
クラウドバインディング
github.com/spring-cloud/spring-cloud-bindings (英語) との統合機能を提供していた spring-ai-spring-cloud-bindings モジュールは削除されました。
BeanOutputConverter JSON スキーマ生成
BeanOutputConverter は JSON スキーマの生成を JsonSchemaGenerator に委譲するようになり、構造化出力の変換がツール呼び出しに使用される JSON スキーマの動作と一致するようになりました。
インパクト
プライマリコンストラクターでオプションである(null 許容またはデフォルト値で宣言されている)Kotlin プロパティは、JSON スキーマ
required配列に含まれなくなりました。@JsonProperty(required = false)でアノテーションが付けられたプロパティ(requiredが指定されていない@JsonProperty宣言を含む)は、必須プロパティとして扱われなくなりました。生成されるスキーマには、ツール呼び出しで使用されるフォーマット規則に一致する、プリミティブ型に対する OpenAPI スタイルの
formatヒント (例:intの場合はint32、longの場合はint64、LocalDateTimeの場合はdate-time) が含まれるようになりました。BeanOutputConverter.postProcessSchema(JsonNode)拡張ポイントは削除されました。このメソッドをオーバーライドするカスタムサブクラスはコンパイルエラーになります。
マイグレーション
JSON スキーマの生成をカスタマイズするには、代わりに BeanOutputConverter.generateSchema() をオーバーライドしてください。サブクラスは、super.generateSchema() に処理を委譲することで、デフォルトのスキーマを後処理できます。
// Before
class CustomConverter extends BeanOutputConverter<MyType> {
CustomConverter() {
super(MyType.class);
}
@Override
protected void postProcessSchema(JsonNode schema) {
// mutate schema
}
}
// After
class CustomConverter extends BeanOutputConverter<MyType> {
CustomConverter() {
super(MyType.class);
}
@Override
protected String generateSchema() {
String schema = super.generateSchema();
// post-process schema
return schema;
}
}Azure Cosmos DB サポート
Azure Cosmos DB ベクトルストア (spring-ai-azure-cosmos-db-store) およびチャットメモリリポジトリ (spring-ai-model-chat-memory-repository-cosmos-db) モジュールは、対応する自動構成とスターターとともに、Spring AI プロジェクトから削除されました。
Azure Cosmos DB のサポートが、Azure Cosmos DB チームによって保守される外部モジュールとして利用可能になりました。ドキュメントと依存関係については、azurecosmosdb.github.io/spring-ai/docs/index.html (英語) を参照してください。
MCP SDK の互換性のない変更点: 必須フィールド
MCP SDK は、コンパクトレコードコンストラクターにおいて、Assert.notNull() を介して、これまでオプションであったフィールドを構築時に必須フィールドとして強制します。
速報: CreateMessageResult — model が必要になりました
// Before
CreateMessageResult.builder()
.content(TextContent.builder(response).build())
.build();
// After
CreateMessageResult.builder(Role.ASSISTANT, response, modelHint)
.build(); 速報: CreateMessageRequest — maxTokens が必要になりました
// Before
CreateMessageRequest.builder()
.messages(messages)
.build();
// After
CreateMessageRequest.builder(messages, 500)
.build();非推奨のビルダー API
以下の引数なしコンストラクターおよび builder() メソッドは非推奨となり、代わりに必須引数を事前に必要とするファクトリメソッドが推奨されます。
| 非推奨 | 置換文字列 |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
可観測性
ツール呼び出し
ツール呼び出し操作に関して生成された観測値は、以下のように変更されました。
span 名は
tool_call <tool-name>ではなくexecute_tool <tool-name>です。メトリクス / スパン属性
gen_ai.operation.nameの値は、frameworkではなくexecute_toolです。ツール型(例:
function)をキャプチャーするための新しいspring.ai.tool.typeメトリクス / スパン属性が導入されました。チャットモデルによって識別されるツール呼び出し ID をキャプチャーするために、新しい
spring.ai.tool.call.idスパン属性が導入されました。
チャットメモリアドバイザー: 会話 ID が必須になりました
組み込みメモリアドバイザー(MessageChatMemoryAdvisor および VectorStoreChatMemoryAdvisor)では、会話 ID は必須となりました。これらのアドバイザーを介したすべての呼び出しにおいて、アドバイザーコンテキストを介して ChatMemory.CONVERSATION_ID を指定する必要があります。値が指定されていない場合、または null が指定されている場合は、アドバイザーは直ちに IllegalArgumentException 例外をスローします。
除去: ChatMemory.DEFAULT_CONVERSATION_ID
定数 ChatMemory.DEFAULT_CONVERSATION_ID (値 "default")は、ChatMemory インターフェースから削除されました。
除去: メモリアドバイザーにおける .conversationId() ビルダーメソッド
.conversationId(String) ビルダーメソッドは、MessageChatMemoryAdvisor.Builder および VectorStoreChatMemoryAdvisor.Builder から削除されました。構築時にデフォルトの会話 ID を設定する機能はサポートされなくなりました。
マイグレーション
.conversationId() ビルダー呼び出しを削除し、ChatMemory.CONVERSATION_ID を使用してアドバイザーコンテキストを介して呼び出し時に常に会話 ID を提供するようにしてください。
// Before
ChatClient chatClient = ChatClient.builder(chatModel)
.defaultAdvisors(MessageChatMemoryAdvisor.builder(chatMemory)
.conversationId("my-session")
.build())
.build();
chatClient.prompt()
.user("Hello!")
.call()
.content();
// After
ChatClient chatClient = ChatClient.builder(chatModel)
.defaultAdvisors(MessageChatMemoryAdvisor.builder(chatMemory).build())
.build();
chatClient.prompt()
.user("Hello!")
.advisors(a -> a.param(ChatMemory.CONVERSATION_ID, "my-session"))
.call()
.content(); 除去: PromptChatMemoryAdvisor
PromptChatMemoryAdvisor は削除されました。代わりに MessageChatMemoryAdvisor を使用してください。
マイグレーション
PromptChatMemoryAdvisor を MessageChatMemoryAdvisor に置き換えてください。ビルダー API は同じです。MessageChatMemoryAdvisor は、メモリをプレーンテキストとしてシステムプロンプトに挿入する代わりに、会話履歴をチャットメッセージとしてプロンプトに直接含めます。
// Before
ChatClient chatClient = ChatClient.builder(chatModel)
.defaultAdvisors(PromptChatMemoryAdvisor.builder(chatMemory).build())
.build();
// After
ChatClient chatClient = ChatClient.builder(chatModel)
.defaultAdvisors(MessageChatMemoryAdvisor.builder(chatMemory).build())
.build();ChatClient オプションにはビルダーが必要になりました
ChatClient を使用する場合、.options() / .defaultOptions() メソッドは、完全に構築された ChatOptions インスタンスではなく、ChatOptions.Builder (またはプロバイダ固有のビルダーサブ型) を受け入れるようになりました。この変更は、メソッドの汎用型制約 <B extends ChatOptions.Builder<?>> によってコンパイル時に強制されます。
オプションビルダーは、最初のアドバイザーが呼び出される前にモデルのデフォルトオプションとマージされるため、明示的に設定したフィールドのみがデフォルト設定を上書きします。
// Before — passing a built ChatOptions instance (no longer compiles with ChatClient)
ChatOptions opts = AnthropicChatOptions.builder()
.maxTokens(100)
.temperature(0.7)
.build();
String response = chatClient.prompt("Tell me a joke")
.options(opts)
.call().content();
// After — pass the builder directly
String response = chatClient.prompt("Tell me a joke")
.options(AnthropicChatOptions.builder()
.maxTokens(100)
.temperature(0.7))
.call().content(); この制限は ChatClient にのみ適用されます。ChatModel.call(Prompt) を直接呼び出す場合、プロンプトにはモデルが想定する具象型の完全に構築された ChatOptions インスタンス ( 例 : AnthropicChatModel の場合は AnthropicChatOptions ) が含まれている必要があります。ChatModel はオプションをマージしません。Prompt.getOptions() が null でない場合はそのまま使用され、null の場合はモデル独自のデフォルトオプションが代わりに使用されます。ChatModel レベルでは部分的なマージは行われません。 |
OpenAI Java SDK 移行
Spring AI は、spring-ai-openai モジュール内のすべての OpenAI モデル(チャット、埋め込み、イメージ、音声、音声文字起こし、モデレーション)において、内部的に公式の openai-java SDK を使用するようになりました。
移行はスムーズに行われ、spring-ai-openai モジュールの既存ユーザーにとって大きな互換性の問題は発生しない見込みです。すべてのプロパティ(spring.ai.openai.* プレフィックス付き)、ビルダー、オプションは完全にそのまま維持されます。既存の extraBody 構成パラメーターは、openai-java SDK の基盤となる additionalBodyProperties に透過的にマッピングされます。
spring-ai-azure-openai モジュールの取り外し
spring-ai-azure-openai モジュール(およびそれに関連する Spring Boot スターター spring-ai-starter-model-azure-openai と自動構成 spring-ai-autoconfigure-model-azure-openai)は Spring AI から削除されました。
既存のユーザーは、代わりに spring-ai-openai モジュール(および関連するスターターと自動構成)を使用し、クラス名(たとえば Azure の接頭辞を削除するなど)と構成プロパティをそれに応じて変更する必要があります。
spring-ai-openai-sdk モジュールの取り外し
spring-ai-openai-sdk モジュール(およびそれに関連する Spring Boot スターター spring-ai-starter-model-openai-sdk と自動構成 spring-ai-autoconfigure-model-openai-sdk)は Spring AI から削除されました。
既存のユーザーは、代わりに spring-ai-openai モジュール(および関連するスターターと自動構成)を使用し、クラス名(たとえば Sdk サフィックスを削除するなど)と構成プロパティを適切に調整してください。
spring-ai-oci-genai モジュールの取り外し
関連モジュールは現在、github.com/oracle/spring-cloud-oracle/tree/main/spring-ai-oracle (英語) で入手できます。
MCP Java SDK が 2.0.0 にアップグレードされました
Spring AI 2.0.0 では、MCP Java SDK が 1.1.x から 2.0.0 にアップグレードされます。このリリースでは、SDK レベルでいくつかの互換性のない変更が導入されており、MCP 型と直接やり取りするアプリケーションに影響を与える可能性があります。
サーバーサイドツールの入力検証はデフォルトで有効になっています
MCP サーバーは、ツールハンドラーを呼び出す前に、受信したツール引数をツールの JSON スキーマと照合して検証するようになりました。検証に失敗した場合は、CallToolResult と isError=true、および詳細なエラーメッセージが表示されます。
マイグレーション
ツール定義に正確な JSON スキーマが含まれていること、およびすべてのクライアントが準拠した引数を送信していることを確認してください。検証を無効にして 2.0 より前の動作に戻すには、サーバービルダーで validateToolInputs(false) を設定してください。
McpServer.sync(transportProvider)
.validateToolInputs(false)
.tool(myTool, handler)
.build();@McpTool アノテーションを使用すると、Spring AI はメソッドパラメーターから JSON スキーマを自動的に生成します。これらのスキーマは組み込みのバリデーターと互換性があり、追加の操作は必要ありません。 |
Tool.inputSchema が JsonSchema から Map<String, Object> に変更されました
McpSchema.Tool.inputSchema() (および outputSchema())は、以前の JsonSchema レコードの代わりに Map<String, Object> を返すようになりました。これにより、任意の JSON スキーマダイアレクトキーワード($ref、unevaluatedProperties、ベンダー拡張機能)がトリミングされることなく往復できるようになります。
マイグレーション
Map<String, Object> に切り替える:
// Before
McpSchema.JsonSchema schema = tool.inputSchema();
// After
Map<String, Object> schema = tool.inputSchema();McpSchema.Tool.Builder を介してツールを構築する場合、非推奨の inputSchema(JsonSchema) ヘルパーは後方互換性のために引き続き使用できますが、inputSchema(Map) または inputSchema(McpJsonMapper, String) の使用を推奨します。
@McpTool アノテーションまたは Spring AI の SyncMcpToolProvider / AsyncMcpToolProvider を使用するアプリケーションは影響を受けません。Spring AI が内部的にスキーマ生成を処理します。 |
Builder.customizeRequest() が HTTP クライアントトランスポートから削除されました
非推奨となった Builder.customizeRequest() メソッドは、HttpClientSseClientTransport.Builder および HttpClientStreamableHttpTransport.Builder から削除されました。
マイグレーション
customizeRequest() を httpRequestCustomizer() (同期)または asyncHttpRequestCustomizer() (非同期)に置き換えてください。
// Before
HttpClientSseClientTransport.builder(baseUrl)
.customizeRequest(req -> req.header("Authorization", "Bearer token"))
.build();
// After
HttpClientSseClientTransport.builder(baseUrl)
.httpRequestCustomizer(req -> req.header("Authorization", "Bearer token"))
.build(); すでに McpClientCustomizer<B> API に移行済みであれば、追加の操作は必要ありません。 |
シールされた MCP スキーマインターフェースが削除されました
以下のインターフェースはもはや sealed ではありません: McpSchema.JSONRPCMessage、McpSchema.Request、McpSchema.Result、McpSchema.Notification、McpSchema.ResourceContents、McpSchema.CompleteReference、McpSchema.Content。
マイグレーション
これらの型に対する網羅的な switch に default ブランチを追加します。
// Before (no default needed when McpSchema.Content was sealed)
String text = switch (content) {
case McpSchema.TextContent tc -> tc.text();
case McpSchema.ImageContent ic -> "[image]";
case McpSchema.EmbeddedResource er -> "[resource]";
};
// After
String text = switch (content) {
case McpSchema.TextContent tc -> tc.text();
case McpSchema.ImageContent ic -> "[image]";
case McpSchema.EmbeddedResource er -> "[resource]";
default -> throw new IllegalArgumentException("Unknown content type: " + content);
};| この変更は、アノテーションや Spring AI のより高レベルの抽象化を通じて MCP とやり取りするほとんどの Spring AI ユーザーに影響を与える可能性は低い。 |
Usage における統合キャッシュ使用状況メトリクス
org.springframework.ai.chat.metadata.Usage インターフェースに、getCacheReadInputTokens() と getCacheWriteInputTokens() という 2 つのデフォルトメソッドが追加されました。プロバイダが値を報告しない場合、どちらのメソッドも null を返します。
Anthropic、Bedrock Converse、OpenAI、Google GenAI は、それぞれキャッシュにデータを格納します。Anthropic と Bedrock は双方向で、OpenAI と Google はキャッシュ読み取り専用です。
これらの数値をネイティブ型にキャストしたり、プロバイダ固有のメタデータキーを読み取ったりするコードは、インターフェースメソッドに切り替えることができます。例については、プロンプトキャッシュ使用状況メトリクスを参照してください。
Anthropic モジュール
spring-ai-anthropic は、以前のように独自に開発した RestClient / WebClient の実装ではなく、com.anthropic:anthropic-java をベースに構築されるようになりました。
ほとんどのアプリケーションにとって、この変更は透過的です。Maven アーティファクト、spring.ai.anthropic.* 構成、AnthropicChatModel / AnthropicChatOptions / ChatClient API は維持され、ChatClient または ChatModel.call(Prompt) を経由するコードは更新する必要がありません。
org.springframework.ai.anthropic.api からインポートしたコード、AnthropicApi 引数を使用して AnthropicChatModel を構築したコード、古い maxTokens のデフォルト値に依存しているコードは、注意が必要です。
インパクト
org.springframework.ai.anthropic.api.AnthropicApiおよびそのネストされたレコード型 (ChatCompletionRequest、ContentBlock、Tool、ToolChoice*、ストリーミングイベントレコード) はすべて削除されました。これらを参照するコードはコンパイルできません。公開コンストラクター
AnthropicChatModel(AnthropicApi, AnthropicChatOptions, …)は廃止されました。AnthropicChatModel.builder()を使用してください。AnthropicChatOptions#maxTokensは、500ではなく4096にデフォルト設定されます。以前の上限に達したレスポンスは、処理時間が長くなり、それに伴ってトークンの使用量も増加します。AnthropicCacheOptions、AnthropicCacheStrategy、AnthropicCacheTtl、CacheBreakpointTracker、CacheEligibilityResolverはapi(およびapi.utils)からルートパッケージであるorg.springframework.ai.anthropicに移行しました。AnthropicCacheType、StreamHelper、metadata.AnthropicRateLimitは削除され、同等の SDK 型(CacheControlEphemeral、AsyncStreamResponse<RawMessageStreamEvent>、RateLimitException)が直接使用されます。CitationDocumentはAnthropicCitationDocumentに名称変更されました。com.anthropic:anthropic-javaは推移的にcom.squareup.okhttp3:okhttpをクラスパスに追加します。
マイグレーション
移動したキャッシュクラスと引用クラスのインポートを更新します。
| 前 | 後 |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
AnthropicCacheStrategy (NONE、TOOLS_ONLY、SYSTEM_ONLY、SYSTEM_AND_TOOLS、CONVERSATION_HISTORY) と AnthropicCacheTtl (FIVE_MINUTES、ONE_HOUR) は同じ列挙値を保持します。
コンストラクターを直接使用する代わりに、ビルダーを使用してください。
// Before
AnthropicApi anthropicApi = new AnthropicApi(apiKey);
AnthropicChatModel chatModel = new AnthropicChatModel(anthropicApi, options);
// After
AnthropicChatModel chatModel = AnthropicChatModel.builder()
.apiKey(apiKey)
.defaultOptions(options)
.build();500 -token のデフォルト値を使用してコストを制限している場合は、明示的に設定してください。
AnthropicChatOptions.builder()
.maxTokens(500)
// ...
.build();残りは Anthropic モジュールを公式 Java SDK に移行するがカバーします: SDK への直接アクセス、ストリーミング動作、プロンプトのキャッシュ、引用、削除された型。
新しいチャットオプション
spring-ai-anthropic には、新たに 4 つのチャットオプションが追加されました。それぞれの詳細な説明は Anthropic チャットに記載されています。主な変更点は以下のとおりです。
| オプション | 追加されるもの |
|---|---|
思考表示 |
|
Service tier |
|
Built-in web search |
|
Inference geo |
|
If you are upgrading from 1.1.x (or 1.0.x), see Migrating the Anthropic Module to the Official Java SDK for the full RestClient → SDK transition guide.
|
MCP Annotations Migrated into Spring AI
The org.springaicommunity:mcp-annotations external library has been removed as a dependency of the mcp-annotations module.
Its classes are now part of Spring AI itself under a new package structure.
Impact
-
All MCP annotation and provider classes have new fully-qualified names.
-
The
org.springaicommunity:mcp-annotationsartifact is no longer provided transitively by Spring AI. -
Any code importing from
org.springaicommunity.mcp.*will fail to compile.
Package Rename
| Old Package | New Package |
|---|---|
|
|
|
|
|
|
マイグレーション
アプリケーションコード内のすべてのインポートを更新してください。
// Before
import org.springaicommunity.mcp.annotation.McpTool;
import org.springaicommunity.mcp.annotation.McpPrompt;
import org.springaicommunity.mcp.annotation.McpResource;
import org.springaicommunity.mcp.annotation.McpSampling;
import org.springaicommunity.mcp.provider.tool.SyncMcpToolProvider;
import org.springaicommunity.mcp.provider.prompt.AsyncMcpPromptProvider;
// After
import org.springframework.ai.mcp.annotation.McpTool;
import org.springframework.ai.mcp.annotation.McpPrompt;
import org.springframework.ai.mcp.annotation.McpResource;
import org.springframework.ai.mcp.annotation.McpSampling;
import org.springframework.ai.mcp.annotation.provider.tool.SyncMcpToolProvider;
import org.springframework.ai.mcp.annotation.provider.prompt.AsyncMcpPromptProvider;org.springaicommunity:mcp-annotations を Maven または Gradle の直接的な依存関係として宣言していた場合は、それを削除してください。これらのクラスは現在、Spring AI の spring-ai-mcp-annotations モジュールによって提供されています。
OpenRewrite による自動移行
提供されている OpenRewrite レシピを使用すれば、すべてのインポートと依存関係の変更を自動化できます。
コマンドラインから migrate-to-2-0-0-M3.yaml [GitHub] (英語) レシピを適用します。
mvn org.openrewrite.maven:rewrite-maven-plugin:6.32.0:run \
-Drewrite.configLocation=https://raw.githubusercontent.com/spring-projects/spring-ai/refs/heads/main/src/rewrite/migrate-to-2-0-0-M3.yaml \
-Drewrite.activeRecipes=org.springframework.ai.migration.M3MigrateMcpAnnotations \
-Dmaven.compiler.failOnError=falseこのレシピでは、以下の 2 つの変更が自動的に行われます。
除去は
org.springaicommunity:mcp-annotationsと Maven の依存関係にある。書き直しは、
.javaファイル全体にわたるすべてのimportステートメントを新しいorg.springframework.ai.mcp.annotation.*パッケージを指すように変更します。
すべての M3 移行を一度に実行するには、包括的 レシピを使用します。[run-all-m3-migrations] を参照してください。
MCP Spring 輸送モジュールが Spring AI に移動されました
mcp-spring-webflux および mcp-spring-webmvc トランスポートモジュールは、MCP Java SDK には同梱されなくなりました。Spring AI 2.0 以降、これらは Spring AI プロジェクト自体の一部となっています。
インパクト
両方のアーティファクトの Maven グループ ID が変更されました。
Spring 固有のトランスポートクラスすべてについて、Java パッケージ名が変更されました。
MCP Java SDK のバージョン要件が
0.18.xから1.0.xにプルアップられました。
Maven 依存グループ ID の変更
<dependency>
<groupId>io.modelcontextprotocol.sdk</groupId>
<artifactId>mcp-spring-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.modelcontextprotocol.sdk</groupId>
<artifactId>mcp-spring-webmvc</artifactId>
</dependency><dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>mcp-spring-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>mcp-spring-webmvc</artifactId>
</dependency>spring-ai-bom または Spring AI MCP スターター(spring-ai-starter-mcp-server-webflux、spring-ai-starter-mcp-server-webmvc、spring-ai-starter-mcp-client-webflux)を使用する場合、明示的なバージョン指定は不要です。BOM が自動的に管理します。 |
Java パッケージの再配置
Spring 固有のトランスポートクラスはすべて org.springframework.ai パッケージに移行しました。
| クラス | 古いパッケージ | 新規パッケージ |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| クラス | 古いパッケージ | 新規パッケージ |
|---|---|---|
|
|
|
|
|
|
マイグレーション
Java のインポートを更新してください。
// Before
import io.modelcontextprotocol.server.transport.WebFluxSseServerTransportProvider;
import io.modelcontextprotocol.server.transport.WebMvcSseServerTransportProvider;
import io.modelcontextprotocol.client.transport.WebFluxSseClientTransport;
import io.modelcontextprotocol.client.transport.WebClientStreamableHttpTransport;
// After
import org.springframework.ai.mcp.server.webflux.transport.WebFluxSseServerTransportProvider;
import org.springframework.ai.mcp.server.webmvc.transport.WebMvcSseServerTransportProvider;
import org.springframework.ai.mcp.client.webflux.transport.WebFluxSseClientTransport;
import org.springframework.ai.mcp.client.webflux.transport.WebClientStreamableHttpTransport;Spring AI スターターを介した Spring Boot の自動構成のみに依存する場合は、Java コードの変更は不要です。上記の説明に従って、pom.xml/build.gradle の依存関係座標を更新するだけで済みます。 |
MCP トランスポート移行に関する完全なリファレンスについては、Spring AI 2.0 へのアップグレードを参照してください。
OpenRewrite による自動移行
提供されている OpenRewrite レシピを使用すると、Maven のすべての依存関係と Java インポートの変更を自動化できます。
mvn org.openrewrite.maven:rewrite-maven-plugin:6.32.0:run \
-Drewrite.configLocation=https://raw.githubusercontent.com/spring-projects/spring-ai/refs/heads/main/src/rewrite/migrate-to-2-0-0-M3.yaml \
-Drewrite.activeRecipes=org.springframework.ai.migration.M3MigrateMcpSpringTransports \
-Dmaven.compiler.failOnError=false プロジェクトで明示的な <version> (BOM でバージョン管理される) を指定せずに io.modelcontextprotocol.sdk:mcp-spring-webflux または mcp-spring-webmvc を宣言した場合、Maven は pom.xml の解析を拒否し、レシピは実行されません。まずこれらのファイルを事前にパッチしてから、OpenRewrite を実行してください。 |
# Step 1 – patch the groupIds directly so Maven can load the modules
find . -name "pom.xml" -print0 \
| xargs -0 perl -i -0pe \
's{<groupId>io\.modelcontextprotocol\.sdk</groupId>(\s+)<artifactId>mcp-spring-webflux</artifactId>}{<groupId>org.springframework.ai</groupId>$1<artifactId>mcp-spring-webflux</artifactId>}g;
s{<groupId>io\.modelcontextprotocol\.sdk</groupId>(\s+)<artifactId>mcp-spring-webmvc</artifactId>}{<groupId>org.springframework.ai</groupId>$1<artifactId>mcp-spring-webmvc</artifactId>}g'
# Step 2 – run OpenRewrite to migrate Java imports and remaining POM changes
mvn org.openrewrite.maven:rewrite-maven-plugin:6.32.0:run \
-Drewrite.configLocation=https://raw.githubusercontent.com/spring-projects/spring-ai/refs/heads/main/src/rewrite/migrate-to-2-0-0-M3.yaml \
-Drewrite.activeRecipes=org.springframework.ai.migration.M3MigrateMcpSpringTransports \
-Dmaven.compiler.failOnError=falseすべての M3 移行を一度に実行するには、包括的 レシピを使用します。[run-all-m3-migrations] を参照してください。
MCP クライアントカスタマイザー API 統合版
McpAsyncClientCustomizer と McpSyncClientCustomizer は削除され、単一の汎用インターフェース McpClientCustomizer<B> に置き換えられました。
インパクト
McpAsyncClientCustomizerはもはや存在しません — Bean を実装するすべてのコードでコンパイルエラーが発生します。McpSyncClientCustomizerはもはや存在しません — Bean を実装するすべてのコードでコンパイルエラーが発生します。McpSyncClientConfigurerおよびMcpAsyncClientConfigurerコンストラクターは、従来の型固有のリストの代わりにList<McpClientCustomizer<…>>を受け入れるようになりました。HttpClient ベースのトランスポート自動構成 (
SseHttpClientTransportAutoConfiguration、StreamableHttpHttpClientTransportAutoConfiguration) では、SDK レベルのMcpSyncHttpClientRequestCustomizerおよびMcpAsyncHttpClientRequestCustomizerの Bean は適用されなくなりました。トランスポートレベルのカスタマイズは、それぞれMcpClientCustomizer<HttpClientSseClientTransport.Builder>およびMcpClientCustomizer<HttpClientStreamableHttpTransport.Builder>を介して行われるようになりました。
マイグレーション
必要な仕様またはビルダー型でパラメーター化された新しい汎用インターフェースを使用して、カスタマイザービーンを置き換えます。
// Before
@Bean
public McpSyncClientCustomizer mySyncCustomizer() {
return (name, spec) -> spec.requestTimeout(Duration.ofSeconds(30));
}
@Bean
public McpAsyncClientCustomizer myAsyncCustomizer() {
return (name, spec) -> spec.requestTimeout(Duration.ofSeconds(30));
}
// After
@Bean
public McpClientCustomizer<McpClient.SyncSpec> mySyncCustomizer() {
return (name, spec) -> spec.requestTimeout(Duration.ofSeconds(30));
}
@Bean
public McpClientCustomizer<McpClient.AsyncSpec> myAsyncCustomizer() {
return (name, spec) -> spec.requestTimeout(Duration.ofSeconds(30));
}HttpClient トランスポートのカスタマイズ(以前は McpSyncHttpClientRequestCustomizer / McpAsyncHttpClientRequestCustomizer 経由で行われていました):
// Before
@Bean
public McpSyncHttpClientRequestCustomizer myRequestCustomizer() {
return requestBuilder -> requestBuilder.header("Authorization", "Bearer token");
}
// After
@Bean
public McpClientCustomizer<HttpClientSseClientTransport.Builder> mySseTransportCustomizer() {
return (name, builder) -> builder.httpRequestCustomizer(
req -> req.header("Authorization", "Bearer token")
);
}OpenRewrite による自動移行
提供されている OpenRewrite レシピを使用すると、インポートと型変更を自動化できます。
mvn org.openrewrite.maven:rewrite-maven-plugin:6.32.0:run \
-Drewrite.configLocation=https://raw.githubusercontent.com/spring-projects/spring-ai/refs/heads/main/src/rewrite/migrate-to-2-0-0-M3.yaml \
-Drewrite.activeRecipes=org.springframework.ai.migration.M3MigrateMcpClientCustomizer \
-Dmaven.compiler.failOnError=falseこのレシピでは、以下の変更が自動的に実行されます。
置換は
McpAsyncClientCustomizerとMcpSyncClientCustomizerをMcpClientCustomizerと共にインポートし、必要なimport io.modelcontextprotocol.client.McpClient;を追加します。書き直し
implements McpAsyncClientCustomizerからimplements McpClientCustomizer<McpClient.AsyncSpec>へ。書き直し
implements McpSyncClientCustomizerからimplements McpClientCustomizer<McpClient.SyncSpec>へ。書き直し残りのすべての使用箇所 (戻り値の型、変数宣言、パラメーターの型)。
McpSyncHttpClientRequestCustomizer および McpAsyncHttpClientRequestCustomizer の Bean は、トランスポートの自動構成では適用されなくなりました。これらの Bean を McpClientCustomizer<TransportBuilder> に移行するには、手動での手順が必要です。ターゲットとなるビルダー型は、構成するトランスポート(SSE または Streamable HTTP)によって異なります。 |
すべての M3 移行を一度に実行するには、包括的 レシピを使用します。[run-all-m3-migrations] を参照してください。
MCP WebMvc トランスポートヘッダーを小文字に正規化
WebMvcSseServerTransportProvider、WebMvcStatelessServerTransport、WebMvcStreamableServerTransportProvider では、securityValidator.validateHeaders(headers) に渡される Map<String, List<String>> のヘッダー名はすべて小文字に正規化されています。
以前は、ヘッダー名は元の HTTP の大文字小文字のまま渡されていました(例: "Authorization"、"Content-Type")。現在は常に小文字になります(例: "authorization"、"content-type")。
インパクト
大文字と小文字を混在させた名前でヘッダーを検索するカスタム ServerTransportSecurityValidator 実装は、ヘッダーが見つからない場合でも警告なしにエラーを表示します。
マイグレーション
ServerTransportSecurityValidator のすべてのヘッダー名検索を小文字のキーを使用するように更新してください。
// Before
public void validateHeaders(Map<String, List<String>> headers) {
List<String> authHeader = headers.get("Authorization");
// ...
}
// After
public void validateHeaders(Map<String, List<String>> headers) {
List<String> authHeader = headers.get("authorization");
// ...
}ToolContext から会話履歴が削除されました
会話履歴は ToolContext に自動的に追加されなくなりました。TOOL_CALL_HISTORY 定数と getToolCallHistory() メソッドは ToolContext クラスから削除されました。
インパクト
ToolContext.TOOL_CALL_HISTORY定数はもう存在しませんToolContext.getToolCallHistory()法はもう存在しないToolContextでは会話履歴が自動的に入力されなくなりました
なぜこの変更が行われたのか?
メモリ効率 : 長時間の会話におけるメモリの際限のない増加を防ぎます
関心の分離 : ツールは、会話の状態を管理するのではなく、そのパラメーターに基づいて動作すべきです。
アーキテクチャの整合性 : 会話のコンテキストは、ツールの実行ではなく、アドバイザーのレベルに属します。
マイグレーション
アプリケーションで会話履歴管理が必要な場合は、ToolCallingAdvisor を使用してください。
ChatClient chatClient = ChatClient.builder()
.defaultAdvisors(
ToolCallingAdvisor.builder()
.conversationHistoryEnabled(true) // Full history (default)
.build()
)
.build();ToolCallingAdvisor の仕組み:
ToolCallingAdvisor はアドバイザーレベルで会話履歴を管理します。
conversationHistoryEnabled=true (default): 会話履歴全体が保持され、ツール呼び出しの繰り返し間で LLM に送信されるため、LLM は完全なコンテキストに基づいて結果を合成することができます。
conversationHistoryEnabled=false : LLM には最新のツールレスポンスのみが送信されます (ChatMemory アドバイザーが履歴を個別に管理する場合に便利です)
要点 : 会話履歴は、ツール自体ではなく、LLM が文脈を理解し、レスポンスを生成するために使用されます。ツールは、入力パラメーターと、ユーザーが明示的に指定したカスタムコンテキストのみを受け取ります。
ツールにおけるカスタムコンテキスト:
ToolContext は、アプリケーション固有のカスタムデータをツールに渡すために引き続き利用可能です。
ChatResponse response = chatClient.prompt()
.user("What's the weather in SF?")
.toolContext(Map.of("userId", "user123", "apiKey", "secret"))
.call()
.chatResponse();フロー例:
ユーザーが質問します: 「サンフランシスコとロサンゼルスの天気はどうですか?」
LLM はツール呼び出しをリクエストする:
getWeather(SF)およびgetWeather(LA)ツールはパラメーターのみを使用して実行されます (会話履歴なし)
ToolCallingAdvisor はツールの結果と会話履歴を収集します
LLM はアドバイザーから会話の文脈を受け取り、次のように要約します。「サンフランシスコの天気は華氏 72 度、ロサンゼルスの天気は華氏 85 度です」
LLM では、アドバイザーであるチェーンを通して会話全体を把握し、ToolContext を通しては把握しません。
モデル内部メソッドのアクセスレベルがプライベートに変更されました
モデルクラス内のすべての
internalCallおよびinternalStreamメソッドはprivateに変更されました。
マイグレーション
xxxModel.internalCallへのすべての呼び出しをxxxModel.callに置き換えます。xxxModel.internalStreamへのすべての呼び出しをxxxModel.streamに置き換えます。// Before ChatResponse response = model.internalCall(prompt, previousChatResponse); Flux<ChatResponse> responseFlux = model.internalStream(prompt, previousChatResponse); // After ChatResponse response = model.call(prompt); Flux<ChatResponse> responseFlux = model.stream(prompt);
OpenSearch の依存関係がアップグレードされました
OpenSearch ベクトルストアの依存関係が新しいバージョンにアップグレードされました。
OpenSearch Java クライアント :
2.23.0→3.6.0OpenSearch テストコンテナー :
2.0.1→4.1.0
バックグラウンド
このアップグレードは、HttpClient5(org.apache.httpcomponents.client5:httpclient5)バージョン 5.6 を使用する Spring Boot 4.1.x との互換性を確保するために必要でした。このバージョンの HttpClient には、gzip コンテンツフォーマッタの互換性を損なう変更が含まれており、OpenSearch Java クライアントのアップグレードが必要でした。詳細は OpenSearch Java PR #1851 [GitHub] (英語) を参照してください。
AbstractFilterExpressionConverter: doSingleValue は現在抽象化されています
AbstractFilterExpressionConverter (ベクトルストアフィルター式コンバーターで使用される)では、メソッド doSingleValue(Object value, StringBuilder context) が具象メソッドから抽象メソッドに変更されました。AbstractFilterExpressionConverter を継承するカスタムベクトルストア実装では、このメソッドを明示的に実装する必要があります。
インパクト
AbstractFilterExpressionConverterを継承し、doSingleValue()をオーバーライドしていないカスタムFilterExpressionConverterは、コンパイルに失敗します。実装では、単一のフィルター値(文字列、数値、ブール値、日付など)をターゲット形式に変換し、提供された
StringBuilderコンテキストに追加する必要があります。
マイグレーション
カスタムコンバーターに doSingleValue(Object value, StringBuilder context) を実装してください。提供されている静的ヘルパーメソッドを使用できます。
JSON ベースのフィルター (例: PostgreSQL JSONPath、Neo4j Cypher、Weaviate): 適切な引用符とエスケープを使用して値をシリアライズするには、
emitJsonValue(Object value, StringBuilder context)を使用します。ルセンベースのフィルター (例: Elasticsearch、OpenSearch、GemFire): 文字列値には
emitLuceneString(String value, StringBuilder context)を使用し、その他の型 (数値、ブール値、日付) はストアのクエリ構文に従って処理してください。その他の形式 : 独自のロジックを実装し、結果を
contextに追加します。
フレームワークは、doSingleValue を呼び出す前に値を正規化します (例: ISO 日付文字列を Date に変換)。そのため、実装ではすでに正規化された値を受け取ることができます。標準フロー以外で式を構築する際に同じ正規化が必要な場合は、静的ヘルパー normalizeDateString(Object) を利用できます。 |
MongoDB チャットメモリのメッセージ順序の修正
MongoChatMemoryRepository は、他のすべてのチャットメモリリポジトリ実装と一致するように、送信された順序(古いものから新しいものへ)でメッセージを返すように修正されました。以前は、メッセージを逆順(新しいものから古いものへ)で誤って返していたため、LLM の会話フローが中断されていました。
インパクト
アプリケーションが MongoChatMemoryRepository を使用しており、誤った順序付けを回避するための対策(たとえば、取得後にメッセージを逆順にするなど)を講じていた場合は、その回避策を削除する必要があります。
マイグレーション
MongoDB チャットメモリから取得したメッセージの順序を反転させるコードをすべて削除してください。
// BEFORE (with workaround for bug):
List<Message> messages = chatMemoryRepository.findByConversationId(conversationId);
Collections.reverse(messages); // Remove this workaround
// AFTER (correct ordering):
List<Message> messages = chatMemoryRepository.findByConversationId(conversationId);
// Messages are now correctly ordered chronologicallyすべてのチャットメモリリポジトリは、メッセージが送信された順序(古いものから新しいものへ)で一貫して返されるようになりました。これは、LLM の会話履歴として想定される形式です。
開発時のサービス
MongoDB Atlas の Docker Compose および Testcontainers サポートは、MongoDB モジュール Spring Boot によってネイティブに提供されるようになりました。移行は透過的であり、コード変更は必要ありません。依存関係については、
org.springframework.ai:spring-ai-spring-boot-testcontainersをインポートする必要はなくなりました。org.springframework.boot:spring-boot-testcontainersへの依存関係で十分です。
デフォルトの温度設定が削除されました
Spring AI では、チャットモデルの自動構成プロパティにデフォルトの温度値が設定されなくなりました。以前は、Spring AI でほとんどのチャットモデルに 0.7 というデフォルト温度が設定されていましたが、各 AI プロバイダーのネイティブなデフォルト温度を使用できるように、このデフォルト設定は削除されました。
インパクト
アプリケーションで温度値を明示的に設定せず、Spring AI のデフォルト値である 0.7 に依存していた場合、アップグレード後に動作が変わる可能性があります。実際のデフォルト値は、各 AI プロバイダーの API によって決定されるため、異なる場合があります。
一部のプロバイダーはデフォルトで
1.0を使用しています一部のプロバイダーはデフォルトで
0.7を使用しています一部のプロバイダではモデル固有のデフォルトがあります
マイグレーション
以前の動作を維持する場合は、構成で温度を明示的に設定します。
# Example for OpenAI
spring.ai.openai.chat.temperature=0.7
# Anthropic before Spring AI 2.1.0 only; remove this property when upgrading to 2.1.0.
spring.ai.anthropic.chat.temperature=0.7
# Example for Azure OpenAI
spring.ai.azure.openai.chat.temperature=0.7またはリクエストを構築するときにプログラムで次のようにします。
ChatResponse response = chatModel.call(
new Prompt("Your prompt here",
OpenAiChatOptions.builder()
.temperature(0.7)
.build()));1.1.0-RC1 へのアップグレード
重大な変更
テキスト読み上げ (TTS) API の移行
OpenAI 音声合成(TTS)の実装は、プロバイダ固有のクラスから共有インターフェースに移行されました。これにより、複数の TTS プロバイダ(OpenAI、ElevenLabs、将来のプロバイダ)で動作する移植性の高いコードの作成が可能になります。
削除されたクラス
次の非推奨クラスは org.springframework.ai.openai.audio.speech パッケージから削除されました。
SpeechModel→TextToSpeechModelを使用 (org.springframework.ai.audio.ttsより)StreamingSpeechModel→StreamingTextToSpeechModelを使用 (org.springframework.ai.audio.ttsより)SpeechPrompt→TextToSpeechPromptを使用 (org.springframework.ai.audio.ttsより)SpeechResponse→TextToSpeechResponseを使用 (org.springframework.ai.audio.ttsより)SpeechMessage→TextToSpeechMessageを使用 (org.springframework.ai.audio.ttsより)Speech(org.springframework.ai.openai.audio.speech内) →Speechを使用 (org.springframework.ai.audio.ttsより)
さらに、他の TTS プロバイダーとの一貫性を保つために、すべての OpenAI TTS コンポーネントで speed パラメーター型が Float から Double に変更されました。
移行手順
インポートの更新 :
org.springframework.ai.openai.audio.speech.からのすべてのインポートをorg.springframework.ai.audio.tts.に置き換えます型参照の更新 : 古いクラス名をすべて新しいクラス名に置き換えます。
Find: SpeechModel Replace: TextToSpeechModel Find: StreamingSpeechModel Replace: StreamingTextToSpeechModel Find: SpeechPrompt Replace: TextToSpeechPrompt Find: SpeechResponse Replace: TextToSpeechResponse Find: SpeechMessage Replace: TextToSpeechMessage速度パラメーターの更新 :
FloatからDoubleへの変更:Find: .speed(1.0f) Replace: .speed(1.0) Find: Float speed Replace: Double speedアップデート依存性注入 :
SpeechModelを挿入する場合は、TextToSpeechModelに更新します。// Before public MyService(SpeechModel speechModel) { ... } // After public MyService(TextToSpeechModel textToSpeechModel) { ... }
1.0.0-SNAPSHOT へのアップグレード
概要
1.0.0-SNAPSHOT バージョンでは、アーティファクト ID、パッケージ名、モジュール構造に大幅な変更が加えられています。このセクションでは、SNAPSHOT バージョンの使用に関する具体的なガイダンスを提供します。
スナップショットリポジトリの追加
1.0.0-SNAPSHOT バージョンを使用するには、スナップショットリポジトリをビルドファイルに追加する必要があります。詳細な手順については、「入門」ガイドのスナップショット - スナップショットリポジトリの追加セクションを参照してください。
アップデート依存関係管理
ビルド構成で、Spring AI BOM のバージョンを 1.0.0-SNAPSHOT に更新してください。依存関係管理の設定に関する詳細な手順については、「入門ガイド」の依存関係管理セクションを参照してください。
アーティファクト ID、パッケージ、モジュールの変更
1.0.0-SNAPSHOT には、アーティファクト ID、パッケージ名、モジュール構造の変更が含まれています。
詳細について: - 一般的なアーティファクト ID の変更 - 一般的なパッケージの変更 - 共通モジュール構造
1.0.0-RC1 へのアップグレード
OpenRewrite レシピを使えば、1.0.0-RC1 へのアップグレードプロセスを自動化できます。このレシピは、このバージョンに必要な多くのコード変更を適用できます。レシピと使用方法はアルコニア Spring AI マイグレーションズ [GitHub] (英語) を参照してください。
重大な変更
チャットクライアントとアドバイザー
エンドユーザーコードに影響を与える主な変更は次のとおりです。
VectorStoreChatMemoryAdvisorの場合:定数
CHAT_MEMORY_RETRIEVE_SIZE_KEYの名前がTOP_Kに変更されました。定数
DEFAULT_CHAT_MEMORY_RESPONSE_SIZE(値: 100) の名前がDEFAULT_TOP_Kに変更され、新しいデフォルト値は 20 になりました。
定数
CHAT_MEMORY_CONVERSATION_ID_KEYはCONVERSATION_IDに名前が変更され、AbstractChatMemoryAdvisorからChatMemoryインターフェースに移動されました。インポート時にorg.springframework.ai.chat.memory.ChatMemory.CONVERSATION_IDを使用するように更新してください。
アドバイザーの自己完結型テンプレート
プロンプト拡張を実行する組み込みアドバイザーが、自己完結型のテンプレートを使用するように更新されました。これにより、各アドバイザーは、他のアドバイザーのテンプレート化やプロンプト決定に影響を与えず、また影響を受けずにテンプレート化操作を実行できるようになります。
次のアドバイザーにカスタムテンプレートを提供していた場合は、必要なプレースホルダーがすべて含まれるようにテンプレートを更新する必要があります。
QuestionAnswerAdvisorでは、次のプレースホルダーを含むテンプレートが必要です ( 詳細については、こちらを参照してください)。ユーザーの質問を受け取るための
queryプレースホルダー。取得したコンテキストを受け取るための
question_answer_contextプレースホルダー。
VectorStoreChatMemoryAdvisorでは、次のプレースホルダーを含むテンプレートが必要です ( 詳細については、こちらを参照してください)。元のシステムメッセージを受信するための
instructionsプレースホルダー。取得した会話メモリを受け取るための
long_term_memoryプレースホルダー。
可観測性
トレースの代わりにログを使用するようにコンテンツ監視をリファクタリングしました (ca843e8 [GitHub] (英語) )
コンテンツ監視フィルターをログハンドラーに置き換えました
目的をより適切に反映するために、構成プロパティの名前を変更しました。
include-prompt→log-promptinclude-completion→log-completioninclude-query-response→log-query-response
トレース認識ログ用の
TracingAwareLoggingObservationHandlerを追加micrometer-tracing-bridge-otelをmicrometer-tracingに置き換えましたイベントベースのトレースを削除し、直接ログ記録を導入しました
OTel SDK への直接的な依存関係を削除しました
観測プロパティで
includePromptをlogPromptに名前変更しました (ChatClientBuilderProperties、ChatObservationProperties、ImageObservationProperties)
チャットメモリリポジトリモジュールと自動構成の名前変更
コードベース全体にリポジトリサフィックスを追加することで、チャットメモリコンポーネントの命名パターンを標準化しました。この変更は Cassandra、JDBC、Neo4j の実装に影響し、アーティファクト ID、Java パッケージ名、クラス名の明確化に役立ちます。
アーティファクト Id
すべてのメモリ関連のアーティファクトは、一貫したパターンに従うようになりました。
spring-ai-model-chat-memory-→spring-ai-model-chat-memory-repository-spring-ai-autoconfigure-model-chat-memory-→spring-ai-autoconfigure-model-chat-memory-repository-spring-ai-starter-model-chat-memory-→spring-ai-starter-model-chat-memory-repository-
Java パッケージ
パッケージパスに
.repository.セグメントが含まれるようになりましたサンプル:
org.springframework.ai.chat.memory.jdbc→org.springframework.ai.chat.memory.repository.jdbc
構成クラス
メイン自動構成クラスは
Repositoryサフィックスを使用するようになりましたサンプル:
JdbcChatMemoryAutoConfiguration→JdbcChatMemoryRepositoryAutoConfiguration
プロパティ
構成プロパティの名前が
spring.ai.chat.memory.<storage>…からspring.ai.chat.memory.repository.<storage>…に変更されました
移行が必要 : - 新しいアーティファクト ID を使用するように Maven/Gradle の依存関係を更新します。- 古いパッケージ名またはクラス名を使用していたインポート、クラス参照、構成を更新します。
メッセージアグリゲーターリファクタリング
変更
MessageAggregatorクラスは、spring-ai-client-chatモジュールのorg.springframework.ai.chat.modelパッケージからspring-ai-modelモジュールに移動されました。(同じパッケージ名)aggregateChatClientResponseメソッドはMessageAggregatorから削除され、org.springframework.ai.chat.clientパッケージの新しいクラスChatClientMessageAggregatorに移動されました。
移行ガイド
MessageAggregator の aggregateChatClientResponse メソッドを直接使用していた場合は、代わりに新しい ChatClientMessageAggregator クラスを使用する必要があります。
// Before
new MessageAggregator().aggregateChatClientResponse(chatClientResponses, aggregationHandler);
// After
new ChatClientMessageAggregator().aggregateChatClientResponse(chatClientResponses, aggregationHandler);適切なインポートを追加することを忘れないでください。
import org.springframework.ai.chat.client.ChatClientMessageAggregator;ワトソン
Watson AI モデルは、新しいチャット生成モデルが利用可能になったため、旧式のテキスト生成に基づいていたことから削除されました。Watson が Spring AI の将来のバージョンで復活することを期待します。
ベクトルストアを削除しました
HanaDB ベクトルストアの自動構成を削除しました (f3b4624 [GitHub] (英語) )
メモリ管理
CassandraChatMemory 実装を削除しました (11e3c8f [GitHub] (英語) )
チャットメモリアドバイザー階層を簡素化し、非推奨の API を削除しました (848a3fd [GitHub] (英語) )
JdbcChatMemory の非推奨を削除 (356a68f [GitHub] (英語) )
チャットメモリリポジトリの成果物をわかりやすくリファクタリングしました (2d517ee [GitHub] (英語) )
チャットメモリリポジトリの自動構成と Spring Boot スターターをわかりやすくリファクタリングしました (f6dba1b [GitHub] (英語) )
メッセージとテンプレート API
非推奨の UserMessage コンストラクターを削除しました (06edee4 [GitHub] (英語) )
非推奨の PromptTemplate コンストラクターを削除しました (722c77e [GitHub] (英語) )
メディアから非推奨のメソッドを削除しました (228ef10 [GitHub] (英語) )
リファクタリングされた StTemplateRenderer: supportStFunctions を validateStFunctions に名前変更しました ( 0e15197 [GitHub] (英語) )
移動後に残った TemplateRender インターフェースを削除しました ( 52675d8 [GitHub] (英語) )
追加のクライアント API の変更
ChatClient とアドバイザーの非推奨を削除 (4fe74d8 [GitHub] (英語) )
OllamaApi と AnthropicApi から非推奨を削除しました (46be898 [GitHub] (英語) )
パッケージ構造の変更
spring-ai-model のパッケージ間の依存関係の循環を削除しました (ebfa5b9 [GitHub] (英語) )
MessageAggregator を spring-ai-model モジュールに移動しました (54e5c07 [GitHub] (英語) )
依存関係
spring-ai-openai で使用されていない json-path 依存関係を削除しました (9de13d1 [GitHub] (英語) )
動作の変更
Azure OpenAI
クリーンな自動構成を備えた Azure OpenAI 用の Entra ID アイデンティティ管理を追加しました (3dc86d3 [GitHub] (英語) )
一般的なクリーンアップ
すべてのコードの非推奨を削除しました(76bee8c [GitHub] (英語) )および (b6ce7f3 [GitHub] (英語) )
1.0.0-M8 へのアップグレード
OpenRewrite レシピを使えば、1.0.0-M8 へのアップグレードプロセスを自動化できます。このレシピは、このバージョンに必要な多くのコード変更を適用できます。レシピと使用方法はアルコニア Spring AI マイグレーションズ [GitHub] (英語) を参照してください。
重大な変更
Spring AI 1.0 M7 から 1.0 M8 へのアップグレード時に、以前にツールコールバックを登録していたユーザーは、ツール呼び出し機能が警告なしに失敗するという互換性のない変更に遭遇しています。これは特に、非推奨となった tools() メソッドを使用していたコードに影響を与えています。
サンプル
以下は、M7 では動作していたが、M8 では期待どおりに動作しなくなったコードの例です。
// This worked in M7 but silently fails in M8
ChatClient chatClient = new OpenAiChatClient(api)
.tools(List.of(
new Tool("get_current_weather", "Get the current weather in a given location",
new ToolSpecification.ToolParameter("location", "The city and state, e.g. San Francisco, CA", true))
))
.toolCallbacks(List.of(
new ToolCallback("get_current_weather", (toolName, params) -> {
// Weather retrieval logic
return Map.of("temperature", 72, "unit", "fahrenheit", "description", "Sunny");
})
));ソリューション
解決策としては、非推奨の tools() メソッドの代わりに toolSpecifications() メソッドを使用することです。
// This works in M8
ChatClient chatClient = new OpenAiChatClient(api)
.toolSpecifications(List.of(
new Tool("get_current_weather", "Get the current weather in a given location",
new ToolSpecification.ToolParameter("location", "The city and state, e.g. San Francisco, CA", true))
))
.toolCallbacks(List.of(
new ToolCallback("get_current_weather", (toolName, params) -> {
// Weather retrieval logic
return Map.of("temperature", 72, "unit", "fahrenheit", "description", "Sunny");
})
));削除された実装と API
メモリ管理
CassandraChatMemory 実装を削除しました (11e3c8f [GitHub] (英語) )
チャットメモリアドバイザー階層を簡素化し、非推奨の API を削除しました (848a3fd [GitHub] (英語) )
JdbcChatMemory の非推奨を削除 (356a68f [GitHub] (英語) )
チャットメモリリポジトリの成果物をわかりやすくリファクタリングしました (2d517ee [GitHub] (英語) )
チャットメモリリポジトリの自動構成と Spring Boot スターターをわかりやすくリファクタリングしました (f6dba1b [GitHub] (英語) )
クライアント API
ChatClient とアドバイザーの非推奨を削除 (4fe74d8 [GitHub] (英語) )
チャットクライアントツールの呼び出しに関する重大な変更 (5b7849d [GitHub] (英語) )
OllamaApi と AnthropicApi から非推奨を削除しました (46be898 [GitHub] (英語) )
メッセージとテンプレート API
非推奨の UserMessage コンストラクターを削除しました (06edee4 [GitHub] (英語) )
非推奨の PromptTemplate コンストラクターを削除しました (722c77e [GitHub] (英語) )
メディアから非推奨のメソッドを削除しました (228ef10 [GitHub] (英語) )
リファクタリングされた StTemplateRenderer: supportStFunctions を validateStFunctions に名前変更しました ( 0e15197 [GitHub] (英語) )
移動後に残った TemplateRender インターフェースを削除しました ( 52675d8 [GitHub] (英語) )
モデルの実装
Watson テキスト生成モデルを削除 (9e71b16 [GitHub] (英語) )
Qianfan コードを削除しました (bfcaad7 [GitHub] (英語) )
HanaDB ベクトルストアの自動構成を削除しました (f3b4624 [GitHub] (英語) )
OpenAiApi からディープシークオプションを削除しました (59b36d1 [GitHub] (英語) )
パッケージ構造の変更
spring-ai-model のパッケージ間の依存関係の循環を削除しました (ebfa5b9 [GitHub] (英語) )
MessageAggregator を spring-ai-model モジュールに移動しました (54e5c07 [GitHub] (英語) )
依存関係
spring-ai-openai で使用されていない json-path 依存関係を削除しました (9de13d1 [GitHub] (英語) )
動作の変更
可観測性
トレースの代わりにログを使用するようにコンテンツ監視をリファクタリングしました (ca843e8 [GitHub] (英語) )
コンテンツ監視フィルターをログハンドラーに置き換えました
目的をより適切に反映するために、構成プロパティの名前を変更しました。
include-prompt→log-promptinclude-completion→log-completioninclude-query-response→log-query-response
トレース認識ログ用の
TracingAwareLoggingObservationHandlerを追加micrometer-tracing-bridge-otelをmicrometer-tracingに置き換えましたイベントベースのトレースを削除し、直接ログ記録を導入しました
OTel SDK への直接的な依存関係を削除しました
観測プロパティで
includePromptをlogPromptに名前変更しました (ChatClientBuilderProperties、ChatObservationProperties、ImageObservationProperties)
Azure OpenAI
クリーンな自動構成を備えた Azure OpenAI 用の Entra ID アイデンティティ管理を追加しました (3dc86d3 [GitHub] (英語) )
一般的なクリーンアップ
1.0.0-M8 からすべての非推奨を削除しました (76bee8c [GitHub] (英語) )
一般的な廃止予定のクリーンアップ (b6ce7f3 [GitHub] (英語) )
1.0.0-M7 へのアップグレード
変更の概要
Spring AI 1.0.0-M7 は、RC1 および GA リリース前の最後のマイルストーンリリースです。このリリースでは、アーティファクト ID、パッケージ名、モジュール構造にいくつかの重要な変更が加えられており、これらは最終リリースでも維持されます。
アーティファクト ID、パッケージ、モジュールの変更
1.0.0-M7 には 1.0.0-SNAPSHOT と同じ構造変更が含まれています。
詳細について: - 一般的なアーティファクト ID の変更 - 一般的なパッケージの変更 - 共通モジュール構造
MCP Java SDK の 0.9.0 へのアップグレード
Spring AI 1.0.0-M7 は、以前のバージョンから大幅な変更が加えられた MCP Java SDK バージョン 0.9.0 を使用するようになりました。アプリケーションで MCP を使用している場合は、これらの変更に対応するためにコードを更新する必要があります。
主な変更点は次のとおりです。
インターフェース名の変更
ClientMcpTransport→McpClientTransportServerMcpTransport→McpServerTransportDefaultMcpSession→McpClientSessionまたはMcpServerSessionすべての
*Registrationクラス→*Specificationクラス
サーバー作成の変更
ServerMcpTransportの代わりにMcpServerTransportProviderを使用する
// Before
ServerMcpTransport transport = new WebFluxSseServerTransport(objectMapper, "/mcp/message");
var server = McpServer.sync(transport)
.serverInfo("my-server", "1.0.0")
.build();
// After
McpServerTransportProvider transportProvider = new WebFluxSseServerTransportProvider(objectMapper, "/mcp/message");
var server = McpServer.sync(transportProvider)
.serverInfo("my-server", "1.0.0")
.build();ハンドラーシグネチャーの変更
すべてのハンドラーは、最初の引数として exchange パラメーターを受け取るようになりました。
// Before
.tool(calculatorTool, args -> new CallToolResult("Result: " + calculate(args)))
// After
.tool(calculatorTool, (exchange, args) -> new CallToolResult("Result: " + calculate(args)))Exchange 経由のクライアントインタラクション
以前はサーバー上で使用可能だったメソッドは、交換オブジェクトを介してアクセスされるようになりました。
// Before
ClientCapabilities capabilities = server.getClientCapabilities();
CreateMessageResult result = server.createMessage(new CreateMessageRequest(...));
// After
ClientCapabilities capabilities = exchange.getClientCapabilities();
CreateMessageResult result = exchange.createMessage(new CreateMessageRequest(...));ルート変更ハンドラー
// Before
.rootsChangeConsumers(List.of(
roots -> System.out.println("Roots changed: " + roots)
))
// After
.rootsChangeHandlers(List.of(
(exchange, roots) -> System.out.println("Roots changed: " + roots)
))MCP コードの移行に関する完全なガイドについては、MCP 移行ガイド [GitHub] (英語) を参照してください。
モデルの自動構成の有効化 / 無効化
モデルの自動構成を有効 / 無効にするための以前の構成プロパティは削除されました。
spring.ai.<provider>.chat.enabledspring.ai.<provider>.embedding.enabledspring.ai.<provider>.image.enabledspring.ai.<provider>.moderation.enabled
デフォルトでは、モデルプロバイダ(例: OpenAI、Ollama)がクラスパス上に見つかった場合、関連するモデル型(チャット、埋め込みなど)の自動構成が有効になります。同じモデル型に複数のプロバイダが存在する場合(例: spring-ai-openai-spring-boot-starter と spring-ai-ollama-spring-boot-starter の両方)、以下のプロパティを使用して、どのプロバイダの自動構成を有効にするかを選択できます。これにより、特定のモデル型に対して他のプロバイダの自動構成が実質的に無効になります。
特定のモデル型に対する自動構成を完全に無効にするには、プロバイダーが 1 つしか存在しない場合でも、対応するプロパティをクラスパス上のどのプロバイダーとも一致しない値 (例: none または disabled) に設定します。
既知のプロバイダー値のリストについては、SpringAIModels [GitHub] (英語) 列挙を参照できます。
spring.ai.model.audio.speech=<model-provider|none>spring.ai.model.audio.transcription=<model-provider|none>spring.ai.model.chat=<model-provider|none>spring.ai.model.embedding=<model-provider|none>spring.ai.model.embedding.multimodal=<model-provider|none>spring.ai.model.embedding.text=<model-provider|none>spring.ai.model.image=<model-provider|none>spring.ai.model.moderation=<model-provider|none>
AI を使ったアップグレードの自動化
提供されたプロンプトを使用して、Claude コード CLI ツールを使用して 1.0.0-M7 へのアップグレードプロセスを自動化できます。
Claude コード CLI ツール (英語) をダウンロード
update-to-m7.txt [GitHub] (英語) ファイルからプロンプトをコピーします
プロンプトを Claude コード CLI に貼り付けます
AI がプロジェクトを分析し、必要な変更を加えます
| 自動アップグレードプロンプトは現在、アーティファクト ID の変更、パッケージの再配置、モジュール構造の変更に対応していますが、MCP 0.9.0 へのアップグレードに関する自動変更はまだ含まれていません。MCP をご利用の場合は、MCP Java SDK アップグレードセクションのガイダンスに従ってコードを手動で更新する必要があります。 |
バージョン間での共通の変更点
アーティファクト ID の変更
Spring AI スターターアーティファクトの命名規則が変更されました。以下の規則に従って依存関係を更新する必要があります。
モデルスターター:
spring-ai-{model}-spring-boot-starter→spring-ai-starter-model-{model}ベクトルストアスターター:
spring-ai-{store}-store-spring-boot-starter→spring-ai-starter-vector-store-{store}MCP スターター:
spring-ai-mcp-{type}-spring-boot-starter→spring-ai-starter-mcp-{type}
サンプル
Maven
Gradle
<!-- BEFORE -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>
<!-- AFTER -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-openai</artifactId>
</dependency>// BEFORE
implementation 'org.springframework.ai:spring-ai-openai-spring-boot-starter'
implementation 'org.springframework.ai:spring-ai-redis-store-spring-boot-starter'
// AFTER
implementation 'org.springframework.ai:spring-ai-starter-model-openai'
implementation 'org.springframework.ai:spring-ai-starter-vector-store-redis'Spring AI 自動構成アーティファクトの変更点
Spring AI の自動構成は、単一の統合されたアーティファクトから、モデル、ベクトルストア、その他のコンポーネントごとに個別の自動構成アーティファクトに変更されました。この変更は、Google プロトコルバッファ、Google RPC など、依存ライブラリの異なるバージョン間の競合による影響を最小限に抑えるために行われました。自動構成をコンポーネント固有のアーティファクトに分離することで、不要な依存関係を取り込むことを回避し、アプリケーションにおけるバージョン競合のリスクを軽減できます。
オリジナルのモノリシックアーティファクトは利用できなくなりました。
<!-- NO LONGER AVAILABLE -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-spring-boot-autoconfigure</artifactId>
<version>${project.version}</version>
</dependency>代わりに、各コンポーネントには次のパターンに従う独自の自動構成アーティファクトが含まれるようになりました。
モデルの自動構成:
spring-ai-autoconfigure-model-{model}ベクトルストアの自動構成:
spring-ai-autoconfigure-vector-store-{store}MCP 自動構成:
spring-ai-autoconfigure-mcp-{type}
新しい自動構成アーティファクトの例
モデル
ベクトルストア
MCP
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-model-openai</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-model-anthropic</artifactId>
</dependency><dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-vector-store-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-vector-store-pgvector</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-vector-store-chroma</artifactId>
</dependency><dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-mcp-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-mcp-server</artifactId>
</dependency>| ほとんどの場合、これらの自動構成依存関係を明示的に追加する必要はありません。対応するスターター依存関係を使用すると、それらは推移的に含まれます。 |
パッケージ名の変更
IDE は、新しいパッケージの場所へのリファクタリングを支援する必要があります。
KeywordMetadataEnricherおよびSummaryMetadataEnricherはorg.springframework.ai.transformerからorg.springframework.ai.chat.transformerに移動しました。Content、MediaContent、Mediaはorg.springframework.ai.modelからorg.springframework.ai.contentに移動しました。
モジュール構造
このプロジェクトでは、モジュールとアーティファクトの構造に大幅な変更が行われました。以前は spring-ai-core にすべての中心的なインターフェースが含まれていましたが、現在はアプリケーションにおける不要な依存関係を削減するため、専用のドメインモジュールに分割されています。

spring-ai-commons
他の Spring AI モジュールに依存しない基本モジュール。以下の要素を含む: - コアドメインモデル(Document、TextSplitter) - JSON ユーティリティとリソース処理 - 構造化ログ記録と可観測性サポート
spring-ai-model
AI 機能の抽象化を提供する: - ChatModel、EmbeddingModel、ImageModel のようなインターフェース - メッセージ型とプロンプトテンプレート - 関数呼び出しフレームワーク(ToolDefinition、ToolCallback) - コンテンツフィルタリングと監視のサポート
spring-ai-vector-store
統一されたベクトルデータベース抽象化: - 類似検索のための VectorStore インターフェース - SQL のような表現による高度なフィルタリング - メモリ内使用のための SimpleVectorStore - 埋め込みのバッチ処理サポート
spring-ai-client-chat
高レベルの会話型 AI API: - ChatClient インターフェース - ChatMemory による会話の持続 - OutputConverter によるレスポンス変換 - アドバイザーベースのインターセプト - 同期およびリアクティブストリーミングのサポート
spring-ai-vector-store-advisor
RAG のベクトルストアとチャットを橋渡しします: - QuestionAnswerAdvisor: プロンプトにコンテキストを挿入します - VectorStoreChatMemoryAdvisor: 会話履歴を保存 / 取得します
依存関係の構造
依存関係の階層は次のように要約できます。
spring-ai-commons(財団)spring-ai-model(コモンズに依存する)spring-ai-vector-storeおよびspring-ai-client-chat(どちらもモデルによって異なります)spring-ai-vector-store-advisorおよびspring-ai-rag(クライアントチャットとベクトルストアの両方に依存する)spring-ai-model-chat-memory-*モジュール (クライアントチャットに依存する)
ToolContext の変更
ToolContext クラスは、明示的および暗黙的なツール解決をサポートするように拡張されました。ツールは以下の方法で指定できます。
明示的に含まれる : プロンプトで明示的にリクエストされ、モデルの呼び出しに含まれるツール。
暗黙的に利用可能 : 実行時の動的解決に使用できるツールですが、明示的にリクエストされない限り、モデルへの呼び出しには含まれません。
1.0.0-M7 以降、ツールは、プロンプトで明示的にリクエストされた場合、または呼び出しに明示的に含まれている場合にのみ、モデルの呼び出しに含まれます。
さらに、ToolContext クラスは final クラスとしてマークされ、拡張できなくなりました。このクラスは元々サブクラス化されることを想定していませんでした。ToolContext をインスタンス化する際に必要なコンテキストデータはすべて、Map<String, Object> の形式で追加できます。詳細については、[ ドキュメント ]( docs.spring.io/spring-ai/reference/api/tools.html#_tool_context ) を参照してください。
1.0.0-M6 へのアップグレード
使用インターフェースと DefaultUsage 実装の変更
Usage インターフェースとそのデフォルト実装 DefaultUsage には、次の変更が加えられました。
メソッド名の変更:
getGenerationTokens()はgetCompletionTokens()になりました
型の変更:
DefaultUsageのすべてのトークンカウントフィールドがLongからIntegerに変更されました。promptTokenscompletionTokens(旧generationTokens)totalTokens
必要なアクション
getGenerationTokens()へのすべての呼び出しをgetCompletionTokens()に置き換えますDefaultUsageコンストラクター呼び出しを更新します。
// Old (M5) new DefaultUsage(Long promptTokens, Long generationTokens, Long totalTokens) // New (M6) new DefaultUsage(Integer promptTokens, Integer completionTokens, Integer totalTokens)
| 使用方法の詳細については、こちらを参照してください。 |
ツール呼び出しにおける FunctionCallingOptions の使用箇所の変更
各 ChatModel インスタンスは、構築時に、モデルの呼び出しに使用されるデフォルトのツールを構成するために使用できるオプションの ChatOptions または FunctionCallingOptions インスタンスを受け入れます。
1.0.0-M6 以前:
デフォルトの
FunctionCallingOptionsインスタンスのfunctions()メソッドを介して渡されたツールは、そのChatModelインスタンスからのモデルへの各呼び出しに含まれており、ランタイムオプションによって上書きされている可能性があります。デフォルトの
FunctionCallingOptionsインスタンスのfunctionCallbacks()メソッドを介して渡されるツールは、実行時の動的解決 ( ツール解決を参照) でのみ使用可能になり、明示的にリクエストされない限り、モデルへの呼び出しには含まれません。
1.0.0-M6 の開始:
functions()メソッドまたはデフォルトのFunctionCallingOptionsインスタンスのfunctionCallbacks()を介して渡されるすべてのツールは、同じ方法で処理されるようになりました。つまり、そのChatModelインスタンスからのモデルへの各呼び出しに含まれ、ランタイムオプションによって上書きされる可能性があります。これにより、モデルへの呼び出しにツールが含まれる方法に一貫性が保たれ、functionCallbacks()と他のすべてのオプションの動作の違いによる混乱が回避されます。
ツールを実行時の動的解決に利用できるようにし、明示的にリクエストされた場合にのみモデルへのチャットリクエストに含める場合は、ツール解決で説明されているいずれかの戦略を使用できます。
| 1.0.0-M6 では、ツール呼び出しを処理するための新しい API が導入されました。上記のシナリオを除き、すべてのシナリオにおいて古い API との後方互換性が維持されています。古い API は引き続き利用可能ですが、非推奨となり、1.0.0-M7 で削除されます。 |
非推奨となりた Amazon Bedrock チャットモデルの削除
1.0.0-M6 以降、Spring AI は Spring AI におけるすべてのチャット会話実装において、Amazon Bedrock の Converse API を使用するように移行しました。Cohere および Titan の埋め込みモデルを除き、Amazon Bedrock のチャットモデルはすべて削除されました。
| チャットモデルの使用については、Bedrock コンバースのドキュメントを参照してください。 |
依存関係管理に Spring Boot 3.4.2 を使用するように変更
Spring AI は、依存関係管理に Spring Boot 3.4.2 を使用するように更新されました。Spring Boot 3.4.2 が管理する依存関係については、こちら [GitHub] (英語) を参照してください。
必要なアクション
Spring Boot 3.4.2 にアップグレードする場合は、REST クライアントの設定に必要な変更について、このドキュメントを必ず参照してください。特に、クラスパスに HTTP クライアントライブラリがない場合、以前は
SimpleClientHttpRequestFactoryが使用されていた場所がJdkClientHttpRequestFactoryに置き換えられる可能性があります。SimpleClientHttpRequestFactoryを使用するように切り替えるには、spring.http.client.factory=simpleを設定する必要があります。異なるバージョンの Spring Boot (たとえば Spring Boot 3.3.x) を使用しており、依存関係の特定のバージョンが必要な場合は、ビルド構成でそれをオーバーライドできます。
ベクトルストア API の変更
バージョン 1.0.0-M6 では、VectorStore インターフェースの delete メソッドが、Optional<Boolean> を返すのではなく、void 操作になるように変更されました。以前のコードで削除操作の戻り値をチェックしていた場合は、このチェックを削除する必要があります。削除が失敗した場合、この操作は例外をスローするようになり、より直接的なエラー処理が可能になります。
1.0.0.M5 へのアップグレード
ベクトルビルダーは一貫性を保つためにリファクタリングされました。
現在の VectorStore 実装コンストラクターは非推奨になっています。ビルダーパターンを使用してください。
VectorStore 実装パッケージは、アーティファクト間での競合を回避するために、一意のパッケージ名に移動されました。たとえば、
org.springframework.ai.vectorstoreからorg.springframework.ai.pgvector.vectorstoreへ。
1.0.0.RC3 へのアップグレード
ポータブルチャットオプション(
frequencyPenalty、presencePenalty、temperature、topP)の型がFloatからDoubleに変更されました。
1.0.0.M2 へのアップグレード
Chroma ベクトルストアの構成プレフィックスは、他のベクトルストアの命名規則に合わせるために、
spring.ai.vectorstore.chroma.storeからspring.ai.vectorstore.chromaに変更されました。スキーマを初期化できるベクトルストアの
initialize-schemaプロパティのデフォルト値が、falseに設定されました。つまり、アプリケーションの起動時にスキーマが作成される場合、アプリケーションは、サポートされているベクトルストアでスキーマの初期化を明示的にオプトインする必要があります。すべてのベクトルストアがこのプロパティをサポートしているわけではありません。詳細については、対応するベクトルストアのドキュメントを参照してください。現在initialize-schemaプロパティをサポートしていないベクトルストアは次のとおりです。Pinecone
Weaviate
Bedrock Jurassic 2 では、チャットオプション
countPenalty、frequencyPenalty、presencePenaltyの名前がcountPenaltyOptions、frequencyPenaltyOptions、presencePenaltyOptionsに変更されました。さらに、チャットオプションstopSequencesの型がString[]からList<String>に変更されました。Azure、OpenAI では、チャットオプション
frequencyPenaltyおよびpresencePenaltyの型が、他のすべての実装と一致するように、DoubleからFloatに変更されました。
1.0.0.M1 へのアップグレード
1.0.0 M1 のリリースに向けて、いくつかの重大な変更を加えました。申し訳ありませんが、これは最善の策です。
ChatClient の変更点
大きな変更が加えられ、「旧」 ChatClient の機能が ChatModel に移行されました。「新」 ChatClient は ChatModel のインスタンスを受け取るようになりました。これは、Spring エコシステム内の他のクライアントクラス(RestClient、WebClient、JdbcClient など)と同様のスタイルでプロンプトを作成および実行するための流れるような API をサポートするために行われました。流れるような API の詳細については JavaDoc (Javadoc) を参照してください。適切なリファレンスドキュメントは近日中に公開予定です。
旧 ModelClient を Model に名称変更し、実装クラスも名称変更しました。たとえば、ImageClient は ImageModel に名称変更されました。Model の実装は、Spring AI API と基盤となる AI モデル API 間の変換を行う移植性レイヤーを表しています。
新しいパッケージ model には、あらゆる入出力データ型の組み合わせに対応した AI モデルクライアントの作成をサポートするインターフェースと基本クラスが含まれています。現在、チャットモデルとイメージモデルのパッケージで実装されています。埋め込みパッケージも近日中にこの新しいモデルにアップデートする予定です。
新しい「ポータブルオプション」設計パターン。ModelCall は、様々なチャットベースの AI モデル間で可能な限り高い移植性を提供することを目的としています。共通の生成オプションセットと、モデルプロバイダー固有のオプションがあります。一種の「ダックタイピング」アプローチが採用されています。モデルパッケージ内の ModelOptions は、このクラスの実装がモデルのオプションを提供することを示すマーカーインターフェースです。すべての text → image ImageModel 実装に共通するポータブルオプションを定義するサブインターフェースである ImageOptions を参照してください。そして、StabilityAiImageOptions と OpenAiImageOptions は、各モデルプロバイダー固有のオプションを提供します。すべてのオプションクラスは、Fluent API ビルダーによって作成され、すべてポータブルな ImageModel API に渡すことができます。これらのオプションデータ型は、ImageModel 実装の自動構成 / 構成プロパティで使用されます。
アーティファクト名の変更
POM アーティファクト名を変更しました: - spring-ai-qdrant → spring-ai-qdrant-store - spring-ai-cassandra → spring-ai-cassandra-store - spring-ai-pinecone → spring-ai-pinecone-store - spring-ai-redis → spring-ai-redis-store - spring-ai-qdrant → spring-ai-qdrant-store - spring-ai-gemfire → spring-ai-gemfire-store - spring-ai-azure-vector-store-spring-boot-starter → spring-ai-azure-store-spring-boot-starter - spring-ai-redis-spring-boot-starter → spring-ai-starter-vector-store-redis
0.8.1 へのアップグレード
以前の spring-ai-vertex-ai は spring-ai-vertex-ai-palm2 に、spring-ai-vertex-ai-spring-boot-starter は spring-ai-vertex-ai-palm2-spring-boot-starter に名前が変更されました。
依存関係を次から変更する必要があります
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai</artifactId>
</dependency>To
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai-palm2</artifactId>
</dependency>Palm2 モデルに関連する Boot スターター
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai-spring-boot-starter</artifactId>
</dependency>to
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai-palm2-spring-boot-starter</artifactId>
</dependency>名前変更されたクラス (01.03.2024)
VertexAiApi → VertexAiPalm2Api
VertexAiClientChat → VertexAiPalm2ChatClient
VertexAiEmbeddingClient → VertexAiPalm2EmbeddingClient
VertexAiChatOptions → VertexAiPalm2ChatOptions
0.8.0 へのアップグレード
2024 年 1 月 24 日更新
prompt、messages、metadataパッケージをorg.springframework.ai.chatのサブパッケージに移動する新しい機能は、テキストからイメージへのクライアントです。クラスは
OpenAiImageModelおよびStabilityAiImageModelです。使用箇所については統合テストを参照してください。ドキュメントは近日公開予定です。新しいパッケージ
modelには、あらゆる入出力データ型の組み合わせに対応した AI モデルクライアントの作成をサポートするインターフェースと基本クラスが含まれています。現在、チャットモデルとイメージモデルのパッケージで実装されています。埋め込みパッケージも近日中にこの新しいモデルにアップデートする予定です。新しい「ポータブルオプション」設計パターン。
ModelCallは、様々なチャットベースの AI モデル間で可能な限り高い移植性を提供することを目的としています。共通の生成オプションセットと、モデルプロバイダー固有のオプションがあります。一種の「ダックタイピング」アプローチが採用されています。モデルパッケージ内のModelOptionsは、このクラスの実装がモデルのオプションを提供することを示すマーカーインターフェースです。すべての text → imageImageModel実装に共通するポータブルオプションを定義するサブインターフェースであるImageOptionsを参照してください。そして、StabilityAiImageOptionsとOpenAiImageOptionsは、各モデルプロバイダー固有のオプションを提供します。すべてのオプションクラスは、Fluent API ビルダーによって作成され、すべてポータブルなImageModelAPI に渡すことができます。これらのオプションデータ型は、ImageModel実装の自動構成 / 構成プロパティで使用されます。
2024 年 1 月 13 日更新
以下の OpenAi 自動構成チャットプロパティが変更されました
spring.ai.openai.modelからspring.ai.openai.chat.modelまで。spring.ai.openai.temperatureからspring.ai.openai.chat.temperatureまで。
OpenAi プロパティに関する更新されたドキュメントを検索します: 参照: openai-chat.html
2023 年 12 月 27 日更新
SimplePersistentVectorStore と InMemoryVectorStore を SimpleVectorStore にマージします * InMemoryVectorStore を SimpleVectorStore に置き換えます
2023 年 12 月 20 日更新
Ollama クライアントと関連クラスおよびパッケージ名のリファクタリング
org.springframework.ai.ollama.client.OllamaClient を org.springframework.ai.ollama.OllamaModelCall に置き換えます。
OllamaChatClient メソッドのシグネチャーが変更されました。
org.springframework.ai.autoconfigure.ollama.OllamaProperties の名前を org.springframework.ai.model.ollama.autoconfigure.OllamaChatProperties に変更し、サフィックスを
spring.ai.ollama.chatに変更します。一部のプロパティも変更されました。
2023 年 12 月 19 日更新
AiClient および関連クラスおよびパッケージ名の変更
AiClient の名前を ChatClient に変更します
AiResponse の名前を ChatResponse に変更します
AiStreamClient の名前を StreamingChatClient に変更します
パッケージの名前を org.sf.ai.client から org.sf.ai.chat に変更します
アーティファクト ID の名前を変更します
transformers-embeddingからspring-ai-transformers
Maven モジュールを最上位ディレクトリと embedding-clients サブディレクトリからすべて 1 つの models ディレクトリに移動しました。
2023 年 12 月 1 日
プロジェクトのグループ ID を移行しています。
FROM:
org.springframework.experimental.aiTO:
org.springframework.ai
以下に示すように、アーティファクトは引き続きスナップショットリポジトリでホストされます。
メインの ブランチはバージョン 0.8.0-SNAPSHOT に移行します。1 ~ 2 週間は不安定になります。最新の状態を望まない場合は、0.7.1-SNAPSHOT を使用してください。
以前と同様に 0.7.1-SNAPSHOT アーティファクトにアクセスでき、引き続き 0.7.1-SNAPSHOT ドキュメント (英語) にアクセスできます。
0.7.1-SNAPSHOT の依存関係
Azure OpenAI
<dependency> <groupId>org.springframework.experimental.ai</groupId> <artifactId>spring-ai-azure-openai-spring-boot-starter</artifactId> <version>0.7.1-SNAPSHOT</version> </dependency>OpenAI
<dependency> <groupId>org.springframework.experimental.ai</groupId> <artifactId>spring-ai-openai-spring-boot-starter</artifactId> <version>0.7.1-SNAPSHOT</version> </dependency>