google / google/adk-python

sample: Model Armor tool-output screening via after_tool_callback

オープン
#6,964 コメント 1 件 リアクション 0 件 担当者 1 名 @sanketpatil06 が担当を希望しています GitHub で見る
needs review tools
主要言語
Python
スター
21.5k
フォーク
4k
平均マージ
1日 14時間
マージ済み PR(30日)
37

説明

### Is your feature request related to a specific problem?

The first-party `ModelArmorPlugin` documents that **tool output is not screened**:

https://github.com/google/adk-python/blob/main/docs/guides/integrations/model_armor/index.md#limitations

Tool results arrive as `user` content whose only part is a `function_response`, which the plugin does not send to Model Armor. Agentic pipelines that ingest external text via tools (issues, email, web search, MCP) often need screening on **tool output**, not just user prompts and model replies.

### Describe the Solution You'd Like

Add a minimal sample under `contributing/samples/integrations/model_armor_tool_output/` demonstrating a companion plugin on `after_tool_callback` that stringifies tool results and calls Model Armor's `SanitizeUserPrompt` API, registered alongside `ModelArmorPlugin` on the same `App`.

### Impact on your work

We run a multi-tool agent control plane where the primary injection vector is hostile content returned as tool output. We use a custom `after_tool_callback` plugin today; a first-party sample would reduce unsafe copy-paste from older adk-samples safety-plugins code.

No critical deadline.

### Willingness to contribute

Yes

### Describe Alternatives You've Considered

- Using `ModelArmorSafetyFilterPlugin` from adk-samples: older callback shapes; not the ADK 2.8 first-party integration path.
- Waiting for core plugin extension: larger API design (tracked separately as a follow-up feature request).

### Proposed API / Implementation

```python
class ToolOutputModelArmorPlugin(BasePlugin):
async def after_tool_callback(
self, *, tool, tool_args, tool_context, result, **kwargs
):
text = stringify(result)
if not text:
return None
# Call modelarmor SanitizeUserPrompt on text; return error dict if MATCH_FOUND
```

Sample registers `[ModelArmorPlugin(...), ToolOutputModelArmorPlugin(...)]` on one `App`.

### Additional context

- The limitation is documented in the adk-python integration guide under **Limitations**.
- I will open a PR referencing this issue the same day if maintainers are open to the approach.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。