Tool calls returned as messages

It’s not clear from any of your documentation that tool calls would be included in the list of messages from a call to an Agent/LLM. Is this intentional?

Do you have any examples of how to best work with the messages returned from an Agent.run() call? I was trying to log these via OpenTelemetry by looping through the List created by:

messages = [m.model_dump(include={“role”, “content”}) for m in run_response.messages]

Is it preferable to read the messages from Agent.memory or from elsewhere in the session vs. the RunResponse itself?

Thanks!

Hello @Adam

Yes, the inclusion of tool calls in the list of messages returned by an Agent.run() call is intentional. This design ensures that all interactions, including tool invocations are captured within the message sequence, providing a comprehensive record of the agent’s operations.

Regarding your approach to logging these messages via OpenTelemetry, accessing the messages directly from the RunResponse object, as you’ve done with run_response.messages is appropriate. This method provides a complete and immediate view of the agent’s activity during that specific run.

I appreciate the quick response. Glad to hear I’m not misunderstanding things. :slight_smile:

Not sure if posts in here are tracked as “issues” with any kind of status, but feel free to close if so.

1 Like

Feel free to reach out if you have any other questions @Adam, I am closing this question now.