Totoro f8ca969330
feat(examples): add opt-in advisory fetched-content screening (#5833)
* feat(examples): add opt-in fetched-content screening extension

* fix(examples): screen sync and async results through supported middleware hooks

* fix(examples): preserve empty message IDs when applying screening warnings

* fix(examples): include screening policy in assembly identity

* feat(examples): load fetched-content screening through the extension entry

Package the screening example as a plugins: extension instead of an
operator-configured middleware. install() validates the private config
and, once enabled, contributes one TOOL_VISIBLE middleware for lead
agents and subagents. The package imports only deerflow_extension_api.

Extension tool wrappers are observational, so detection and the warning
use two supported contracts: the tool wrapper classifies the visible
result and records flagged tool-call IDs in the run's task store, and
before_model replaces the matching messages of the latest tool step by
ID. The excerpt sent to Jev is now the redacted, sanitized text the
model sees. Runs without a task store send nothing. Unexpected local
errors surface as isolation diagnostics; provider errors fail open.

Tests load the package through load_extensions() and the host isolation
wrapper and run real lead/subagent graphs with a task store bound as the
Gateway worker binds it. The README records what the example exercised
in the extension API and the gaps it found.

* fix(examples): classify each tool message of a screened result on its own

A Command result was classified as one concatenated excerpt and the flag
landed on its first text message, so a benign first result could take the
warning while an injected later result reached the model unmarked.

Each text message now gets its own bounded excerpt and Jev request, for at
most eight messages per tool call. The requests share one client and run
concurrently in a task group, each under its own deadline, so one slow or
failed request cannot hide another message's flag. Every flagged message's
tool-call ID is recorded. The message cap joins the declared policy, and the
README describes the per-message requests and data sharing.

---------

Co-authored-by: Totoro-qaq <279883115+Totoro-qaq@users.noreply.github.com>
2026-09-25 14:38:59 +08:00

25 lines
667 B
TOML

[project]
name = "deerflow-extension-jev-screening"
version = "0.1.0"
description = "Opt-in advisory screening of fetched content, contributed as a DeerFlow extension middleware"
readme = "README.md"
requires-python = ">=3.12"
license = "MIT"
dependencies = [
"deerflow-extension-api>=0.2.3,<0.3",
"httpx>=0.28,<1",
"langchain>=1.3,<2",
"langgraph>=1.2.9,<1.3",
"pydantic>=2.12,<3",
]
[project.entry-points."deerflow.extensions"]
jev-screening = "deerflow_extension_jev_screening:install"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["deerflow_extension_jev_screening"]