When SpotlightSearchTool is used with a custom LanguageModel backend (for
example Apple’s ChatCompletionsLanguageModel from apple/foundation-models-utilities,
pointed at an OpenAI-compatible server), the tool can never be successfully
invoked. The model produces tool-call arguments that exactly match the format
documented in the tool’s own description, but those arguments fail validation
against the tool’s generated parameters JSON Schema, throwing
LanguageModelSession.ToolCallError with underlying error
“Failed to parse generated content.”
The root cause is a mismatch between two things the framework sends to the model
in the same tool definition:
the human-readable description (“Call format”), which presents the
top-level arguments as { root, modelComposition, … }, and
the parameters JSON Schema (FullArguments), which requires
{ "query": { "type": "search", "value": { root, modelComposition, … } } }.
A model that follows the description is guaranteed to fail the schema.
Secondary observation (may be a separate issue or intended)
CoreSpotlightSource.fetchAttributes appears to have no effect on which
attributes are returned to the model on this agentic-search path. Even with
fetchAttributes: [.title, .contentDescription] set on the source, results
contain only default metadata (kMDItemTitle, kMDItemDisplayName, dates,
identifiers) and omit kMDItemDescription. The description is returned only when
the in-query SearchArguments.fetchAttributes explicitly lists it. The
searchableIndexDelegate was never invoked in any configuration tried (including
.dynamic). If the source-level fetchAttributes is meant to drive returned
attributes, that also seems incorrect; otherwise, clarifying the docs would help.
Therefore my question, is this just not supported or does the scheme need an update? Or is There a different way that should be done?