Skip to content

[BUG][deep_discussion][The whole transcript becomes the next speaker message, roughly doubling context each turn] #2050

Description

@kyegomez

Summary

In one_on_one_debate, each speaker's entire transcript becomes the next speaker's message. Since Agent.run returns the whole conversation by default, context roughly doubles every turn — by turn 3 the message contains turn 1 twice — and both agents also accumulate it in their own memory on top.

Where

swarms/structs/deep_discussion.py:53-61:

for i in range(max_loops):
    # Current speaker responds
    response = speaker.run(task=message, img=img)
    conversation.add(speaker.agent_name, response)

    # Swap roles
    message = response
    speaker, other = other, speaker

response is whatever the caller's agents produce, and Agent's output_type defaults to "str-all-except-first" (swarms/structs/agent.py:349) — the agent's entire conversation, not its answer. message = response then makes that blob the next prompt.

Effect

Turn 1: A answers → response ≈ A's answer.
Turn 2: B receives A's whole transcript as its task, and B's response is B's whole transcript, which now contains A's.
Turn 3: A receives that, so A's own turn-1 output comes back to it — mislabelled as the user's words, and duplicated.

Growth is roughly geometric in max_loops, and each agent's own short_memory grows alongside because run records the incoming task too.

Suggested fix

Two changes, both small:

  1. Pass the answer, not the transcript:
    from swarms.structs.context_utils import agent_answer
    response = speaker.run(task=message, img=img)
    answer = agent_answer(speaker, fallback=response)
    conversation.add(speaker.agent_name, answer)
    message = answer
  2. Better, deliver the shared conversation as typed turns so each speaker sees its own prior output as assistant rather than as user prose:
    from swarms.structs.context_utils import messages_for, split_last_turn
    prior, turn_task = split_last_turn(messages_for(speaker.agent_name, conversation))
    response = speaker.run(task=turn_task, messages=prior, img=img)
    (See [BUG][Multi-Agent Structures][Every structure flattens the shared conversation into one user block, defeating the Agent-side transcript fix] #2029 / [BUG][Agent.run][A caller-supplied messages= is silently discarded, so structures cannot pass typed turns] #2030.)

deep_discussion.py does get one thing right: it builds a fresh Conversation() inside the function (:39), so there is no cross-task leakage.

Found at 3e89f27b (v14.0.2).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions