Reuse the Anthropic code execution container across tool loop steps

Merged
SU
3d ago
+191-1

when an agent has CodeExecution plus a regular tool the follow up request never sends the container id back
so every step lands in a fresh sandbox and whatever the model wrote to disk in the earlier step is gone

repro on claude-sonnet-5-5
step 1 runs python that writes /tmp/probe_token.txt then calls the client tool
step 2 runs cat /tmp/probe_token.txt and gets No such file or directory since it's a different container
same thing with stream()

this reads container.id off the response (message_delta.delta.container when streaming) and carries it in the existing continuationToken so the next step sends it as container
same repro after the change prints the token back on both prompt() and stream()
a container you already set through provider options is left alone
it also covers pause_turn since the docs say that continuation needs the id too

https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool#container-reuse

if you'd rather keep continuationToken for response ids only I can move this to its own field