Pass instruction depth config to llm-connect

This commit is contained in:
2026-05-19 20:55:35 +02:00
parent 1ff8b14d1b
commit 5c4f96e7aa
6 changed files with 208 additions and 16 deletions

View File

@@ -10,10 +10,15 @@ from activity_core import activities
class FakeLLMClient:
def __init__(self, response: str) -> None:
self.response = response
self.calls: list[tuple[str, str]] = []
self.calls: list[tuple[str, str, dict | None]] = []
def complete(self, prompt: str, model: str = "") -> str:
self.calls.append((prompt, model))
def complete(
self,
prompt: str,
model: str = "",
config: dict | None = None,
) -> str:
self.calls.append((prompt, model, config))
return self.response
@@ -56,7 +61,9 @@ async def test_evaluate_instructions_returns_task_specs_with_audit(monkeypatch)
assert spec["prompt_hash"] is not None
assert len(spec["prompt_hash"]) == 64
assert result["reports"] == []
assert llm.calls == [("Open tasks: 3", "test-model")]
assert llm.calls == [
("Open tasks: 3", "test-model", {"model_name": "test-model"})
]
@pytest.mark.asyncio
@@ -94,7 +101,12 @@ async def test_evaluate_instructions_returns_report_payload(monkeypatch) -> None
@pytest.mark.asyncio
async def test_evaluate_instructions_without_llm_client_returns_no_tasks(monkeypatch) -> None:
class RaisingClient:
def complete(self, prompt: str, model: str = "") -> str: # noqa: ARG002
def complete(
self,
prompt: str,
model: str = "",
config: dict | None = None,
) -> str: # noqa: ARG002
raise RuntimeError("not configured")
monkeypatch.setattr(activities, "get_llm_client", lambda: RaisingClient())
@@ -114,3 +126,36 @@ async def test_evaluate_instructions_without_llm_client_returns_no_tasks(monkeyp
})
assert result == {"task_specs": [], "reports": []}
@pytest.mark.asyncio
async def test_evaluate_instructions_forwards_llm_connect_depth_config(monkeypatch) -> None:
llm = FakeLLMClient(json.dumps({"summary": "ok", "recommendations": []}))
monkeypatch.setattr(activities, "get_llm_client", lambda: llm)
await activities.evaluate_instructions({
"instructions": [
{
"id": "daily-triage-report",
"trusted_fields": [],
"model": "custodian-triage-balanced",
"temperature": 0.2,
"max_tokens": 1200,
"max_depth": 2,
"model_params": {"reasoning_effort": "medium"},
"prompt": "Run report.",
"output_schema": "schemas/daily-triage-report.json",
"review_required": False,
}
],
"event": {},
"context": {},
})
assert llm.calls[0][2] == {
"model_name": "custodian-triage-balanced",
"temperature": 0.2,
"max_tokens": 1200,
"max_depth": 2,
"model_params": {"reasoning_effort": "medium"},
}