weiqingy commented on code in PR #965:
URL: https://github.com/apache/flink-agents/pull/965#discussion_r3792826118


##########
integrations/chat-models/anthropic/src/main/java/org/apache/flink/agents/integrations/chatmodels/anthropic/AnthropicChatModelConnection.java:
##########
@@ -114,24 +117,167 @@ public void close() {
         this.client.close();
     }
 
+    // Models Anthropic documents native structured-output support for. Source 
of truth:
+    // https://platform.claude.com/docs/en/build-with-claude/structured-outputs
+    //
+    // The documented rule is generational rather than a per-snapshot list: 
structured outputs are
+    // generally available for Claude 4.5 and later models, and for Claude 
Mythos Preview. Names
+    // from the 4.6 generation onward carry no date and are pinned, so the 
name is itself the
+    // snapshot and is matched exactly.
+    //
+    // The three 4.5-generation names are aliases that front a dated snapshot, 
so a request may
+    // carry either the alias or the snapshot behind it and both have to 
match. Those are matched
+    // by prefix instead, and the prefix has to retain the minor version: 
"claude-opus-4" would
+    // also capture claude-opus-4-1-20250805, which predates the cutoff and is 
not capable.
+    //
+    // A name outside both sets reports not-capable and degrades to the 
prompt-engineering
+    // fallback rather than failing at the provider.
+    private static final Set<String> NATIVE_STRUCTURED_OUTPUT_MODELS =
+            Set.of(
+                    "claude-opus-4-6",
+                    "claude-opus-4-7",
+                    "claude-opus-4-8",
+                    "claude-opus-5",
+                    "claude-sonnet-4-6",
+                    "claude-sonnet-5",
+                    "claude-fable-5",
+                    "claude-mythos-5",
+                    "claude-mythos-preview");
+
+    private static final Set<String> NATIVE_STRUCTURED_OUTPUT_ALIAS_PREFIXES =

Review Comment:
   Thanks for the review. Improved this in commit `a72fbbf4`.
   



##########
integrations/chat-models/anthropic/src/main/java/org/apache/flink/agents/integrations/chatmodels/anthropic/AnthropicChatModelSetup.java:
##########
@@ -74,7 +78,7 @@ public class AnthropicChatModelSetup extends 
BaseChatModelSetup {
     private static final String DEFAULT_MODEL = "claude-sonnet-4-20250514";
     private static final double DEFAULT_TEMPERATURE = 0.1d;
     private static final long DEFAULT_MAX_TOKENS = 1024L;
-    private static final boolean DEFAULT_JSON_PREFILL = true;
+    private static final boolean DEFAULT_JSON_PREFILL = false;

Review Comment:
   You're right, this breaks existing setups. `json_prefill` defaulted to 
`true` in 0.2.0 through 0.3.1, so callers without tools lose the prefilled `{` 
on 0.4.
   
   Currently I don't think it needs a separate BREAKING entry. `code_review.md` 
says breaking changes are acceptable in beta when they prevent an old bug path 
staying available, which is this one: the old gate never checked the model, so 
a 4.6+ model returned a 400 on every tool-free request. It also asks that such 
a change be intentional, documented and tested, and this one is, in the 
`chat_models.md` table and the setup tests in both languages. I have also fixed 
the PR description, which still claimed nothing changed.
   
   Once we reach 1.0 we should guarantee backward compatibility. Having 
somewhere to record breaks like this before then would be worth doing, and this 
is a good example of why.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to