feat: inject run_id as cache_salt for per-epoch resampling (algo #10)

This commit is contained in:
2026-07-16 06:33:09 -04:00
parent 58a0203522
commit 9be3bdb8eb
4 changed files with 27 additions and 3 deletions
+11
View File
@@ -94,6 +94,17 @@ def _invalid_tool_json() -> str:
class TestAgentLoop:
"""AgentLoop 推理循环引擎测试。"""
@pytest.mark.asyncio
async def test_forwards_cache_salt(self) -> None:
"""AgentLoop.run(cache_salt=...) 透传到 llm.chat(算法 #10 跨 epoch 重采样)。"""
llm = AsyncMock()
llm.chat.return_value = _make_response(_submit_json())
loop = AgentLoop(llm=llm, max_steps=10)
await loop.run("system", "user", _StubDispatcher(), cache_salt="run:e2")
assert llm.chat.call_args.kwargs["cache_salt"] == "run:e2"
@pytest.mark.asyncio
async def test_submit_answer_terminates_loop(self) -> None:
"""submit_answer 终止循环 → finished, result=args, steps_used=1。"""
+1
View File
@@ -698,6 +698,7 @@ class TestConcurrencyControl:
*,
session_id: str | None = None,
parent_call_id: str | None = None,
cache_salt: str | None = None,
) -> LLMResponse:
nonlocal current_concurrent, max_concurrent
current_concurrent += 1