feat: carry the new observability fields through retry and cache
This commit is contained in:
@@ -194,6 +194,35 @@ class TestSuccessPath:
|
||||
assert (await limiter.source_stats("a")).tpm_used == 16
|
||||
|
||||
|
||||
class TestObservabilityPassthrough:
|
||||
"""issue #3: transport 采到的两个可观测字段必须原样上浮到 LLMResponse。"""
|
||||
|
||||
async def test_fields_reach_the_response(self):
|
||||
result = TransportResult(
|
||||
content="ok",
|
||||
thinking="",
|
||||
prompt_tokens=10,
|
||||
completion_tokens=5,
|
||||
usage_source="measured",
|
||||
ttft_ms=12.0,
|
||||
max_inter_token_ms=3.0,
|
||||
raw={},
|
||||
cached_prompt_tokens=64,
|
||||
model_reported="MiniMax-Text-01-250321",
|
||||
)
|
||||
mw, *_ = _harness([_src("a")], [result])
|
||||
resp = await mw(_REQ)
|
||||
assert resp.cached_prompt_tokens == 64
|
||||
assert resp.model_reported == "MiniMax-Text-01-250321"
|
||||
# model 仍是配置别名: 真实版本是旁证,不顶替溯源主字段
|
||||
assert resp.model == "m"
|
||||
|
||||
async def test_absent_fields_stay_none(self):
|
||||
mw, *_ = _harness([_src("a")], [_ok()])
|
||||
resp = await mw(_REQ)
|
||||
assert resp.cached_prompt_tokens is None and resp.model_reported is None
|
||||
|
||||
|
||||
class TestRetryAndFailover:
|
||||
async def test_transient_switches_source_then_succeeds(self):
|
||||
mw, _, _, transport, sleep, _ = _harness(
|
||||
|
||||
Reference in New Issue
Block a user