{"record":{"id":"836c5fcbea5ec9c2","repo":"microsoft/semantic-kernel","slug":"missing-or-malformed-vector-store-ids-in-spec-836c5f","errorCode":null,"errorMessage":"Missing or malformed 'vector_store_ids' in: {spec}","messagePattern":"Missing or malformed 'vector_store_ids' in: (.+?)","errorType":"exception","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/open_ai/openai_assistant_agent.py","lineNumber":115,"sourceCode":"        _TOOL_BUILDERS[tool_type.lower()] = fn\n        return fn\n\n    return decorator\n\n\n# Update _code_interpreter\n@_register_tool(\"code_interpreter\")\ndef _code_interpreter(spec: ToolSpec, kernel: Kernel | None = None) -> tuple[list[AssistantToolParam], ToolResources]:\n    file_ids = spec.options.get(\"file_ids\")\n    return OpenAIAssistantAgent.configure_code_interpreter_tool(file_ids=file_ids)\n\n\n# Update _file_search\n@_register_tool(\"file_search\")\ndef _file_search(spec: ToolSpec, kernel: Kernel | None = None) -> tuple[list[AssistantToolParam], ToolResources]:\n    vector_store_ids = spec.options.get(\"vector_store_ids\")\n    if not vector_store_ids or not isinstance(vector_store_ids, list) or not vector_store_ids[0]:\n        raise AgentInitializationException(f\"Missing or malformed 'vector_store_ids' in: {spec}\")\n    return OpenAIAssistantAgent.configure_file_search_tool(vector_store_ids=vector_store_ids)\n\n\ndef _build_tool(spec: ToolSpec, kernel: \"Kernel\") -> tuple[list[AssistantToolParam], ToolResources]:\n    if not spec.type:\n        raise AgentInitializationException(\"Tool spec must include a 'type' field.\")\n\n    try:\n        builder = _TOOL_BUILDERS[spec.type.lower()]\n    except KeyError as exc:\n        raise AgentInitializationException(f\"Unsupported tool type: {spec.type}\") from exc\n\n    sig = inspect.signature(builder)\n    return builder(spec) if len(sig.parameters) == 1 else builder(spec, kernel)  # type: ignore[call-arg]\n\n\n# endregion\n","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/open_ai/openai_assistant_agent.py#L97-L133","documentation":"Raised by the 'file_search' tool builder when a ToolSpec's options lack a usable vector_store_ids value. The builder requires a non-empty list whose first element is truthy, because OpenAI file search needs at least one existing vector store id to query.","triggerScenarios":"Defining a declarative tool of type 'file_search' where options.vector_store_ids is missing, is not a list, or is an empty/None-first-element list (e.g. {'vector_store_ids': [None]} or {'vector_store_ids': []}).","commonSituations":"Forgetting to create the vector store first and capture its id; passing a single string instead of a list; referencing a variable that is None at spec-build time; typos like 'vectorStoreIds'.","solutions":["Create the vector store via the OpenAI client and capture the returned id, then pass it as a list.","Ensure options={'vector_store_ids': ['vs_abc123']} (a non-empty list with a real id).","Validate vector_store_ids is a list and its first element is a non-empty string before building the tool.","Check the key spelling is exactly 'vector_store_ids' (snake_case)."],"exampleFix":"# before\ntool = ToolSpec(type=\"file_search\", options={\"vector_store_ids\": vs_id})  # vs_id is a str or None\n# after\nvs = await client.beta.vector_stores.create(name=\"docs\")\ntool = ToolSpec(type=\"file_search\", options={\"vector_store_ids\": [vs.id]})","handlingStrategy":"validation","validationCode":"vs_ids = spec.options.get(\"vector_store_ids\")\nif not vs_ids or not isinstance(vs_ids, list) or not vs_ids[0]:\n    raise ValueError(\"file_search requires options['vector_store_ids'] as a non-empty list of store ids.\")\n# all good -> build the tool","typeGuard":"def is_valid_vector_store_ids(v) -> bool:\n    return isinstance(v, list) and len(v) > 0 and all(isinstance(i, str) and i for i in v)","tryCatchPattern":null,"preventionTips":["Create the vector store first and pass its id in a list.","Use the exact key 'vector_store_ids' (snake_case).","Validate the option shape before building a file_search tool spec."],"tags":["openai","semantic-kernel","agents","tools","file-search","declarative-spec","validation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}