From 693bd89a79acf6ce10664e5f8be58413bbc7dd71 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 24 May 2026 15:36:20 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- studio/backend/core/inference/llama_cpp.py | 10 ++++++---- .../backend/tests/test_llama_cpp_reprompt_guard.py | 13 +++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py index eef41608a8..7e21ad349c 100644 --- a/studio/backend/core/inference/llama_cpp.py +++ b/studio/backend/core/inference/llama_cpp.py @@ -4917,12 +4917,14 @@ class LlamaCppBackend: _visible = content_accum.strip() _reasoning = reasoning_accum.strip() _stripped = _visible if _visible else _reasoning - _artifact_text = _visible if _visible else ( - _reasoning if not has_content_tokens else "" + _artifact_text = ( + _visible + if _visible + else (_reasoning if not has_content_tokens else "") ) - _visible_has_artifact = bool(_artifact_text) and _has_answer_artifact( + _visible_has_artifact = bool( _artifact_text - ) + ) and _has_answer_artifact(_artifact_text) if ( tools and _reprompt_count < _MAX_REPROMPTS diff --git a/studio/backend/tests/test_llama_cpp_reprompt_guard.py b/studio/backend/tests/test_llama_cpp_reprompt_guard.py index b81f0c80df..23019fc2c7 100644 --- a/studio/backend/tests/test_llama_cpp_reprompt_guard.py +++ b/studio/backend/tests/test_llama_cpp_reprompt_guard.py @@ -672,7 +672,9 @@ def test_reasoning_only_visible_artifact_suppresses_reprompt(): visible = content_accum.strip() reasoning = reasoning_accum.strip() stripped = visible if visible else reasoning - artifact_text = visible if visible else (reasoning if not has_content_tokens else "") + artifact_text = ( + visible if visible else (reasoning if not has_content_tokens else "") + ) would_reprompt = bool( 0 < len(stripped) < _REPROMPT_MAX_CHARS and _INTENT_SIGNAL.search(stripped) @@ -689,17 +691,16 @@ def test_hidden_reasoning_artifact_still_reprompts(): content_accum = "" reasoning_accum = ( - "First, let me draft it.\n" - "```python\n" - "print('hidden answer')\n" - "```" + "First, let me draft it.\n" "```python\n" "print('hidden answer')\n" "```" ) has_content_tokens = True # content existed but was stripped visible = content_accum.strip() reasoning = reasoning_accum.strip() stripped = visible if visible else reasoning - artifact_text = visible if visible else (reasoning if not has_content_tokens else "") + artifact_text = ( + visible if visible else (reasoning if not has_content_tokens else "") + ) would_reprompt = bool( 0 < len(stripped) < _REPROMPT_MAX_CHARS and _INTENT_SIGNAL.search(stripped)