Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/anthropic/lib/tools/_beta_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ def __run__(self) -> Iterator[RunnerItemT]:
message = self._get_last_message()
assert message is not None

# Update container from response for programmatic tool calling support
if message.container is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephaniepang97 Can we, instead of using the container.id from the last API response, rely on the last assistant message (runner._get_last_assistant_message_content)? The user might change the state during the loop (e.g., in a for block via set_messages_params), so we should take the ID from the last message in the current state, not from the last API response

self._params["container"] = message.container.id

self._iteration_count += 1

# If the compaction was performed, skip tool call generation this iteration
Expand Down Expand Up @@ -497,6 +501,10 @@ async def __run__(self) -> AsyncIterator[RunnerItemT]:
message = await self._get_last_message()
assert message is not None

# Update container from response for programmatic tool calling support
if message.container is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a simple test for this case to make sure we’re sending container.id back? We can use a snapshot with a real example and record it, like we do in the other tests.

self._params["container"] = message.container.id

self._iteration_count += 1

# If the compaction was performed, skip tool call generation this iteration
Expand Down
Loading