diff --git a/AGENTS.md b/AGENTS.md index 03a85f1..99d445c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1164,8 +1164,8 @@ CLI, unit tests (24) + integration tests (2). runner, and the rewrite is never fed back into assessment, tracing, or the decision log (the runner and REPL keep the raw deterministic summary). The prompt forbids adding/inferring/dropping facts, and `Humanizer.humanize` - always falls back to the original text on any error, timeout, empty/refusal - reply, or runaway length, so a cleanup failure never swallows a real result. + always falls back to the original text on any error, timeout, empty reply, or + runaway length, so a cleanup failure never swallows a real result. It reuses the scheduler's `llm` client (endpoint/model/sampler configured once) with a short per-call `timeout` (a new optional `chat()` argument) so a slow cleanup cannot hold the gateway poll loop for the authoring budget. Off @@ -1205,7 +1205,7 @@ CLI, unit tests (24) + integration tests (2). real `Scheduler` (lazy engine, unreachable LLM). `tests/test_humanize.py` covers the optional result cleanup with an injected fake `llm` client (rewrite, quote/whitespace normalization, fallback on - error/empty/refusal/runaway, disabled passthrough, and the global + + error/empty/runaway, disabled passthrough, and the global + per-platform gateway enable/disable wiring). `tests/test_lxmf_transport.py` covers the neutral LXMF transport's missing-dep contract, default paths, and `normalize_message` (no real `lxmf` diff --git a/semif_agent/gateway/humanize.py b/semif_agent/gateway/humanize.py index 2602d50..7faff86 100644 --- a/semif_agent/gateway/humanize.py +++ b/semif_agent/gateway/humanize.py @@ -10,7 +10,7 @@ It is generation, never a decision: the success/failure verdict and the routing are already settled by SemIf and the runner, and the rewrite is never fed back into assessment, tracing, or the decision log. The prompt forbids adding, inferring, or dropping facts, and `humanize` falls back to the original text on -any error, timeout, empty reply, refusal, or runaway length — a cleanup failure +any error, timeout, empty reply, or runaway length — a cleanup failure must never swallow or corrupt a real result. It reuses the scheduler's configured ``llm`` client (its endpoint/model/sampler) @@ -35,18 +35,6 @@ SYSTEM_PROMPT = ( "- If the result is already a plain sentence, return it unchanged." ) -#: Leading phrases that mark a meta/refusal reply rather than a rewrite. -_REFUSAL_PREFIXES = ( - "i cannot", - "i can't", - "i'm sorry", - "i am sorry", - "i'm unable", - "i am unable", - "as an ai", - "sorry,", -) - def _clean_reply(raw: str) -> str: """Normalize a model reply into one bare sentence, or "" if unusable.""" @@ -82,7 +70,7 @@ class Humanizer: """Return a grounded rewrite of `text`, or `text` unchanged. Never raises: any failure (unreachable client, timeout, empty or - unusable reply, refusal, runaway length) returns the original text. + unusable reply, runaway length) returns the original text. """ source = (text or "").strip() if not self.enabled or not source: @@ -100,8 +88,6 @@ class Humanizer: cleaned = _clean_reply(raw) if not cleaned: return text - if cleaned.lower().startswith(_REFUSAL_PREFIXES): - return text if len(cleaned) > self.max_chars: return text return cleaned diff --git a/tests/test_humanize.py b/tests/test_humanize.py index 3af537c..36b8424 100644 --- a/tests/test_humanize.py +++ b/tests/test_humanize.py @@ -61,11 +61,6 @@ def test_humanize_falls_back_on_empty_reply(): assert Humanizer(client).humanize("raw result") == "raw result" -def test_humanize_falls_back_on_refusal(): - client = FakeClient(reply="I cannot rewrite that.") - assert Humanizer(client).humanize("raw result") == "raw result" - - def test_humanize_falls_back_on_runaway_length(): client = FakeClient(reply="x" * 1000) assert Humanizer(client, max_chars=100).humanize("raw") == "raw"