Skip to content

Python: Workflow as an Agent don't work with threads #2754

@furoTmark

Description

@furoTmark

The documentation suggests that workflows can take as argument AgentThreads and can work with them.

However, from my test, this isn't the case.

{
  "type": "agent_thread_state",
  "service_thread_id": null,
  "chat_message_store_state": {
    "type": "chat_message_store_state",
    "messages": [
      {
        "type": "chat_message",
        "role": { "type": "role", "value": "user" },
        "contents": [{ "type": "text", "annotations": null, "text": "test" }],
        "author_name": null,
        "message_id": null,
        "additional_properties": {}
....
      {
        "type": "chat_message",
        "role": { "type": "role", "value": "assistant" },
        "contents": [
          {
            "type": "text",
            "annotations": null,
            "text": "Hello! How can I assist you today? If you have a document to work with, a question, or need help creating something, just let me know!"
          }
        ],
...
      {
        "type": "chat_message",
        "role": { "type": "role", "value": "user" },
        "contents": [
          {
            "type": "text",
            "annotations": null,
            "text": "what color is the sky?"
          }
        ],
....
      {
        "type": "chat_message",
        "role": { "type": "role", "value": "assistant" },
        "contents": [
          {
            "type": "text",
            "annotations": null,
            "text": "The color of the sky is usually **blue** during the daytime, due to the scattering of sunlight by the atmosphere. At sunrise or sunset, it can appear **red, orange, pink, or purple**. At night, the sky is typically **dark** or **black**, sometimes dotted with stars.\n\nWould you like more details about why the sky appears these colors?"
          }
        ],
...
      {
        "type": "chat_message",
        "role": { "type": "role", "value": "user" },
        "contents": [
          {
            "type": "text",
            "annotations": null,
            "text": "what was the last question I asked you?"
          }
        ],
...
      {
        "type": "chat_message",
        "role": { "type": "role", "value": "assistant" },
        "contents": [
          {
            "type": "text",
            "annotations": null,
            "text": "You just asked: \"what was the last question I asked you?\""
          }
        ],
,,,
      {
        "type": "chat_message",
        "role": { "type": "role", "value": "user" },
        "contents": [
          {
            "type": "text",
            "annotations": null,
            "text": "what did we talk about in this thread?"
          }
        ],
...
      {
        "type": "chat_message",
        "role": { "type": "role", "value": "assistant" },
        "contents": [
          {
            "type": "text",
            "annotations": null,
            "text": "In this thread, you asked: \"what did we talk about in this thread?\"\n\nThere have been no previous discussions or messages prior to this one. If you have any specific topics or past conversations you'd like to reference, please let me know!"
          }
        ],
...

If I try this with an agent, it works.
I tested the workflow as an agent with configuring FileCheckpointStorage as well.
In this case, I could see that each checkpoint was a completely new conversation.

Is this a bug, or is this a limitation of as_agent() for workflows?

Metadata

Metadata

Assignees

Labels

pythonv1.0Features being tracked for the version 1.0 GAworkflowsRelated to Workflows in agent-framework

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions