Awesome Reviewers

Reviewer · AI

Multi-agent context integrity

When orchestrating multi-agent LLM pipelines (debates, hierarchical swarms, planner/generator/evaluator loops, councils, round-robins), the conversation/message context actually sent to a model must match what the prompt claims and what the pipeline requires — no more, no less.

Instruction

When orchestrating multi-agent LLM pipelines (debates, hierarchical swarms, planner/generator/evaluator loops, councils, round-robins), the conversation/message context actually sent to a model must match what the prompt claims and what the pipeline requires — no more, no less.

Concretely:

  • Scope state per invocation. Shared conversation objects (e.g. self.conversation) must be reset or re-scoped at the start of each top-level run(); otherwise a second call on the same instance silently replays a prior run’s turns into the new task’s context.
  • Never drop turns a prompt depends on. When slicing history (e.g. split_last_turn, “prior turns only”), verify the dropped turn isn’t the one the next prompt relies on (the original task, the immediately preceding speaker’s output, etc.). Reusing a slicing helper from another component without re-checking its assumptions is a common source of this bug.
  • Don’t assert context that may not exist. Prompt text like “the conversation above” or “read the conversation above” is only safe if you’ve confirmed messages_for(...) (or equivalent) is guaranteed non-empty and correctly ordered relative to the task for every call site. If emptiness or ordering can vary, either guard with an explicit check/fallback or word the prompt so it degrades gracefully instead of inviting the model to hallucinate missing content.
  • Propagate all instructions needed to use new capabilities. If you attach a tool/schema to an agent (e.g. a director gets an order-batch tool), also attach the protocol/instructions explaining how to use it (valid target names, expected format), or a caller-supplied agent will have the capability but not the knowledge to use it correctly.

Example of a context-dropping bug to avoid:

# BAD: silently drops the newest turn the next prompt depends on
prior, last = split_last_turn(history)
agent.run(task, messages=prior, ...)  # loses original task / prior speaker's output

# GOOD: pass the full relevant history the prompt actually needs
messages = messages_for(current_agent.agent_name, self.conversation)
agent.run(task, messages=messages, ...)

Before merging changes that touch shared conversation state, multi-turn prompts, or message slicing, add a test that runs the pipeline twice on one instance and/or inspects the actual messages payload to confirm it contains exactly the turns the prompt text promises.