Skip to content

feat: add guarded durable-memory ADK recipe - #2507

Open
vgudur-dev wants to merge 4 commits into
google:mainfrom
vgudur-dev:contrib/amg-memory-guard
Open

vgudur-dev wants to merge 4 commits into
google:mainfrom
vgudur-dev:contrib/amg-memory-guard

Conversation

@vgudur-dev

Copy link
Copy Markdown

Summary

This contribution adds a standalone community recipe that places OWASP Agent Memory Guard (AMG) at the durable-session-state boundary of a Google ADK agent. It retains a benign external observation while blocking a representative indirect prompt-injection payload before it reaches session state.

The recipe follows the repository’s standalone Python layout and includes a manifest, pyproject.toml, environment example, runnable agent module, README, and isolated tests.

Demonstrated control boundary

Tool-derived observations are marked as EXTERNAL_TOOL, every proposed durable write passes through MemoryGuard(policy=Policy.strict()), and ADK state is updated only after AMG permits the operation. A blocked write returns structured security information for the application’s logging or incident workflow.

Validation

The recipe passed the repository’s recipe validation, manifest schema, placement checks, README checks, Ruff format/lint checks, and two isolated no-network tests. It uses no model API key and makes no production-security guarantee; it is a focused implementation pattern for an ADK durable-memory boundary.

@vgudur-dev
vgudur-dev requested a review from happyhuman as a code owner August 13, 2026 05:50
@google-cla

google-cla Bot commented Aug 13, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment thread contrib/python/amg-memory-guard/amg_memory_guard_adk/agent.py
Comment thread contrib/python/amg-memory-guard/amg_memory_guard_adk/agent.py Outdated
Comment thread contrib/python/amg-memory-guard/amg_memory_guard_adk/agent.py Outdated
Comment thread contrib/python/amg-memory-guard/pyproject.toml Outdated
Comment thread contrib/python/amg-memory-guard/pyproject.toml
Comment thread contrib/python/amg-memory-guard/README.md Outdated
Comment thread contrib/python/amg-memory-guard/tests/test_runnability.py Outdated
[project]
name = "amg-memory-guard"
version = "0.1.0"
description = "Guard Google ADK durable session-state writes with OWASP Agent Memory Guard."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match description in manifest.yaml ("A Google ADK recipe that screens external observations before they are committed to durable session state."), and check_recipe_pyproject.py fails the PR when the two disagree. I suggest matching this one to the manifest.

"rule": exc.rule,
}

tool_context.state["guarded_external_observation"] = content

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the state write happens whatever action comes back as, since only a raised PolicyViolation skips it. Is allow the only outcome that doesn't raise?

if tool_context is None:
return {"status": "error", "message": "ADK tool context is required."}

session_id = tool_context._invocation_context.session.id

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_invocation_context isn't guarded like tool_context just above

@@ -0,0 +1 @@
MODEL_NAME=gemini-3.5-flash

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MODEL_NAME is the only key here — should GOOGLE_GENAI_USE_VERTEXAI and the credentials vars go in too? contrib/python/market-research-agent/.env.example has them, and the README sends the reader through cp .env.example .env before adk run.

@@ -0,0 +1,18 @@
"""Google ADK durable-memory protection recipe."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

licence header sits under the docstring in this one

@happyhuman happyhuman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please go through the comments, and also the failed workflows and fix them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants