diff --git a/edge0-strata/docs/DETAILS.md b/edge0-strata/docs/DETAILS.md index 1dbd9a8f..5fe9620f 100644 --- a/edge0-strata/docs/DETAILS.md +++ b/edge0-strata/docs/DETAILS.md @@ -468,7 +468,7 @@ applies at the next start. Network, key, MCP and program keys are not editable t | `reasoning_budget_tokens` | `0` (no budget) | Caps the thinking at N tokens: the server ends it with a short wrap-up line and `` and the model answers from there. The wrap-up counts as output tokens. A request's own `reasoning_budget_tokens` (or llama.cpp's `thinking_budget_tokens`) wins. | | `answer_room` | on | A request with thinking on, no budget and `max_tokens` of 1,024 or more gets one: thinking is wrapped up when a quarter of the cap (at least 512 tokens) is left. Requests without `max_tokens` get three quarters of the context. `false` turns it off. Clients should not cap the reply far below what the context allows. | | `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` | off | `"stop"` ends, `"recover"` (or `true`) restarts once, a reply whose reasoning repeats whole passages. Checked every 512 output tokens. It can mistake repeated useful code for a loop, so keep the answer quality alongside the completion rate when testing it (#728). | +| `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. | | `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. | diff --git a/edge0-strata/serve/server.py b/edge0-strata/serve/server.py index ab67a871..f0c0da15 100644 --- a/edge0-strata/serve/server.py +++ b/edge0-strata/serve/server.py @@ -223,9 +223,9 @@ def write_temporary(path: Path, parts: list) -> None: # and no call, is continued once with the thinking closed (the same way the budget's wrap-up closes it) REASONING_CLOSE = "\n\n\n" REASONING_WRAP_UP = "\n\nI have thought about this long enough; time to give my answer.\n\n\n" -# #728: opt-in handling of reasoning that repeats whole passages (which the single-token guard above cannot see). +# #728: handling of reasoning that repeats whole passages (which the single-token guard above cannot see). # "reasoning_loop_recovery": "stop" ends the reply there; "recover" (or true) goes on from the same output with the -# low-effort instruction in place of the xhigh one. Both off by default. +# low-effort instruction in place of the xhigh one. "recover" is the default; false turns it off. HIGH_EFFORT = EFFORT_TEXT["xhigh"] LOW_EFFORT = EFFORT_TEXT["low"] LOOP_CHECK_EVERY = 512 # output tokens between two looks at the reasoning (at a clean parser boundary) @@ -4307,7 +4307,7 @@ def __init__(self, engine: Engine, tokenizer, template: ChatTemplate, model_name self.vram_reserve_asked = False # a POST /v1/vram was made (vram_reserve None is then asked) self.vision_held = False # an elastic encoder holds VRAM the expert cache gave it self.last_image_at = 0.0 # when an image turn last ended (the elastic encoder's idle) - self.reasoning_loop_recovery = False + self.reasoning_loop_recovery = "recover" self.reasoning_budget_configured = False # the config named reasoning_budget_tokens (0 included): no family default self.reasoning_budget_tokens = 0 # #123: the config's default thinking budget (0: none) self.repeat_stop_tokens = REPEAT_STOP_TOKENS # #606: one token this many times in a row ends a reply (0: off) @@ -9491,7 +9491,7 @@ def request_stop(reason: str): if budget: print(f"[strata] thinking budget: {budget} tokens (reasoning_budget_tokens; a request can set its own)", flush=True) - recovery = cfg.get("reasoning_loop_recovery", False) # #728: false (default) | "stop" | "recover" (true) + recovery = cfg.get("reasoning_loop_recovery", "recover") # #728: "recover" (default) | "stop" | false if recovery is True: recovery = "recover" if recovery is not False and recovery not in ("stop", "recover"):