Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / Agent safety

Intercept or redact content in a live bidirectional agent session

Inspect content before it reaches a live model stream and block or replace the turn when needed.

Goal

Add content filtering and redaction to live interaction so blocked content does not reach the model.

Steps

  1. Define input/output segments to inspect, blocking policy, and user-facing notice. [live]
  2. Use LlmAgent.before_model_callback / after_model_callback or corresponding BasePlugin callbacks; define when to return a replacement LlmResponse. [live]
  3. Return a replacement response or end the turn for policy-triggering content so the original is not sent onward. [live]
  4. Test allowed, redacted, and rejected cases; ensure callbacks do not copy secrets into logs. [live]

How to verify

Blocked segments do not reach later model calls, allowed content continues, and audit logs omit sensitive payloads.

Troubleshooting

If a turn continues after replacement, verify the callback return and termination semantics; disable export first if logs leak data.

Permissions

Prerequisites

Permissions

Limitations

This procedure follows Google ADK at the pinned revision; other versions, models, or remote services may differ in APIs and event semantics. Recheck permissions, retention, and recovery before production.

Pinned upstream source

https://github.com/google/adk-python/blob/e9b74d36140f2594b24c481fb7a3825b2cb01e96/docs/guides/flows/llm_flows/base_llm_flow/live_model_callbacks.md

Repository
google/adk-python
File path
docs/guides/flows/llm_flows/base_llm_flow/live_model_callbacks.md
Pinned commit
e9b74d36140f2594b24c481fb7a3825b2cb01e96
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: Apache-2.0

Main topic

Make Agent behavior safer and easier to verify

Related resources