File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -607,6 +607,21 @@ def test_unknown_tool_returns_error(self):
607607
608608
609609class TestToolSurface :
610+ def test_shared_schemas_omit_ollama_only_unique_items (self ):
611+ ai_mod = _import_ai_mcp_client ()
612+
613+ def contains_unique_items (value ):
614+ if isinstance (value , dict ):
615+ return 'uniqueItems' in value or any (
616+ contains_unique_items (child ) for child in value .values ()
617+ )
618+ if isinstance (value , list ):
619+ return any (contains_unique_items (child ) for child in value )
620+ return False
621+
622+ for tool in ai_mod .get_mcp_tools ():
623+ assert not contains_unique_items (tool ['inputSchema' ])
624+
610625 def test_no_llm_facing_get_songs_or_dead_params (self ):
611626 ai_mod = _import_ai_mcp_client ()
612627 for tool in ai_mod .get_mcp_tools ():
Original file line number Diff line number Diff line change @@ -593,6 +593,39 @@ def test_source_schema_not_mutated(self):
593593 pr .build_tool_calls_schema (tools )
594594 assert 'additionalProperties' not in tools [0 ]['inputSchema' ]
595595
596+ def test_unique_items_are_added_only_to_derived_argument_arrays (self ):
597+ pr = _prompts ()
598+ tools = _tools_fixture ()
599+
600+ schema = pr .build_tool_calls_schema (tools )
601+ branches = schema ['properties' ]['tool_calls' ]['items' ]['oneOf' ]
602+ argument_schemas = [branch ['properties' ]['arguments' ] for branch in branches ]
603+
604+ def array_schemas (value ):
605+ if isinstance (value , dict ):
606+ if value .get ('type' ) == 'array' :
607+ yield value
608+ for child in value .values ():
609+ yield from array_schemas (child )
610+ elif isinstance (value , list ):
611+ for child in value :
612+ yield from array_schemas (child )
613+
614+ derived_arrays = [
615+ array_schema
616+ for argument_schema in argument_schemas
617+ for array_schema in array_schemas (argument_schema )
618+ ]
619+ source_arrays = [
620+ array_schema
621+ for tool in tools
622+ for array_schema in array_schemas (tool ['inputSchema' ])
623+ ]
624+
625+ assert derived_arrays
626+ assert all (array_schema ['uniqueItems' ] is True for array_schema in derived_arrays )
627+ assert all ('uniqueItems' not in array_schema for array_schema in source_arrays )
628+
596629
597630class TestPromptRendering :
598631 def test_system_prompt_derives_tools_and_rules (self ):
You can’t perform that action at this time.
0 commit comments