{"record":{"id":"353a0cc6f9da5433","repo":"microsoft/semantic-kernel","slug":"count-must-be-an-integer-in-spec","errorCode":null,"errorMessage":"'count' must be an integer in: {spec}","messagePattern":"'count' must be an integer in: (.+?)","errorType":"validation","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/azure_ai/azure_ai_agent.py","lineNumber":155,"sourceCode":"def _azure_function(spec: ToolSpec) -> ToolDefinition:\n    # TODO(evmattso): Implement Azure Function tool support\n    raise NotImplementedError(\"Azure Function tools are not yet supported with the Azure AI Agent Declarative Spec.\")\n\n\n@_register_tool(\"bing_grounding\")\ndef _bing_grounding(spec: ToolSpec) -> BingGroundingTool:\n    opts = spec.options or {}\n\n    connections = spec.options.get(\"tool_connections\")\n    if not connections or not isinstance(connections, list) or not connections[0]:\n        raise AgentInitializationException(f\"Missing or malformed 'tool_connections' in: {spec}\")\n    conn_id = connections[0]\n\n    market = opts.get(\"market\", \"\")\n    set_lang = opts.get(\"set_lang\", \"\")\n    count = opts.get(\"count\", 5)\n    if not isinstance(count, int):\n        raise AgentInitializationException(f\"'count' must be an integer in: {spec}\")\n    freshness = opts.get(\"freshness\", \"\")\n\n    return BingGroundingTool(connection_id=conn_id, market=market, set_lang=set_lang, count=count, freshness=freshness)\n\n\n@_register_tool(\"code_interpreter\")\ndef _code_interpreter(spec: ToolSpec) -> CodeInterpreterTool:\n    file_ids = spec.options.get(\"file_ids\")\n    return CodeInterpreterTool(file_ids=file_ids) if file_ids else CodeInterpreterTool()\n\n\n@_register_tool(\"file_search\")\ndef _file_search(spec: ToolSpec) -> FileSearchTool:\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 FileSearchTool(vector_store_ids=vector_store_ids)\n","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/azure_ai/azure_ai_agent.py#L137-L173","documentation":"Raised when a bing_grounding tool spec's count option is present but not a Python int. count controls how many Bing search results the grounding tool considers.","triggerScenarios":"Setting count as a string (e.g. \"5\") or float in the declarative spec, typically from untyped config injection.","commonSituations":"Config templating injects numbers as strings; YAML scalar quoted as a string; copy-paste from a JSON sample.","solutions":["Provide count as an integer literal.","Coerce externally loaded config: int(opts['count']) before spec construction.","Omit count to accept the default of 5."],"exampleFix":"// before\noptions:\n  tool_connections:\n    - \"/.../myBingConn\"\n  count: \"5\"\n\n// after\noptions:\n  tool_connections:\n    - \"/.../myBingConn\"\n  count: 5","handlingStrategy":"validation","validationCode":"def coerce_count(opts: dict):\n    c = opts.get(\"count\", 5)\n    if not isinstance(c, int):\n        raise TypeError(\"count must be int\")\n    return c","typeGuard":"def count_is_int(opts: dict) -> bool:\n    return isinstance(opts.get(\"count\", 5), int)","tryCatchPattern":null,"preventionTips":["Coerce externally loaded numeric options to int before constructing the spec.","Use a typed schema (Pydantic) to enforce int typing at parse time."],"tags":["azure-ai-agent","declarative-spec","bing-grounding","type-validation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}