From 8261536b1327681d8abc276de951fdf0697af9eb Mon Sep 17 00:00:00 2001 From: linyubupa <403864360@qq.com> Date: Sun, 22 Nov 2026 17:32:43 +0800 Subject: [PATCH] feat(serve): place a non-default reasoning effort before the answer by default "effort_position" now defaults to "end": a request that asks for low or medium reasoning effort gets it in a short system turn right before the answer, so changing the effort keeps the cached conversation instead of rewriting the system prompt at the top. "start" still puts it at the top, and an engine older than 0.1.39 (no --tail-role-token) falls back to that with the message it already printed. The comment, the run-config help, docs/DETAILS.md and the test that pinned the old default are updated. --- edge0-strata/docs/DETAILS.md | 2 +- edge0-strata/serve/runconfig.py | 2 +- edge0-strata/serve/server.py | 12 ++++++------ edge0-strata/serve/test_server.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/edge0-strata/docs/DETAILS.md b/edge0-strata/docs/DETAILS.md index 5fe9620f..0581a422 100644 --- a/edge0-strata/docs/DETAILS.md +++ b/edge0-strata/docs/DETAILS.md @@ -470,7 +470,7 @@ applies at the next start. Network, key, MCP and program keys are not editable t | `reasoning_close_retry` | off | Closes the thinking once and continues when a reply ended inside its thinking with no answer and no tool call (#1053). | | `reasoning_loop_recovery` | `"recover"` | `"stop"` ends, `"recover"` (or `true`) restarts once, a reply whose reasoning repeats whole passages; `false` turns it off. Checked every 512 output tokens, only while the model is thinking. It can mistake repeated useful code for a loop, so keep the answer quality alongside the completion rate when testing it (#728). | | `repeat_stop_tokens` | `256` | A reply that repeats one token this many times in a row ends as `"length"`. `0` turns it off. | -| `effort_position` | `"start"` | `"end"` puts a `low` or `medium` effort in a short system turn right before the answer, so a request that only changes the effort reuses the conversation cache. How well the model follows a level in that place is not measured. | +| `effort_position` | `"end"` | `"end"` puts a `low` or `medium` effort in a short system turn right before the answer, so a request that only changes the effort reuses the conversation cache. How well the model follows a level in that place is not measured. `"start"` keeps it at the top; an engine older than 0.1.39 falls back to `"start"` with a message. | | `anthropic_thinking` | as the template | `"on_request"` renders a `/v1/messages` request that asks for no thinking without thinking, as Anthropic does. Claude Code's short helper calls need it. | | `tool_call_recovery` | on (since 0.2.8; off in 0.2.7 and before) | Also reads a declared tool's call written as ``, as JSON inside ``, as a `` block without ``, or as a second call inside one ``. On 1,462 agent turns 98.3% read as intended with it and 92.9% without; the 49 specimens of the test corpus read the same with it on or off. Only a declared tool's call is ever recovered; anything else stays text. `"tool_call_recovery": false` turns it off. | | `env_to_user` | off | Moves opencode's `` block (working directory, date) to the first user message so the system turn is the same for every session and the disk prefix cache restores it. | diff --git a/edge0-strata/serve/runconfig.py b/edge0-strata/serve/runconfig.py index 3448db06..a457a868 100644 --- a/edge0-strata/serve/runconfig.py +++ b/edge0-strata/serve/runconfig.py @@ -30,7 +30,7 @@ ("anthropic_thinking", ("enum", ["model", "on_request"]), "Anthropic requests that do not ask for thinking: think as the model does (model) or not (on_request)"), ("effort_position", ("enum", ["start", "end"]), - "Where a non-default reasoning effort goes: start (the default) or end (keeps the cache when it changes)"), + "Where a non-default reasoning effort goes: end (the default; keeps the cache when it changes) or start"), ("aliases", "names", "Other model names the server lists and answers to (comma-separated)"), ("idle_unload_s", "num>=0", "Unload the model after this many seconds without requests (0 or empty: never)"), ("mtp", "bool", "Draft layer (MTP): off starts the engine without it (about 1 GB less graphics memory, slower words per second); " diff --git a/edge0-strata/serve/server.py b/edge0-strata/serve/server.py index f0c0da15..24a13fc4 100644 --- a/edge0-strata/serve/server.py +++ b/edge0-strata/serve/server.py @@ -3182,13 +3182,13 @@ def engine_binary(exe: str, cfg: dict | None = None) -> str: def effort_end_args(cfg: dict, exe: str, tok) -> list[str] | None: - """#458 (opt-in): the engine arguments for "effort_position": "end" - the id of "system" as --tail-role-token, so - the engine checkpoints in front of the trailing effort turn - or None when the config leaves it at the top (the - default) or the engine is too old for it (said once; the prompt stays the default one). ValueError for a value + """#458: the engine arguments for "effort_position": "end" (the default) - the id of "system" as + --tail-role-token, so the engine checkpoints in front of the trailing effort turn - or None when the config asks + for "start" or the engine is too old for it (said once; the prompt stays at the top). ValueError for a value other than "start" / "end".""" - pos = cfg.get("effort_position", "start") + pos = cfg.get("effort_position", "end") if pos not in ("start", "end"): - raise ValueError(f'"effort_position" must be "start" (the default) or "end", not {pos!r}') + raise ValueError(f'"effort_position" must be "start" or "end" (the default), not {pos!r}') if pos == "start": return None try: @@ -4234,7 +4234,7 @@ def __init__(self, engine: Engine, tokenizer, template: ChatTemplate, model_name self.slot_save_path = None # --slot-save-path: /slots/0?action=save|restore (off when None) self.embeddings = threading.local() # the current request's image embeddings file (GENI) self.api_key = "" # when set, /v1/* needs it (Bearer or x-api-key) - # #458 (opt-in, the config's "effort_position": "end"): a non-default reasoning effort goes in a short system + # #458 (the config's "effort_position": "end", the default): a non-default reasoning effort goes in a short system # turn before the answer instead of the top of the prompt, so switching it keeps the cached conversation self.effort_end = False self.conv_log = ConvCacheLog() # #596: the parked conversations, from the engine's log diff --git a/edge0-strata/serve/test_server.py b/edge0-strata/serve/test_server.py index 1f8bf8e2..817bddb4 100644 --- a/edge0-strata/serve/test_server.py +++ b/edge0-strata/serve/test_server.py @@ -915,7 +915,7 @@ def encode(self, text, parse_special=False): old.write_bytes(b"... --turn-token ID ...") out = io.StringIO() with contextlib.redirect_stdout(out): - self.assertIsNone(effort_end_args({}, str(new), Tok())) + self.assertEqual(effort_end_args({}, str(new), Tok()), ["--tail-role-token", "8678"]) self.assertIsNone(effort_end_args({"effort_position": "start"}, str(new), Tok())) self.assertEqual(effort_end_args({"effort_position": "end"}, str(new), Tok()), ["--tail-role-token", "8678"])