generated from coulomb/repo-seed
Pass instruction depth config to llm-connect
This commit is contained in:
@@ -30,14 +30,24 @@ from activity_core.rules.executor import (
|
||||
class _NullLLM:
|
||||
"""Always returns an empty task list."""
|
||||
|
||||
def complete(self, prompt: str, model: str = "") -> str:
|
||||
def complete(
|
||||
self,
|
||||
prompt: str,
|
||||
model: str = "",
|
||||
config: dict | None = None,
|
||||
) -> str:
|
||||
return "[]"
|
||||
|
||||
|
||||
class _BadLLM:
|
||||
"""Returns invalid JSON on every call."""
|
||||
|
||||
def complete(self, prompt: str, model: str = "") -> str:
|
||||
def complete(
|
||||
self,
|
||||
prompt: str,
|
||||
model: str = "",
|
||||
config: dict | None = None,
|
||||
) -> str:
|
||||
return "not valid json {"
|
||||
|
||||
|
||||
@@ -47,9 +57,16 @@ class _CountingLLM:
|
||||
def __init__(self, responses: list[str]) -> None:
|
||||
self._responses = list(responses)
|
||||
self.call_count = 0
|
||||
self.calls: list[dict | None] = []
|
||||
|
||||
def complete(self, prompt: str, model: str = "") -> str:
|
||||
def complete(
|
||||
self,
|
||||
prompt: str,
|
||||
model: str = "",
|
||||
config: dict | None = None,
|
||||
) -> str:
|
||||
self.call_count += 1
|
||||
self.calls.append(config)
|
||||
if self._responses:
|
||||
return self._responses.pop(0)
|
||||
return "[]"
|
||||
@@ -77,6 +94,10 @@ def _instr(
|
||||
model: str = "claude-sonnet-4-6",
|
||||
output_schema: str = "",
|
||||
review_required: bool = False,
|
||||
temperature: float | None = None,
|
||||
max_tokens: int | None = None,
|
||||
max_depth: int | None = None,
|
||||
model_params: dict[str, Any] | None = None,
|
||||
) -> SimpleNamespace:
|
||||
return SimpleNamespace(
|
||||
id=id,
|
||||
@@ -84,6 +105,10 @@ def _instr(
|
||||
trusted_fields=trusted_fields or [],
|
||||
prompt=prompt,
|
||||
model=model,
|
||||
temperature=temperature,
|
||||
max_tokens=max_tokens,
|
||||
max_depth=max_depth,
|
||||
model_params=model_params or {},
|
||||
output_schema=output_schema,
|
||||
review_required=review_required,
|
||||
)
|
||||
@@ -225,6 +250,31 @@ def test_execute_instruction_with_audit_returns_metadata():
|
||||
assert result.review_required is True
|
||||
|
||||
|
||||
def test_execute_instruction_forwards_llm_connect_run_config():
|
||||
llm = _CountingLLM(["[]"])
|
||||
instr = _instr(
|
||||
prompt="Check State Hub.",
|
||||
trusted_fields=[],
|
||||
model="custodian-triage-balanced",
|
||||
temperature=0.2,
|
||||
max_tokens=1200,
|
||||
max_depth=2,
|
||||
model_params={"reasoning_effort": "medium"},
|
||||
)
|
||||
|
||||
execute_instruction_with_audit(instr, _Event(), {}, llm)
|
||||
|
||||
assert llm.calls == [
|
||||
{
|
||||
"model_name": "custodian-triage-balanced",
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 1200,
|
||||
"max_depth": 2,
|
||||
"model_params": {"reasoning_effort": "medium"},
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
def test_execute_instruction_with_audit_accepts_report_payload():
|
||||
report_data = {
|
||||
"summary": "State Hub has loose ends.",
|
||||
@@ -312,6 +362,22 @@ def test_review_required_field_on_instruction_def():
|
||||
assert defn.review_required is True
|
||||
|
||||
|
||||
def test_instruction_def_accepts_llm_connect_depth_config():
|
||||
defn = InstructionDef(
|
||||
id="test",
|
||||
trusted_fields=[],
|
||||
model="custodian-triage-balanced",
|
||||
temperature=0.2,
|
||||
max_tokens=1200,
|
||||
max_depth=2,
|
||||
model_params={"reasoning_effort": "medium"},
|
||||
prompt="p",
|
||||
output_schema="schema.json",
|
||||
)
|
||||
assert defn.max_depth == 2
|
||||
assert defn.model_params == {"reasoning_effort": "medium"}
|
||||
|
||||
|
||||
def test_review_required_defaults_to_false():
|
||||
defn = InstructionDef(
|
||||
id="test",
|
||||
|
||||
Reference in New Issue
Block a user