Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

Merge remote-tracking branch 'refs/remotes/pr/3499' into integration/ecc-043-20261011

haelyra353f64fa8304
diff --cc src/llm/providers/ollama.py
index e0669563c,c7a0c7121..4571fdb73
--- a/src/llm/providers/ollama.py
+++ b/src/llm/providers/ollama.py
@@@ -19,35 -15,11 +19,36 @@@ from llm.core.interface import
from llm.core.types import (
LLMInput,
LLMOutput,
+ Message,
ModelInfo,
ProviderType,
+ Role,
ToolCall,
)
+ from llm.providers.model_config import read_model_env
+from llm.providers.reasoning import prefilled_reasoning_from_env, strip_reasoning
+
+logger = logging.getLogger(__name__)
+
+
+def _messages_payload(messages: list[Message]) -> list[dict[str, Any]]:
+ """Serialize messages, naming the tool each tool result answers.
+
+ Ollama correlates a tool result with its call through ``tool_name``; ids
+ are optional on its side, so the name is what keeps several results apart.
+ """
+ names: dict[str, str] = {}
+ payload = []
+ for msg in messages:
+ item = msg.to_dict()
+ for tc in msg.tool_calls or []:
+ names[tc.id] = tc.name
+ if msg.role == Role.TOOL:
+ tool_name = msg.name or names.get(msg.tool_call_id or "")
+ if tool_name:
+ item["tool_name"] = tool_name
+ payload.append(item)
+ return payload
class OllamaProvider(LLMProvider):
@@@ -57,25 -29,9 +58,25 @@@
self,
base_url: str | None = None,
default_model: str | None = None,
+ prefilled_reasoning: bool | None = None,
+ leading_reasoning: bool | None = None,
) -> None:
+ # Enable only for a deployment that declares balanced leading reasoning.
+ # Generic responses can contain literal XML and stay intact by default.
+ self.leading_reasoning = (
+ leading_reasoning
+ if leading_reasoning is not None
+ else prefilled_reasoning_from_env("OLLAMA_LEADING_REASONING")
+ )
+ # Set for models whose chat template prefills <think>, so replies arrive
+ # as "...</think>answer" without the opening tag.
+ self.prefilled_reasoning = (
+ prefilled_reasoning
+ if prefilled_reasoning is not None
+ else prefilled_reasoning_from_env("OLLAMA_PREFILLED_REASONING")
+ )
self.base_url = base_url or os.environ.get("OLLAMA_BASE_URL", "http://localhost:11434")
- self.default_model = default_model or os.environ.get("OLLAMA_MODEL", "llama3.2")
+ self.default_model = default_model or read_model_env("OLLAMA_MODEL") or "llama3.2"
self._models = [
ModelInfo(
name="llama3.2",
diff --cc src/llm/providers/openai.py
index 34b21a8e5,443bdc0c1..168786ea9
--- a/src/llm/providers/openai.py
+++ b/src/llm/providers/openai.py
@@@ -33,23 -32,8 +33,24 @@@ class OpenAIProvider(LLMProvider)
self,
api_key: str | None = None,
base_url: str | None = None,
+ default_model: str | None = None,
+ prefilled_reasoning: bool | None = None,
+ leading_reasoning: bool | None = None,
) -> None:
+ # Enable only for a deployment that declares balanced leading reasoning.
+ # Generic responses can contain literal XML and stay intact by default.
+ self.leading_reasoning = (
+ leading_reasoning
+ if leading_reasoning is not None
+ else prefilled_reasoning_from_env("OPENAI_LEADING_REASONING")
+ )
+ # Set for self-hosted servers whose chat template prefills <think>, so
+ # replies arrive as "...</think>answer" without the opening tag.
+ self.prefilled_reasoning = (
+ prefilled_reasoning
+ if prefilled_reasoning is not None
+ else prefilled_reasoning_from_env("OPENAI_PREFILLED_REASONING")
+ )
self.client = OpenAI(
api_key=api_key or os.environ.get("OPENAI_API_KEY"),
base_url=base_url,