Skip to content

Python: Bug: AgentGroupChat | ChatCompletionAgent | Complete chat history is getting passed to llm #12144

Closed
@pintuiitbhi

Description

@pintuiitbhi

Describe the bug
There is two agent - Agent1 and Agent2. I am using AgentGroupChat using ChatCompletionAgent. It is multi turn conversation based. Then complete chat history is getting passed to llm. Each agent has its own Kernel instance.
This is what currently I observerd from two DEBUG logs of Semantic-Kernel

Image

This is the each item content in json_data for a llm api calls request has -

ROLE, CONTENT

  1. system, Agent1 Prompt
  2. user, task
  3. assistant, tool_calls
  4. tool, tool_calls result
  5. assistant, Agent1 response
  6. assistant, Agent1 response
  7. assistant, Agent2 Prompt
  8. assistant, Agent1 response
  9. assistant, Agent1 response
  10. assistant, Agent2 response

As its clear for more iterations it will pass more such messages and we will get token limit exceeded error.
Currently for my use case I just need this for any llm api call

  1. system prompt
    2, user task
  2. assistant tool_calls
  3. tool response
  4. assistant response
  5. assistnat response

To Reproduce
Steps to reproduce the behavior:

  1. This can be observed in Semantic Kernel DEBUG log for any multi-turn group chat for atleast 10 iterations

Expected behavior
6 message items should be enough.

When its turn then this should be the llm api call payload:

  1. system prompt
    2, user task
  2. assistant tool_calls
  3. tool response
  4. assistant response
  5. assistnat response

When its turn then this should be the llm api call payload:

  1. system prompt
    2, user task
  2. assistant tool_calls
  3. tool response
  4. assistant response
  5. assistnat response

Screenshots
If applicable, add screenshots to help explain your problem.

Platform

  • Language: Python
  • Source: main branch , 1.30.0 Semantic kernel version
  • AI model: Currently I used gpt-4o using Azure
  • IDE: Vscode
  • OS: Windows

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

agentsbugSomething isn't workingpythonPull requests for the Python Semantic Kernel

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions