diff --git a/cli/parser.py b/cli/parser.py index a3b215a..b7f6bf1 100644 --- a/cli/parser.py +++ b/cli/parser.py @@ -113,7 +113,9 @@ class CLIParser: else: # Non-zero exit is an error error_msg = stderr if stderr else f"Process exited with code {code}" - logger.warning(f"CLI_PARSER: Error exit (code={code}): {error_msg[:100]}") + logger.warning( + f"CLI_PARSER: Error exit (code={code}): {error_msg[:100]}" + ) return [ {"type": "error", "message": error_msg}, {"type": "complete", "status": "failed"}, diff --git a/cli/session.py b/cli/session.py index 99746a0..812e19e 100644 --- a/cli/session.py +++ b/cli/session.py @@ -153,9 +153,13 @@ class CLISession: yield {"type": "error", "error": {"message": stderr_text}} return_code = await self.process.wait() - logger.info(f"Claude CLI exited with code {return_code}, stderr_present={bool(stderr_text)}") + logger.info( + f"Claude CLI exited with code {return_code}, stderr_present={bool(stderr_text)}" + ) if return_code != 0 and not stderr_text: - logger.warning(f"CLI_SESSION: Process exited with code {return_code} but no stderr captured") + logger.warning( + f"CLI_SESSION: Process exited with code {return_code} but no stderr captured" + ) yield { "type": "exit", "code": return_code, diff --git a/messaging/base.py b/messaging/base.py index 4517d6b..f147bf7 100644 --- a/messaging/base.py +++ b/messaging/base.py @@ -38,7 +38,9 @@ class SessionManagerInterface(Protocol): """ ... - async def register_real_session_id(self, temp_id: str, real_session_id: str) -> bool: + async def register_real_session_id( + self, temp_id: str, real_session_id: str + ) -> bool: """Register the real session ID from CLI output.""" ... diff --git a/messaging/event_parser.py b/messaging/event_parser.py index 2b0da0b..b609561 100644 --- a/messaging/event_parser.py +++ b/messaging/event_parser.py @@ -55,9 +55,7 @@ def parse_cli_event(event: Dict) -> List[Dict]: # Prioritize thinking first if thinking_parts: - results.append( - {"type": "thinking", "text": "\n".join(thinking_parts)} - ) + results.append({"type": "thinking", "text": "\n".join(thinking_parts)}) # Then tools or subagents if tool_calls: diff --git a/providers/base.py b/providers/base.py index 84c6bac..fe2b610 100644 --- a/providers/base.py +++ b/providers/base.py @@ -7,6 +7,7 @@ from pydantic import BaseModel class ProviderConfig(BaseModel): """Configuration for a provider.""" + api_key: str base_url: Optional[str] = None rate_limit: Optional[int] = None @@ -25,7 +26,9 @@ class BaseProvider(ABC): pass @abstractmethod - async def stream_response(self, request: Any, input_tokens: int = 0) -> AsyncIterator[str]: + async def stream_response( + self, request: Any, input_tokens: int = 0 + ) -> AsyncIterator[str]: """Stream response in Anthropic SSE format.""" pass diff --git a/providers/model_utils.py b/providers/model_utils.py index fa07ee8..3339ff7 100644 --- a/providers/model_utils.py +++ b/providers/model_utils.py @@ -25,7 +25,7 @@ def strip_provider_prefixes(model: str) -> str: """ for prefix in _PROVIDER_PREFIXES: if model.startswith(prefix): - return model[len(prefix):] + return model[len(prefix) :] return model diff --git a/providers/nvidia_mixins.py b/providers/nvidia_mixins.py index 6e3610b..28156d2 100644 --- a/providers/nvidia_mixins.py +++ b/providers/nvidia_mixins.py @@ -95,10 +95,10 @@ class RequestBuilderMixin: if request_data.thinking and getattr(request_data.thinking, "enabled", True): extra_body.setdefault("thinking", {"type": "enabled"}) extra_body.setdefault("reasoning_split", True) - - # Handle DeepSeek-specific thinking mode - if "deepseek" in request_data.model.lower(): - extra_body.setdefault("chat_template_kwargs", {"thinking": True}) + extra_body.setdefault( + "chat_template_kwargs", + {"thinking": True, "reasoning_split": True, "clear_thinking": False}, + ) body.update(extra_body) diff --git a/tests/test_config.py b/tests/test_config.py index 70669b7..87148aa 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,7 +1,6 @@ """Tests for config/settings.py""" - class TestSettings: """Test Settings configuration.""" diff --git a/tests/test_request_utils.py b/tests/test_request_utils.py index cc66d2c..a0df3d8 100644 --- a/tests/test_request_utils.py +++ b/tests/test_request_utils.py @@ -199,7 +199,10 @@ class TestExtractCommandPrefix: def test_with_env_vars(self): """Test command with environment variables.""" assert extract_command_prefix("DEBUG=1 python script.py") == "DEBUG=1 python" - assert extract_command_prefix("API_KEY=secret node app.js") == "API_KEY=secret node" + assert ( + extract_command_prefix("API_KEY=secret node app.js") + == "API_KEY=secret node" + ) def test_single_word_commands(self): """Test single word commands.""" @@ -211,7 +214,10 @@ class TestExtractCommandPrefix: """Test detection of command injection attempts.""" assert extract_command_prefix("`whoami`") == "command_injection_detected" assert extract_command_prefix("$(whoami)") == "command_injection_detected" - assert extract_command_prefix("echo $(cat /etc/passwd)") == "command_injection_detected" + assert ( + extract_command_prefix("echo $(cat /etc/passwd)") + == "command_injection_detected" + ) def test_empty_command(self): """Test handling of empty commands.""" @@ -221,7 +227,9 @@ class TestExtractCommandPrefix: def test_complex_git_command(self): """Test complex git command extraction.""" assert extract_command_prefix("git log --oneline --graph") == "git log" - assert extract_command_prefix("git checkout -b feature-branch") == "git checkout" + assert ( + extract_command_prefix("git checkout -b feature-branch") == "git checkout" + ) def test_cargo_command(self): """Test cargo command extraction."""