Zhuoxi2000 commented on code in PR #965:
URL: https://github.com/apache/flink-agents/pull/965#discussion_r3785334041
##########
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:
The Java default changing from true to false is also a behavior change for
existing setups that relied on implicit prefilling. The new default makes sense
given 4.6+ models reject prefilling, but should this get a release-note /
BREAKING entry for 0.4 rather than only the docs update?
##########
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:
The alias-prefix logic has the same edge case one level down:
startsWith("claude-sonnet-4-5") would also match something like
claude-sonnet-4-50. Since the intent is to match either the alias itself or a
dated snapshot, name.equals(prefix) || name.startsWith(prefix + "-") seems
safer. The same applies to Python’s _NATIVE_STRUCTURED_OUTPUT_ALIAS_PREFIXES.
--
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]