Skip to content

Bug: LiteLLMModel compatibility with ChatMessage format in fastacp.py #2

@vinayak-shanawad

Description

@vinayak-shanawad

Hi Nick,

Greetings!!

When attempting to integrate and run fastacp.py with smolagents.models.LiteLLMModel, the script consistently encounters AttributeError: 'dict' object has no attribute 'role'.

This prevents the ACPCallingAgent from successfully making calls to the LiteLLMModel.

Steps to Reproduce:

  1. Ensure a smolagents environment is set up and litellm is installed (pip install 'smolagents[litellm]').
  2. Have acp_sdk installed and running locally with agents at http://localhost:8000 and http://localhost:8001 (as per the test.py setup).
  3. Use the fastacp.py script (specifically, the version prior to the recent fixes).
  4. Execute the L8.ipynb notebook provided in the repository.

Expected Behavior:
The ACPCallingAgent should successfully interact with the LiteLLMModel, process messages, call relevant ACP agents, and return a final answer without errors.

Actual Behavior (Error Trace Snippet):
Calling model with messages: [{'role': 'system', 'content': "..."}] Error details - message format: [{'role': 'system', 'content': "..."}] Error details - tools: ['policy_agent', 'health_agent'] [ERROR] Error while generating or parsing output:'dict' object has no attribute 'role' [ERROR] Error in step 1: Error while generating or parsing output:'dict' object has no attribute 'role'

Root Cause:
The smolagents.models.LiteLLMModel (and the underlying smolagents.models.ChatMessage class and internal message processing via get_clean_message_list) has a strict expectation for the format of chat messages. The previous fastacp.py script was passing messages either as plain Python dictionaries or smolagents.models.ChatMessage objects whose content attribute was a simple string.

Environment:

  • Python Version: [3.12]
  • smolagents version: [1.20.0]
  • litellm version: [1.72.6]
  • acp_sdk version: [1.0.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions