请求侧改为直接拦截,宿主统一渲染 OpenAI 错误体

response_guard.lua:判定通过直接 pass,原始请求一字不改转发上游;不通过直接 block。删除 stub 替换逻辑,风险请求不再让上游白跑一次生成。

middleware/errors.py:PolicyBlocked 携带 code。middleware/runtime.py:block 的 reason 经白名单映射成 code,插件文本不进响应。middleware/proxy.py:PolicyBlocked 输出 OpenAI 错误体(400 content_policy_violation / 503 safety_review_unavailable),替换原来的 403 {error: PolicyBlocked}。

tools/verify_plugins.py:断言同步到新流程。
This commit is contained in:
Автомата Калашникова committed 2026-11-27 17:52:52 +08:00
1 parent 9218bdf1e8
commit af7b2e28f3
5 files changed
+89 -96

No files matched your search

+9 -1
View File
@@ -7,7 +7,15 @@ class PluginFailure(MiddlewareError):
class PolicyBlocked(MiddlewareError):
pass
"""A plugin rejected the request.
``code`` is one of a closed set of tokens (see runtime.BLOCK_CODES). Plugin-supplied
text must never reach the response body, so anything outside that set is normalised.
"""
def __init__(self, code: str = "content_policy_violation") -> None:
super().__init__(code)
self.code = code
class Overloaded(MiddlewareError):