feat: preserve governed OpenAI tool messages in 1.4.0

Add faithful single-choice chat results, tool stream activity, error-frame retries, and isolated protocol caching.

Reject empty cached completions with the same value predicate as transport, add regression coverage, and adopt Apache-2.0.
This commit is contained in:
2026-10-01 14:32:19 -04:00
parent 0e29deac1a
commit 9185eab8c9
42 changed files with 2227 additions and 78 deletions
+6
View File
@@ -20,6 +20,7 @@ from .types import (
OcrLayoutTransportResult,
OcrTextResult,
OcrTextTransportResult,
ResponseMode,
SourceConfig,
SourceStats,
TelemetryStatus,
@@ -40,6 +41,10 @@ class Middleware(Protocol):
class Transport(Protocol):
"""一次原始调用的协议细节(请求组装/流式解析/错误翻译);不含任何治理。
`response_mode` 为必填返回契约:openai 成功必须提供 completion,
不支持者应 RequestRejected,不能静默退回文本。工具的实际增量与首次身份
同正文/推理共用活性事件;同帧只置位一次,重复身份不算进展。
`reasoning_effort` 是本次调用要求的推理档位(`None` = 不表态,随源级配置)。
它必须走**协议参数**而不能让 transport 自己去读 `ChatRequest`: 端口只收拆开的
请求要素,是为了让 transport 不依赖洋葱内部的请求类型(P7 端口最内层)。
@@ -70,6 +75,7 @@ class Transport(Protocol):
reasoning_effort: Effort | None,
first_token_event: asyncio.Event | None,
content_event: asyncio.Event | None,
response_mode: ResponseMode,
) -> TransportResult: ...