Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State Management does not work with OpenAIAssistantAgent #5130

Open
ssbnord opened this issue Jan 21, 2025 · 0 comments
Open

State Management does not work with OpenAIAssistantAgent #5130

ssbnord opened this issue Jan 21, 2025 · 0 comments

Comments

@ssbnord
Copy link

ssbnord commented Jan 21, 2025

What happened?

This tutorial works for AssistantAgent not for OpenAIAssistantAgent. It looks like the save_state and load_state methods use the default impl here which return

{'type': 'BaseState', 'version': '1.0.0'}

It works as expected for AssistantAgent.

What did you expect to happen?

State management should work for OpenAIAssistantAgent similar to AssistantAgent.

How can we reproduce it (as minimally and precisely as possible)?

import asyncio
from autogen_ext.agents.openai import OpenAIAssistantAgent
from autogen_core import CancellationToken

from autogen_agentchat.messages import TextMessage
from openai import AsyncAzureOpenAI
import os


async def example():

    async_model_client = AsyncAzureOpenAI(
        api_key = os.environ.get("API_KEY"),
        azure_endpoint = os.environ.get("API_BASE"),
        api_version= "2024-07-01-preview",
    )

    agent = OpenAIAssistantAgent(name="FunnyAgent",
                            description="Tells jokes",
                            client=async_model_client,
                            model="gpt-4o",
                            instructions="You tell jokes.",
                        )

    response = await agent.on_messages(
        [TextMessage(source="user", content="Tell me a joke")], CancellationToken()
    )

    print(response.chat_message.content)

    agent_state = await agent.save_state()
    print(agent_state)

asyncio.run(example())

Observe that the agent state is returned as

{'type': 'BaseState', 'version': '1.0.0'}

AutoGen version

0.4.2

Which package was this bug in

Extensions

Model used

gpt-4o

Python version

3.12.8

Operating system

MacOS 15.2

Any additional info you think would be helpful for fixing this bug

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant