Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

feat(examples): let the typed-decisions workflow32 runner set temperature (#679)

svonava415f2f4dc04b
diff --git a/examples/typed-decisions/workflow32/README.md b/examples/typed-decisions/workflow32/README.md
index 8d0fcae9d..96198b50f 100644
--- a/examples/typed-decisions/workflow32/README.md
+++ b/examples/typed-decisions/workflow32/README.md
@@ -45,9 +45,10 @@ budget covers reasoning as well as the final JSON. `--thinking on` requests
may override that request. The runner records caller settings without claiming
to verify actual server configuration. Use `--thinking off` or
`--thinking server` to record a different configuration; the latter omits the
-template override. `--max-completion-tokens` and `--timeout` are explicit
-overrides and remain visible in `plan.json`. Results with different settings
-are different runs.
+template override. `--max-completion-tokens`, `--timeout` and `--temperature`
+are explicit overrides and remain visible in `plan.json`; `--temperature 0`
+reproduces the separately published temperature-0 treatment. Results with
+different settings are different runs.
Every case runs once, in source order, with no truncation, tools, retry,
synthetic probe or warmup. The first ordinary case gates continuation on a
diff --git a/examples/typed-decisions/workflow32/run.py b/examples/typed-decisions/workflow32/run.py
index afb9bded3..0b3e6d9f4 100644
--- a/examples/typed-decisions/workflow32/run.py
+++ b/examples/typed-decisions/workflow32/run.py
@@ -83,7 +83,7 @@ def request_body(case: dict, settings: dict) -> dict:
"model": settings["model"],
**case["request"],
"max_completion_tokens": settings["max_completion_tokens"],
- "temperature": 1.0,
+ "temperature": settings["temperature"],
"top_p": 0.95,
"top_k": 64,
}
@@ -241,7 +241,7 @@ def case_worker(case: dict, folder: Path, settings: dict, inner: httpx.BaseTrans
case["request"]["messages"],
response_format=case["request"]["response_format"],
max_completion_tokens=settings["max_completion_tokens"],
- temperature=1.0,
+ temperature=settings["temperature"],
top_p=0.95,
top_k=64,
extra_body=extra,
@@ -320,10 +320,18 @@ def run_frame(
timeout_s: float = 1800,
max_completion_tokens: int = 32768,
thinking: str = "on",
+ temperature: float = 1.0,
execute=run_case,
) -> list[dict]:
if not math.isfinite(timeout_s) or timeout_s <= 0 or max_completion_tokens <= 0:
raise ValueError("Positive finite case timeout and completion token cap are required")
+ if (
+ isinstance(temperature, bool)
+ or not isinstance(temperature, (int, float))
+ or not math.isfinite(temperature)
+ or not 0 <= temperature <= 2
+ ):
+ raise ValueError("Temperature must be a finite number from 0 to 2")
address = httpx.URL(url)
if (
address.scheme not in {"http", "https"}
@@ -343,6 +351,7 @@ def run_frame(
"timeout_s": timeout_s,
"max_completion_tokens": max_completion_tokens,
"thinking": thinking,
+ "temperature": float(temperature),
}
out.mkdir(parents=True, exist_ok=False)
sync_directory(out.parent)
@@ -409,6 +418,7 @@ if __name__ == "__main__":
parser.add_argument("--timeout", type=float, default=1800)
parser.add_argument("--max-completion-tokens", type=int, default=32768)
parser.add_argument("--thinking", choices=("on", "off", "server"), default="on")
+ parser.add_argument("--temperature", type=float, default=1.0)
args = parser.parse_args()
if not args.url:
parser.error("Set SIE_URL or pass --url")
@@ -420,5 +430,6 @@ if __name__ == "__main__":
timeout_s=args.timeout,
max_completion_tokens=args.max_completion_tokens,
thinking=args.thinking,
+ temperature=args.temperature,
)
raise SystemExit(1 if any(row.get("halt") for row in outcomes) or outcomes[0]["status"] != "ok" else 0)
diff --git a/examples/typed-decisions/workflow32/tests/test_workflow.py b/examples/typed-decisions/workflow32/tests/test_workflow.py
index c5a43806c..535bc3e95 100644
--- a/examples/typed-decisions/workflow32/tests/test_workflow.py
+++ b/examples/typed-decisions/workflow32/tests/test_workflow.py
@@ -56,6 +56,7 @@ def settings(**updates) -> dict:
"timeout_s": 10,
"max_completion_tokens": 32768,
"thinking": "on",
+ "temperature": 1.0,
**updates,
}
@@ -233,6 +234,16 @@ class SourceAndFrameTests(unittest.TestCase):
for seconds in [float("nan"), float("inf"), 0, -1]:
with self.subTest(seconds=seconds), self.assertRaises(ValueError):
self.frame(mock.Mock(), timeout_s=seconds)
+ for temperature in [float("nan"), float("inf"), -0.1, 2.5, True, "0"]:
+ with self.subTest(temperature=temperature), self.assertRaises(ValueError):
+ self.frame(mock.Mock(), temperature=temperature)
+
+ def test_explicit_temperature_is_recorded_in_the_plan(self) -> None:
+ execute = mock.Mock(return_value={"status": "ok", "physical_sends": 1})
+ self.frame(execute, temperature=0.0)
+ plan = json.loads((self.root / "out" / "plan.json").read_bytes())
+ self.assertEqual(plan["decoding"]["temperature"], 0.0)
+ self.assertEqual(execute.call_args.args[2]["temperature"], 0.0)
class TransportTests(unittest.TestCase):
@@ -271,6 +282,20 @@ class TransportTests(unittest.TestCase):
self.assertEqual(terminal["wire"][0]["method"], "POST")
self.assertEqual(json.loads((self.folder / terminal["wire"][0]["file"]).read_bytes()), reply())
+ def test_explicit_temperature_reaches_the_wire(self) -> None:
+ bodies = []
+
+ def handler(request):
+ bodies.append(json.loads(request.read()))
+ return httpx.Response(
+ 200, stream=httpx.ByteStream(run.canonical(reply())), headers={"content-type": "application/json"}
+ )
+
+ terminal = self.worker(handler, temperature=0.0)
+ self.assertEqual(terminal["status"], "ok")
+ self.assertEqual(bodies, [run.request_body(self.case, settings(temperature=0.0))])
+ self.assertEqual(bodies[0]["temperature"], 0.0)
+
def test_capacity_rejection_never_retries(self) -> None:
requests = []