Skip to content

The agent that grows with you

refactor(agent): drop the orphaned hand-rolled summary kwargs builder

kshitijk4poor488f2fc86d2c
diff --git a/agent/chat_completion_helpers.py b/agent/chat_completion_helpers.py
index ee612290d58..ed694740185 100644
--- a/agent/chat_completion_helpers.py
+++ b/agent/chat_completion_helpers.py
@@ -2011,64 +2011,6 @@ def _managed_summary_call(agent, api_request_id: str, request, callback, *, retr
)
-def _iteration_summary_chat_kwargs(agent, api_messages: list) -> dict:
- """chat.completions.create kwargs for the summary, mirroring ChatCompletionsTransport.build_kwargs()."""
- try:
- from agent.auxiliary_client import _fixed_temperature_for_model, OMIT_TEMPERATURE as _OMIT_TEMP
- except Exception:
- _fixed_temperature_for_model = _OMIT_TEMP = None
- raw_temp = _fixed_temperature_for_model(agent.model, agent.base_url) if _fixed_temperature_for_model is not None else None
- temperature = None if raw_temp is _OMIT_TEMP else raw_temp
- provider_name = (agent.provider or "").strip().lower()
- # LM Studio uses top-level `reasoning_effort` (not extra_body.reasoning).
- is_lmstudio = provider_name == "lmstudio" and agent._supports_reasoning_extra_body()
- lm_reasoning_effort = agent._resolve_lmstudio_summary_reasoning_effort() if is_lmstudio else None
-
- extra_body = {}
- if not is_lmstudio and agent._supports_reasoning_extra_body():
- extra_body["reasoning"] = agent.reasoning_config if agent.reasoning_config is not None else {"enabled": True, "effort": "medium"}
- if "nousresearch" in agent._base_url_lower:
- from agent.portal_tags import nous_portal_tags
- extra_body["tags"] = nous_portal_tags()
-
- summary_kwargs = {"model": agent.model, "messages": api_messages}
- if temperature is not None:
- summary_kwargs["temperature"] = temperature
- if agent.max_tokens is not None:
- summary_kwargs.update(agent._max_tokens_param(agent.max_tokens))
- if lm_reasoning_effort is not None:
- summary_kwargs["reasoning_effort"] = lm_reasoning_effort
-
- # Merge the profile's canonical body even when routing is unset (e.g. required Portal tags).
- provider_preferences = _provider_preferences_for_agent(agent)
- profile_extra_body = {}
- with contextlib.suppress(Exception):
- from providers import get_provider_profile
- provider_profile = get_provider_profile(agent.provider)
- if provider_profile is not None:
- profile_extra_body = provider_profile.build_extra_body(
- session_id=getattr(agent, "session_id", None), provider_preferences=provider_preferences or None,
- model=agent.model, base_url=agent.base_url, reasoning_config=agent.reasoning_config)
- if profile_extra_body:
- extra_body.update(profile_extra_body)
-
- def _is_openrouter() -> bool:
- return provider_name == "openrouter" or agent._is_openrouter_url()
-
- if provider_preferences and "provider" not in profile_extra_body and _is_openrouter():
- extra_body["provider"] = provider_preferences
- # Pareto Code router plugin — model-gated, same shape as the main-loop emission.
- _score = agent.openrouter_min_coding_score
- if agent.model == "openrouter/pareto-code" and _is_openrouter() and _score is not None and _score != "":
- with contextlib.suppress(TypeError, ValueError):
- _ps = float(_score)
- if 0.0 <= _ps <= 1.0:
- extra_body["plugins"] = [{"id": "pareto-router", "min_coding_score": _ps}]
- if extra_body:
- summary_kwargs["extra_body"] = extra_body
- return summary_kwargs
-
-
def _summary_text_with_scrub(agent, response, **normalize_kwargs) -> str:
"""Keep summary text while discarding any tool calls emitted alongside it.
diff --git a/agent/reasoning_params.py b/agent/reasoning_params.py
index 17711e73d5a..ee436f30445 100644
--- a/agent/reasoning_params.py
+++ b/agent/reasoning_params.py
@@ -98,11 +98,6 @@ class ReasoningParamsMixin:
return False
return bool(_cached_probe(self, "_ollama_thinking_cache", ollama_model_supports_thinking, None, lambda v: v is not None))
- def _resolve_lmstudio_summary_reasoning_effort(self) -> Optional[str]:
- """Safe top-level ``reasoning_effort`` for LM Studio; shared with the iteration-limit summary call."""
- from agent.lmstudio_reasoning import resolve_lmstudio_effort
- return resolve_lmstudio_effort(self.reasoning_config, self._lmstudio_reasoning_options_cached())
-
def _github_models_reasoning_extra_body(self) -> dict | None:
"""Format reasoning payload for GitHub Models/OpenAI-compatible routes."""
try: