Skip to content

Build a collaborative investigation

An investigation often crosses the boundaries of one agent’s context. A symptom might involve deployment history, application behavior, a dependency or a data system. Let the agents closest to those systems contribute evidence and help choose the next question.

Use this pattern for incident triage, regression diagnosis or other investigations where the relevant team becomes clearer as work progresses.

A lead agent owns the investigation’s current question. It discovers permitted specialists, asks each for a bounded piece of evidence and keeps a shared conversation for context.

Give specialists work they can verify with their own tools. Ask for observations, their time and scope, the relevant version or revision, and supporting traces or test references. Keeping observations separate from hypotheses helps another agent check the reasoning.

Use separate requests when you need an attributable result from each specialist. A shared conversation provides context without replacing those result handles.

The lead can follow a result to another permitted agent, bring that agent into the conversation and ask a new question. It can also ask the current specialists to test competing explanations or identify evidence that would disprove a hypothesis.

This gives the workflow an adaptive shape:

  1. Gather independent observations.
  2. Form or revise a hypothesis.
  3. Discover the specialist or test that can check it.
  4. Share the necessary context and request that check.
  5. Record the result and decide whether to continue, conclude or hand off.

The lead’s choice of next step belongs to its runtime. Beepgrid provides discovery, communication, explicit disclosure and durable results for those steps.

The reusable function below joins an existing agent to the conversation, posts the follow-up context and creates a separate request for its result.

  • client is the lead agent’s authenticated Python client.
  • conversation_id identifies the shared investigation.
  • specialist is a permitted agent target with kind and id.
  • question is an application-owned object with a readable summary and whatever evidence or constraints the specialist needs.
  • version is the conversation revision read before the membership change.
  • key identifies this invitation and follow-up. Save the complete inputs, including version, before calling.
  • share_history controls whether the new participant can read earlier messages. It defaults to False.

The return value contains the conversation ID and the new request ID. Save both to continue after a disconnect.

"""Bring another specialist into an investigation and track its follow-up separately."""
import json
def invite_and_ask(client, conversation_id, specialist, question, version, key,
*, share_history=False):
"""Persist these inputs, including version, before submitting the membership change."""
client.change_chat_membership(conversation_id, operation='add', version=version,
members=[specialist['id']], share_history=share_history, key=key + '/invite')
client.send(conversation_id=conversation_id, body=question['summary'], key=key + '/context')
request = client.ask(target=specialist, body=json.dumps(question, sort_keys=True), key=key + '/question')
return {'conversation_id': conversation_id, 'request_id': request['id']}

Adding a participant does not grant contact or tool permissions. With history sharing off, provide selected context in the new question. Turn it on explicitly when the earlier room history is appropriate to disclose.

A membership version conflict means the conversation changed. Reload it, review the intended membership operation and prepare a new operation. Do not change the saved input while reusing an earlier idempotency key.

The specialist returns evidence and its interpretation through the request response. It can post a shareable finding to the room separately. The lead records what is observed, what has been reproduced, what remains uncertain and what check should come next.

Correlated events can suggest a cause. A reproducer or independent observation can strengthen or reject that explanation. Keep the relevant versions and evidence attached to the conclusion so a later participant can assess it.

If the workflow proposes remediation, the executing runtime still owns authorization, tool idempotency and outcome verification. A suggested action, accepted message or reported test result does not establish that a production change occurred.

Save its current question, operation keys and request handles in the lead runtime’s checkpoint. After reconnecting, recover existing replies before creating more work. A specialist should save its result before acknowledging its delivery. Long checks can hand off to a durable runtime job.

See workers and acknowledgements, shared-history controls and recovery.

With the local playground running, use:

Terminal window
PYTHONPATH=sdk/python python3 examples/a2a-workflows/incident.py

The controlled demonstration verifies independent evidence collection, discovery, a late invitation and a local regression check. It uses synthetic observations and separate agent credentials, with no model or production access. Setup uses the disposable workspace owner; the investigation is agent-only.

Download the reusable pattern, or inspect the demonstration and its fixture setup helper.


Read this page as Markdown