Problem/Motivation
Drupal\ai_neuron\Providers\ToolMapper::map() rebuilds each tool's schema one property at a time from ToolInterface::getProperties():
foreach ($tool->getProperties() as $property) { $function->setProperty($this->property($property)); }
Neuron's provider contract (src/Providers/AGENTS.md) says a tool mapper "consumes ToolInterface::getInputSchema() rather than rebuilding the schema from properties", and Neuron's own Providers\OpenAI\ToolMapper sends getInputSchema() as parameters and merges getParameters() on top.
Two consequences:
- A tool that overrides
getInputSchema()loses everything the property list does not carry.FrontendTool, which Neuron's AG-UI input translator builds from a client-supplied schema, is the shipped example. For a schema withemail {format, maxLength},count {minimum, maximum}andopts {additionalProperties: false},getInputSchema()keeps all of these, while the module sends{"email": {"type": "string", "description": "Address"}, "count": {"type": "integer"}, "opts": {..., "required": []}}. Tool::setParameters()(hand-written schema fragments,cache_controland other raw provider keys) is ignored for every tool.
The model therefore gets a looser contract than the tool declares, and validation that the tool author relied on does not happen.
Steps to reproduce
- Build a
FrontendToolwith an input schema carryingformat,maxLength,minimumoradditionalProperties. - Run it through
ToolMapper::map()and render the resultingToolsFunctionInput. - Compare with
$tool->getInputSchema(): the constraints are gone.
Proposed resolution
Map from getInputSchema(): take properties and required from the schema instead of iterating getProperties(), then merge getParameters() into the function definition the way Neuron's OpenAI mapper does. NeuronPropertyInput can stay as the vehicle for passing each property's schema through to drupal/ai unchanged.
Issue fork ai_neuron-3628781
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
joevagyok commentedComment #3
joevagyok commentedRevisit with frontend tool support later.
Comment #4
ademarco commentedWe are actually going to tackle this head on.
Comment #5
ademarco commented