{"record":{"id":"8d8effe34b9ff2ab","repo":"rohitg00/ai-engineering-from-scratch","slug":"tc-mode","errorCode":null,"errorMessage":"tc.mode","messagePattern":"tc\\.mode","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/13-tools-and-protocols/02-function-calling-deep-dive/code/main.py","lineNumber":113,"sourceCode":"            {\n                \"name\": tool.name,\n                \"description\": tool.description,\n                \"parameters\": _gemini_schema(tool.input_schema),\n            }\n        ]\n    }\n\n\ndef tool_choice_openai(tc: ToolChoice) -> Any:\n    if tc.mode == \"auto\":\n        return \"auto\"\n    if tc.mode == \"none\":\n        return \"none\"\n    if tc.mode == \"required\":\n        return \"required\"\n    if tc.mode == \"force\":\n        return {\"type\": \"function\", \"function\": {\"name\": tc.tool_name}}\n    raise ValueError(tc.mode)\n\n\ndef tool_choice_anthropic(tc: ToolChoice) -> dict:\n    if tc.mode == \"auto\":\n        return {\"type\": \"auto\"}\n    if tc.mode == \"none\":\n        return {\"type\": \"none\"}\n    if tc.mode == \"required\":\n        return {\"type\": \"any\"}\n    if tc.mode == \"force\":\n        return {\"type\": \"tool\", \"name\": tc.tool_name}\n    raise ValueError(tc.mode)\n\n\ndef tool_choice_gemini(tc: ToolChoice) -> dict:\n    mode_map = {\"auto\": \"AUTO\", \"none\": \"NONE\", \"required\": \"ANY\"}\n    if tc.mode in mode_map:\n        return {\"function_calling_config\": {\"mode\": mode_map[tc.mode]}}","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/13-tools-and-protocols/02-function-calling-deep-dive/code/main.py#L95-L131","documentation":"Error \"tc.mode\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/13-tools-and-protocols/02-function-calling-deep-dive/code/main.py:113 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}