runtimeInjectsToolDeclarations property
Whether the runtime/SDK injects the tool declarations itself, so this chat
must NOT weave its own JSON tools prompt (that would double-wrap them). The
engine's explicit override wins; absent one it derives from the model's
FunctionCallFormat (true for SDK-passthrough models like Gemma 4). This
replaces the former hardcoded modelType == ModelType.gemma4 check, so an
engine that injects tools natively could opt in for any model type. No
shipping engine sets the override yet (Gemma 4 gets true via its format).
NOTE: this governs the INPUT side only (skipping declaration injection).
Reading tool calls BACK is still keyed off
FunctionCallParser.usesSdkPassthrough (see generateChatResponse /
generateChatResponseAsync), which is model-format-derived and not
per-chat overridable — so an engine that sets this true on a
non-passthrough model gets calls parsed from the text stream, not from a
structured SDK response.
Implementation
late final bool runtimeInjectsToolDeclarations =
_runtimeInjectsToolDeclarationsOverride ??
FunctionCallParser.runtimeInjectsToolDeclarations(modelType);