Repository navigation
gpt5.2 can not use tool call #8137
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
AI_TypeValidationError: Type validation failed: Value: {"id":"chatcmpl-DA8EwctrvVTROgoDH5iNKQNyJublr","object":"chat.completion","created":1768234868,"model":"gpt-5.2-pro-2025-12-11","system_fingerprint":null,"choices":[{"delta":{"content":"我来直接用 opencode 的终端在该目录上统计文件数(分别给出“仅当前目录”和“含子目录”两种)。","reasoning_content":"","reasoning":"","role":"assistant","tool_calls":[{"id":"fc_0f8bca84f2bce1940069651fbe6f988195a92c21863e7f1395","type":"function","function":{"name":"bash","arguments":"{\"command\":\"powershell -NoProfile -Command \\\"$p='D:\\\\codex-workspaces\\\\Cursor\\\\logs\\\\20260112191206TP105779863040719752408801F'; if(!(Test-Path -LiteralPath $p)){Write-Error ('Path not found: ' + $p); exit 2}; $non=(Get-ChildItem -LiteralPath $p -File -Force).Count; $rec=(Get-ChildItem -LiteralPath $p -File -Force -Recurse).Count; Write-Host ('non_recursive_files=' + $non); Write-Host ('recursive_files=' + $rec)\\\"\",\"description\":\"Count files in logs directory via PowerShell\",\"timeout\":120000,\"workdir\":\"D:\\\\codex-workspaces\\\\Cursor\"}"}}]},"logprobs":null,"finish_reason":null,"index":0}],"usage":{"prompt_tokens":26722,"completion_tokens":612,"total_tokens":27334,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":0,"audio_tokens":0,"image_tokens":0},"completion_tokens_details":{"text_tokens":0,"audio_tokens":0,"reasoning_tokens":395},"input_tokens":0,"output_tokens":0,"input_tokens_details":null,"output_tokens_details":null,"claude_cache_creation_5_m_tokens":0,"claude_cache_creation_1_h_tokens":0}}. Error message: [{"code":"invalid_union","errors":[[{"expected":"number","code":"invalid_type","path":["choices",0,"delta","tool_calls",0,"index"],"message":"Invalid input: expected number, received undefined"}],[{"expected":"object","code":"invalid_type","path":["error"],"message":"Invalid input: expected object, received undefined"}]],"path":[],"message":"Invalid input"}]
Plugins
No response
OpenCode version
1.1.5
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
github-actions commentedon Jan 13, 2026
This issue might be a duplicate of existing issues. Please check:
The common thread appears to be type validation failures when models attempt to use tool calls. #7439 looks particularly relevant as it also affects GPT-5.2 on the AIHubMix provider with the same invalid_union error pattern.
Feel free to ignore if none of these address your specific case.
rekram1-node commentedon Jan 13, 2026
@1436107040 try updating to latest
VallyZeng commentedon Jan 13, 2026
I’m seeing the same issue. Using this config:
pp-codex: {
npm: @ai-sdk/openai-compatible,
options: {
baseURL: https://baseurl.com/v1,
apiKey: sk-xx
},
models: {
gpt-5.2-codex: {
name: GPT-5.2-codex,
limit: {
context: 272000,
output: 128000
},
options: {
thinking: {
type: enabled,
budgetTokens: 32000
}
}
}
}
}
The output is filled with excessive “Thinking/Preparing/Executing…” text, and the tool call (e.g., ls) returns no output. Example:
Check what files are in the current working directory.
17:45
Thinking: Listing directory contentsListing files with bash in workdirExecuting shell commandUsing shell toolInitiating call actionRecognizing a commandAcknowledging readinessInitiating callEncouraging immediate actionDetermining the working directoryUtilizing shell commandsStarting taskPreparing to invoke toolAcknowledging confirmationAssuming working directoryPreparing to run shell commandAttempting a known callProceeding with executionExecuting shell commandActing under constraintsPreparing JSON formatPreparing to apply formatting toolConfirming tool channel usagePreparing to write analysisPlanning to make a callProceeding with next stepAcknowledging readinessExecuting next stepPreparing output for toolInitiating next stepReconsidering approach to tool call placementSeparating tool call messageSending tool call with commentary channelUtilizing new message with toolAcknowledging readinessProceeding to deliverPreparing final tool callPreparing to send with tool callConfirming readinessPreparing to send tool callSending messageConfirming task completionPreparing to list filesStarting next stepPreparing to make a callReconsidering tool call placementSwitching to comment modeSending confirmationCorrecting message formattingConfirming output channelSending tool callAcknowledging readinessRouting message to commentary channelWaiting for tool outputPreparing outputHandling empty results gracefullyWaiting for tool responseChecking command outputWaiting for tool output
I wasn’t able to retrieve the directory listing—no output came back from the ls call. Want me to try again, or specify the exact path you want listed?
...
Is this a known issue? Any recommended config or workaround to avoid the verbose thinking output and make tool calls return correctly?
OpenCode version
1.1.16
brick0808 commentedon Jan 13, 2026
I also encountered the same problem.
canxin121 commentedon Jan 13, 2026
Same problem
NeverMore93 commentedon Jan 14, 2026
I uograde to latest version, it's does not work;
AI_TypeValidationError: Type validation failed: Value: {"id":"chatcmpl-DBAdmketv9HUmHZu7F1ZgVzNDlzLs","object":"chat.completion","created":1768377350,"model":"gpt-5.2-pro-2025-12-11","system_fingerprint":null,"choices":[{"delta":{"content":"我先用工具列出可访问目录并扫一下工作区顶层文件,确认 tool 调用链路正常。","reasoning_content":"","reasoning":"","role":"assistant","tool_calls":[{"id":"fc_011c7377fd35cc0c0069674c6e9f58819289262c5ace323ca8","type":"function","function":{"name":"filesystem_list_allowed_directories","arguments":"{}"}},{"index":1,"id":"fc_011c7377fd35cc0c0069674c6e9f688192ba7f98ec8628daf2","type":"function","function":{"name":"glob","arguments":"{\"path\":\"D:\\\\codex-workspaces\\\\OpenCode\",\"pattern\":\"*\"}"}}]},"logprobs":null,"finish_reason":null,"index":0}],"usage":{"prompt_tokens":22849,"completion_tokens":896,"total_tokens":23745,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":0,"audio_tokens":0,"image_tokens":0},"completion_tokens_details":{"text_tokens":0,"audio_tokens":0,"reasoning_tokens":802},"input_tokens":0,"output_tokens":0,"input_tokens_details":null,"output_tokens_details":null,"claude_cache_creation_5_m_tokens":0,"claude_cache_creation_1_h_tokens":0}}. Error message: [{"code":"invalid_union","errors":[[{"expected":"number","code":"invalid_type","path":["choices",0,"delta","tool_calls",0,"index"],"message":"Invalid input: expected number, received undefined"}],[{"expected":"object","code":"invalid_type","path":["error"],"message":"Invalid input: expected object, received undefined"}]],"path":[],"message":"Invalid input"}]tyrellshawn commentedon Jan 18, 2026
I resolved this by using opencode auth login and setting open ai/chat gpt plus. I am guessing its the same since the model is the same gpt-5.2 model
rekram1-node commentedon Jan 18, 2026
What provider are you using that doesnt work? I cannot replicate this at all
tyrellshawn commentedon Jan 18, 2026
Open AI with Chat GPT pro subscription. I uninstalled and reinstalled opencode in wsl and kept getting this error:
By logging back in to Open AI using opencode auth login again resolved this issue for me.
NeverMore93 commentedon Jan 20, 2026
I use third party provider.
AI_TypeValidationError: Type validation failed: Value: {"id":"chatcmpl-DBGM1lsFuo5VLBFaDwMPUhNX3xz1C","object":"chat.completion","created":1768902536,"model":"gpt-5.2-pro-2025-12-11","system_fingerprint":null,"choices":[{"delta":{"content":"","reasoning_content":"","reasoning":"","role":"assistant","tool_calls":[{"id":"fc_01a86141dbb1408f00696f4fde32208199b16573d12cd97421","type":"function","function":{"name":"read","arguments":"{\"filePath\":\"D:\\\\AI\\\\AI.txt\",\"limit\":2000,\"offset\":0}"}},{"index":1,"id":"fc_01a86141dbb1408f00696f4fde322c8199a48b15ed9bdfd9f2","type":"function","function":{"name":"bash","arguments":"{\"command\":\"python - <<'PY'\\nimport zipfile, re\\nfrom pathlib import Path\\np = Path(r'D:\\\\AI\\\\Luban AI平台设计方案---AI生成版本.docx')\\nwith zipfile.ZipFile(p) as z:\\n xml = z.read('word/document.xml').decode('utf-8', errors='ignore')\\n# crude xml to text: keep paragraph breaks\\nxml = re.sub(r'</w:p>', '\\\\n', xml)\\nxml = re.sub(r'<[^>]+>', '', xml)\\nxml = xml.replace('<','<').replace('>','>').replace('&','&')\\n# cleanup multiple newlines\\nlines = [line.strip() for line in xml.splitlines()]\\ntext = '\\\\n'.join([l for l in lines if l])\\nprint(text)\\nPY\",\"description\":\"Extract text from docx via python\",\"timeout\":120000,\"workdir\":\"/\"}"}}]},"logprobs":null,"finish_reason":null,"index":0}],"usage":{"prompt_tokens":12222,"completion_tokens":1030,"total_tokens":13252,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":0,"audio_tokens":0,"image_tokens":0},"completion_tokens_details":{"text_tokens":0,"audio_tokens":0,"reasoning_tokens":766},"input_tokens":0,"output_tokens":0,"input_tokens_details":null,"output_tokens_details":null,"claude_cache_creation_5_m_tokens":0,"claude_cache_creation_1_h_tokens":0}}. Error message: [{"code":"invalid_union","errors":[[{"expected":"number","code":"invalid_type","path":["choices",0,"delta","tool_calls",0,"index"],"message":"Invalid input: expected number, received undefined"}],[{"expected":"object","code":"invalid_type","path":["error"],"message":"Invalid input: expected object, received undefined"}]],"path":[],"message":"Invalid input"}]NeverMore93 commentedon Jan 21, 2026
I see so many user enconter same issues
allarac commentedon Feb 13, 2026
Yes, no agents works for me using ollama.
rekram1-node commentedon Feb 13, 2026
If you are using ollama make sure you follow the guide in docs:
https://opencode.ai/docs/providers/#ollama
github-actions commentedon Apr 15, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.