Skip to content
in/guard/out
in/guard/out

Docs · Guides

Let a subagent read sensitive data

The main agent needs a conclusion from an HR record – "is a review due?" – not the record itself. Let a subagent read it and pass back only a cleaned answer.

Use this when your agent hands work to subagents (for example Claude Code’s Task tool, or your own spawn_agent).

Two things make this safe:

  • A subagent starts with its parent’s restrictions. If the parent has read HR data, so has the subagent – delegating is never a way around a room.
  • A subagent’s answer is checked on its way back. With a cleaning rule, the parent gets “Alice’s review is due” without the salary, and stays out of the HR room itself.

1. Send the parent header from your subagents

Every request a subagent makes should carry its parent’s run id:

extra_headers={
    "X-Guardrails-Session-Id": child_run_id,
    "X-Guardrails-Parent-Session-Id": parent_run_id,
}

2. Mark the spawn tool

In Tools this agent used, set the spawn tool to Starts a subagent (or click its suggestion).

The tools table with spawn_agent set to “Starts a subagent”

Without this, a spawn tool counts as sending data somewhere unknown, and is refused while the parent holds confidential data.

3. Check the setup list

The setup checklist now watches for the parent header:

Setup: Subagents send X-Guardrails-Parent-Session-Id – never seen on this key

Never seen on this key means your harness isn’t sending it yet. Only mark a tool as Starts a subagent once it does – the rule trusts that the subagent inherits the parent’s restrictions through that header.

4. Clean what comes back

Set up the confidential data as in Keep confidential data in, and choose Clean it in step 5. Cleaning applies to subagent answers as well as chat answers: the parent receives the subagent’s answer with names and numbers removed.

Stricter option. In the Advanced editor → Data flow → Subagents, tick Only accept cleaned answers. A subagent answer that no cleaning rule covers is then withheld instead of passing the room on to the parent.