Skip to main content
Lesson 13 of 14 · Multi-Agent Research

Multi-turn conversations with previous_response_id

Lesson 13 of 14 Updated July 29, 2026 Developer
On this page
  1. Refine the search turn by turn
  2. Chain queries with previous_response_id
  3. Three ways to run a session
  4. The same with the xAI SDK
  5. Knowing when to stop a session
  6. Key takeaways

Refine the search turn by turn

You might imagine multi-agent as a single-query machine: one massive question in, a complete report out. That’s its least efficient use. Real investigation moves in steps, each answer opening the next question. Multi-agent works this way too: chain queries while keeping context to start broad, then narrow down.

Chain queries with previous_response_id

With the Responses API, chaining relies on previous_response_id: you pass the previous response’s ID to each call, and the model picks up the thread.

# Turn 1: overview
response1 = client.responses.create(
    model="grok-4.20-multi-agent-0309",
    reasoning={"effort": "low"},
    input=[{"role": "user", "content": "Overview of RAG frameworks in 2026"}],
)

# Turn 2: deep dive (references previous turn)
response2 = client.responses.create(
    model="grok-4.20-multi-agent-0309",
    reasoning={"effort": "medium"},
    input=[{"role": "user", "content": "Deep dive into the mentioned hybrid architectures"}],
    previous_response_id=response1.id,
)

# Turn 3: targeted comparison
response3 = client.responses.create(
    model="grok-4.20-multi-agent-0309",
    reasoning={"effort": "high"},
    input=[{"role": "user", "content": "Compare Pinecone and Weaviate for this use case"}],
    previous_response_id=response2.id,
)

Notice the progression in reasoning effort: low for the initial map, medium for the deep dive, high for the final comparison. This reflects underlying logic—don’t spend compute power until you know what to spend it on. The agents know what’s already been said and don’t rebuild the ground every turn.

Three ways to run a session

The funnel, from broad to specific

This is the most natural and economical trajectory. The first turn, run with four agents, maps the subject and surfaces angles. The second, still with four agents, zooms in on the one that concerns you. Only the third turn mobilizes sixteen agents to analyze the identified point in depth. You deploy the large team only once you’re sure what you’re looking for, instead of paying for exhaustive exploration where 90% won’t serve you.

Lateral exploration

Sometimes an answer reveals an unexpected angle. You ask about LLM deployment challenges in production, the leader mentions latency issues in passing, and that’s where your project hinges. The next turn starts from that mention—“you mentioned latency issues, what solutions exist?”—then the third compares the semantic caching approaches discussed. Each question picks up the exact vocabulary from the previous turn, which targets searches much better.

Cross-validation

This approach aims for reliability over discovery. You ask for Mistral Large 3 performance benchmarks, then have independent sources verify those figures, and finish by looking for contradictions between them. The third turn is the most instructive: it turns an assured answer into a state of knowledge where uncertainty is explicit.

The same with the xAI SDK

The native SDK makes chaining implicit: the chat object holds the history, you just add successive messages.

chat = client.chat.create(
    model="grok-4.20-multi-agent-0309",
    agent_count=4,
    use_encrypted_content=True,
)

# Turn 1
chat.append(user("Overview of RAG frameworks in 2026"))
for response, chunk in chat.stream():
    if chunk.content:
        print(chunk.content, end="", flush=True)

# Turn 2 (same chat object = context preserved)
chat.append(user("Deep dive into hybrid architectures"))
for response, chunk in chat.stream():
    if chunk.content:
        print(chunk.content, end="", flush=True)

use_encrypted_content=True makes a real difference here: without it, only the exchanged text is kept; with it, the sub-agents’ internal state survives from turn to turn and search continuity improves.

Knowing when to stop a session

The mechanism has limits, all related to accumulation. Context grows with every turn and eventually saturates the context window; encrypted content contributes to this, with sub-agent state taking up space; consistency erodes as the leader holds a vaster history; and costs follow, with every turn billing all accumulated tokens.

In practice, stick to three to five turns per session. Beyond that, open a new session with a synthesis prompt summarizing your conclusions: this clean, condensed context often proves more effective than the stretched conversation you abandon.

Key takeaways

  • previous_response_id chains queries while keeping context
  • Funnel strategy (broad → specific) optimizes costs
  • use_encrypted_content=True preserves sub-agent state between turns
  • Limit yourself to 3-5 turns per session to keep consistency and costs manageable
  • Start with 4 agents and increase as needed