[Bug] Anthropic API Error: Missing Tool Result Block

Resolved 💬 5 comments Opened Oct 3, 2025 by Aldohlys Closed Jan 6, 2026

Bug Description
== ACTION ===
I provided console output to claude code :
source('analysis/an_line.R')

Listening on http://127.0.0.1:7332
simu-output$legs
Using manual lignes
simu-output$legs
Loading portfolio
readPortfolioDate
Using portfolio data
output$pos
2025-10-03 10:01:22 DEBUG [R] (Tuser)::(doTryCatch) : Loading historical data from cache for 2 legs
2025-10-03 10:01:23 ERROR [R] (Tuser)::(3) : Cache load error: argument inutilisé (x[[i]])
Avis : No trace type specified and no positional attributes specified
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plotly.com/r/reference/#scatter
No scatter mode specifed:
Setting the mode to markers
Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
2025-10-03 10:01:43 INFO [R] (Tuser)::(observe) : Starting IBKR retrieval for 2 legs
2025-10-03 10:01:43 DEBUG [R] (Tuser)::(.f) : Updating contract: GLD 350C 20251017
[2025-10-03 10:01:43] [PY] [INFO] (tdata_py.historical_option_data) Loaded config: 3 contracts
[2025-10-03 10:01:49] [PY] [ERROR] (tdata_py.IB_connection) IB connection failed {host=127.0.0.1, port=7496, client_id=7930, exception_type=TimeoutError, exception_message=}
Traceback (most recent call last):
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\asyncio\tasks.py", line 456, in wait_for
return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users/aldoh/Documents/RApplication/Tuser/renv/library/windows/R-4.4/x86_64-w64-mingw32/Tdata/python\tdata_py\IB_connection.py", line 64, in safe_ib_connect
ib.connect(host, port, clientId=client_id, readonly=readonly)
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\ib_insync\ib.py", line 269, in connect
return self._run(self.connectAsync(
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\ib_insync\ib.py", line 308, in _run
return util.run(*awaitables, timeout=self.RequestTimeout)
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\ib_insync\util.py", line 341, in run
result = loop.run_until_complete(task)
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\ib_insync\ib.py", line 1708, in connectAsync
await asyncio.wait_for(self.reqExecutionsAsync(), timeout)
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\asyncio\tasks.py", line 458, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
2025-10-03 10:01:49 DEBUG [R] (Tuser)::(.f) : Updating contract: GLD 360C 20251017
[2025-10-03 10:01:49] [PY] [INFO] (tdata_py.historical_option_data) Loaded config: 3 contracts
[2025-10-03 10:01:55] [PY] [ERROR] (tdata_py.IB_connection) IB connection failed {host=127.0.0.1, port=7496, client_id=8756, exception_type=TimeoutError, exception_message=}
Traceback (most recent call last):
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\asyncio\tasks.py", line 456, in wait_for
return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users/aldoh/Documents/RApplication/Tuser/renv/library/windows/R-4.4/x86_64-w64-mingw32/Tdata/python\tdata_py\IB_connection.py", line 64, in safe_ib_connect
ib.connect(host, port, clientId=client_id, readonly=readonly)
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\ib_insync\ib.py", line 269, in connect
return self._run(self.connectAsync(
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\ib_insync\ib.py", line 308, in _run
return util.run(*awaitables, timeout=self.RequestTimeout)
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\ib_insync\util.py", line 341, in run
result = loop.run_until_complete(task)
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\ib_insync\ib.py", line 1708, in connectAsync
await asyncio.wait_for(self.reqExecutionsAsync(), timeout)
File "C:\Users\aldoh\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\asyncio\tasks.py", line 458, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
2025-10-03 10:01:55 INFO [R] (Tuser)::(doTryCatch) : IBKR retrieval completed successfully
2025-10-03 10:01:55 DEBUG [R] (Tuser)::(doTryCatch) : Loading historical data from cache for 2 legs
2025-10-03 10:01:55 ERROR [R] (Tuser)::(3) : Cache load error: argument inutilisé (x[[i]])

=== CONSOLE OUTPUT ====

⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.61: tool_use ids were
found without tool_result blocks immediately after: toolu_013u7hGsE8R5nhXvcrkTyegZ. Each tool_use block must
have a corresponding tool_result block in the next message."},"request_id":"req_011CTjv4YQmafcTnTCXzW3pV"}

Environment Info

  • Platform: win32
  • Terminal: null
  • Version: 2.0.5
  • Feedback ID: b9976e4f-f679-47d8-b3d9-f2e0dda7842c

Errors

Note: Error logs were truncated.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗