add new template kwargs and fixed linter errors

This commit is contained in:
Alishahryar1 2026-01-31 00:03:21 -08:00
parent 303767e346
commit 3acabcb8e0
9 changed files with 33 additions and 17 deletions

View file

@ -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"},

View file

@ -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,

View file

@ -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."""
...

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -1,7 +1,6 @@
"""Tests for config/settings.py"""
class TestSettings:
"""Test Settings configuration."""

View file

@ -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."""