Miracle778
|
5a699e24a1
|
feat(guardrails): expose authenticated runtime context in GuardrailRequest (#3665)
* docs: guardrail runtime attribution spec
* docs: guardrail request attribution implementation plan
* feat(guardrails): add runtime user context and attribution fields to GuardrailRequest
Extend GuardrailRequest with optional runtime attribution fields so that
pluggable GuardrailProviders can access authenticated user context and
tool-call-level attribution:
- Gateway injects user_role, oauth_provider, oauth_id into runtime context
alongside the existing user_id (server-authenticated only, client spoofing
prevented)
- GuardrailRequest gains: user_id, user_role, oauth_provider, oauth_id,
run_id, tool_call_id (all optional, backward compatible)
- GuardrailMiddleware reads these from ToolCallRequest.runtime.context
- thread_id now actually populated from context (was always None before)
- Tests: 15 new/expanded tests covering Gateway injection, runtime context
reading, partial/missing fields, and client spoofing prevention
- Docs: new Runtime Attribution section in GUARDRAILS.md with provider
example and YAML policy illustration
* fix(guardrails): propagate attribution to subagents
* fix(guardrails): complete subagent attribution propagation
---------
Co-authored-by: Miracle778 <miracle778@no-reply.com>
|
2026-06-21 16:08:25 +08:00 |
|