Skip to content

Feat/content safety decision - #1196

Open
wujiaming-ai wants to merge 14 commits into
mainfrom
feat/content-safety-decision
Open

wujiaming-ai wants to merge 14 commits into
mainfrom
feat/content-safety-decision

Conversation

@wujiaming-ai

Copy link
Copy Markdown
Collaborator

No description provided.

@wujiaming-ai
wujiaming-ai force-pushed the feat/content-safety-decision branch from 3e0e8bf to 4dbf6cf Compare November 3, 2026 06:51
wujiaming-ai and others added 12 commits November 4, 2026 15:25
Add an opt-in content safety plugin that audits content at the model and
tool lifecycle checkpoints through the System One decision API. The default
provider remains none and nothing is mounted automatically.

- strict tool.content_safety configuration with Ark connection defaults
- strict decision response arbitration and on_error policy
- streaming partial suppression with final aggregated audit
- audited SkillToolset load/resource/script/list/search tools
- LLM Shield adapter and real-ADK E2E coverage

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Exercise the real Ark System One endpoint through the production plugin
path when VEADK_CONTENT_SAFETY_LIVE=1 and a key are supplied. Normal test
runs skip it so no CI job calls the production service by accident.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Rename ContentSafetyPlugin to DecisionPlugin to match the reviewed
architecture, remove the skill pre-audit adapter from this change, and
use StateBuilder.build_after_model for model-output auditing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Only derive the System One endpoint from a known Ark HTTPS base. Require
an explicit decision.api_key for custom endpoints so Ark credentials are
never silently sent to another provider.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ADK may attach hidden reasoning as Part(thought=True). Auditing that text
caused benign final answers to be blocked after the model had already
produced safe visible output. Filter hidden thought parts from after_model
state and preserve them when replacing visible event text.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The legacy LLM Shield module constructs a plugin at import time, so a
config-only llm_shield_app_id was read too late and startup failed unless
TOOL_LLM_SHIELD_APP_ID was already exported. Set the env inside the lock
before importing, and restore it even when the import raises.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Move the Decision API protocol into veadk.decision with typed request and
response models. content_safety now adapts its question configuration at the
boundary and consumes the typed response, keeping the dependency one-way.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Prevent non-Ark credentials from being reused for an explicit Ark decision
endpoint. Audit visible text in mixed text/function-call events, run legacy
LLM Shield callbacks outside the event loop, load .env before applying
decision overrides, reject plaintext remote endpoints, and store API keys as
SecretStr. Add regression coverage for each fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Mount the content-safety plugin from VeADK Runner and AgentKit when
`tool.content_safety` is present, so callers no longer have to load the
config, build the plugin, and wire it into App manually.

- Agent gains an optional `content_safety` field (None/False/True/dict/config)
  and a `content_safety_plugins` property for manually built ADK Apps.
- `load_content_safety_config_if_present()` treats missing files or blocks as
  disabled while still failing fast on invalid configuration.
- Plugin resolution deduplicates by name and keeps explicitly supplied plugins.
- Runner now supports app-only construction while injecting plugins.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- merge five built-in questions for provider=decision
- allow per-name overrides and appends, add use_default_questions
- fix question type to noul and reject user-supplied type

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- prepend fixed audit policy outside the untrusted payload
- shorten built-in question instructions
- keep truncation limited to dynamic content

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@wujiaming-ai
wujiaming-ai force-pushed the feat/content-safety-decision branch from 59dfc5c to e810148 Compare November 4, 2026 07:27
wujiaming-ai and others added 2 commits November 4, 2026 17:00
- merge the documented 12 categories with existing defaults
- add self_harm, child_safety, and fraud_social_engineering
- keep existing names and the 0.5 default threshold

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Lower thresholds for safety-critical categories (child safety and
self-harm) and raise them for broad, high-false-positive categories such
as compute abuse and public order. Export the per-question threshold
mapping and update tests to assert the tiering.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant