Open
Description
Hi! We are encountering a regression after updating to v1.14.0.
Specifically, it's due to this change from #1148, which modified the to_messages
method to no longer include the tool call ID in the returned message:
- "text": (f"Call id: {self.tool_calls[0].id}\n" if self.tool_calls else "")
- + f"Observation:\n{self.observations}",
+ "text": f"Observation:\n{self.observations}",
It's a little hacky, but we were parsing the "Call id" section for our custom Anthropic model.
Anthropic requires that you pass in the tool_use_id
for tool results (see here), and parsing it from the string was the only way we could figure out how to retrieve that ID in the context of a custom model.
Code example
We were doing something like this:
from smolagents import Model
class AnthropicModel(Model):
def __call__(
self,
messages: list[dict[str, str]],
stop_sequences: list[str] | None = None,
grammar: str | None = None,
tools_to_call_from: list[Tool] | None = None,
**kwargs: Any,
) -> ChatMessage:
# ... abbreviated code
# this is the part where we construct the Anthropic-format messages from the provided messages dict
for message in messages:
if message["role"] == MessageRole.TOOL_RESPONSE:
# parse call id from message["content"][0]["text"]
# (search for "Call id: ..." section)
which no longer works.