refactor: lift hardcoded model default + fix stale `is_whitebox` docstring
``"anthropic/claude-sonnet-4-6"`` was duplicated as a kwarg default in
5 places (``run_strix_scan``, ``make_run_config``, ``make_agent_context``,
and twice in ``agents_graph.create_agent``'s ``inner.get(..., default)``
calls). The default was actually dead code: ``validate_environment``
requires ``STRIX_LLM`` to be set before any scan starts, and the CLI/TUI
callers don't pass ``model=`` themselves.
Replaced with a single resolution in ``run_strix_scan``:
resolved_model = model or load_settings().llm.model
if not resolved_model:
raise RuntimeError("No LLM model configured. ...")
then propagated explicitly to ``make_agent_context`` and
``make_run_config``. Both lose their string defaults — ``model`` is now
a required kwarg. The graph tool's ``inner.get("model", "...")`` is
``inner["model"]``: the parent context guarantees it's set.
Drive-by: ``run_strix_scan`` docstring still listed ``is_whitebox`` as
a ``scan_config`` key — stale since ``1e641e5`` derived it from
``targets`` instead. Updated.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+13
-4
@@ -161,7 +161,7 @@ async def run_strix_scan(
|
||||
bus: AgentMessageBus | None = None,
|
||||
interactive: bool = False,
|
||||
max_turns: int = STRIX_DEFAULT_MAX_TURNS,
|
||||
model: str = "anthropic/claude-sonnet-4-6",
|
||||
model: str | None = None,
|
||||
cleanup_on_exit: bool = True,
|
||||
) -> RunResult:
|
||||
"""Run one Strix scan end-to-end against a freshly-prepared sandbox.
|
||||
@@ -169,7 +169,7 @@ async def run_strix_scan(
|
||||
Args:
|
||||
scan_config: Per-scan configuration — ``targets``,
|
||||
``user_instructions``, ``diff_scope``, ``scan_mode``,
|
||||
``is_whitebox``, ``skills``.
|
||||
``skills``. ``is_whitebox`` is derived from ``targets``.
|
||||
scan_id: Used to key the sandbox session cache. Auto-generated
|
||||
if omitted — callers that want resume-after-crash semantics
|
||||
should pass a stable id.
|
||||
@@ -181,6 +181,9 @@ async def run_strix_scan(
|
||||
interactive: Renders the interactive-mode prompt block on the
|
||||
root agent.
|
||||
max_turns: Cap on root-agent LLM turns (default 300).
|
||||
model: Litellm model alias. ``None`` (default) reads
|
||||
:attr:`Settings.llm.model` — caller pre-validates via
|
||||
:func:`validate_environment` that it's set.
|
||||
cleanup_on_exit: When True (default), tears down the sandbox
|
||||
session in a ``finally``. Set to False for resume scenarios
|
||||
where the caller wants to preserve the container.
|
||||
@@ -192,6 +195,12 @@ async def run_strix_scan(
|
||||
scan_id = f"scan-{uuid.uuid4().hex[:8]}"
|
||||
logger.info("Starting Strix scan %s", scan_id)
|
||||
|
||||
resolved_model = model or load_settings().llm.model
|
||||
if not resolved_model:
|
||||
raise RuntimeError(
|
||||
"No LLM model configured. Set STRIX_LLM env or pass model= to run_strix_scan().",
|
||||
)
|
||||
|
||||
# Caller may pre-create the bus so it can hold a handle (e.g., the
|
||||
# TUI uses it to route stop / chat-input commands). Otherwise we
|
||||
# own the bus internally for the scan's lifetime.
|
||||
@@ -244,7 +253,7 @@ async def run_strix_scan(
|
||||
agent_id=root_id,
|
||||
parent_id=None,
|
||||
tracer=tracer,
|
||||
model=model,
|
||||
model=resolved_model,
|
||||
max_turns=max_turns,
|
||||
is_whitebox=is_whitebox,
|
||||
diff_scope=diff_scope,
|
||||
@@ -258,7 +267,7 @@ async def run_strix_scan(
|
||||
run_config = make_run_config(
|
||||
sandbox_session=bundle["session"],
|
||||
sandbox_client=bundle["client"],
|
||||
model=model,
|
||||
model=resolved_model,
|
||||
reasoning_effort=reasoning_effort,
|
||||
)
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ DEFAULT_RETRY = ModelRetrySettings(
|
||||
def make_run_config(
|
||||
*,
|
||||
sandbox_session: BaseSandboxSession | None,
|
||||
model: str = "anthropic/claude-sonnet-4-6",
|
||||
model: str,
|
||||
reasoning_effort: Literal["low", "medium", "high"] | None = None,
|
||||
model_settings_override: ModelSettings | None = None,
|
||||
sandbox_client: Any | None = None,
|
||||
@@ -71,8 +71,8 @@ def make_run_config(
|
||||
this scan (one container per scan; see
|
||||
:mod:`strix.runtime.session_manager`). ``None`` is allowed
|
||||
for unit tests and dry runs.
|
||||
model: Model alias passed to ``MultiProvider``. Defaults to the
|
||||
production Anthropic alias.
|
||||
model: Litellm model alias passed to ``MultiProvider``. Caller
|
||||
resolves from :attr:`Settings.llm.model`.
|
||||
reasoning_effort: ``"low" | "medium" | "high"``; routes to
|
||||
``ModelSettings.reasoning``.
|
||||
model_settings_override: Optional per-run ``ModelSettings``
|
||||
@@ -117,7 +117,7 @@ def make_agent_context(
|
||||
agent_id: str,
|
||||
parent_id: str | None,
|
||||
tracer: Any | None,
|
||||
model: str = "anthropic/claude-sonnet-4-6",
|
||||
model: str,
|
||||
model_settings: ModelSettings | None = None,
|
||||
max_turns: int = 300,
|
||||
is_whitebox: bool = False,
|
||||
|
||||
@@ -446,7 +446,7 @@ async def create_agent(
|
||||
agent_id=child_id,
|
||||
parent_id=parent_id,
|
||||
tracer=inner.get("tracer"),
|
||||
model=inner.get("model", "anthropic/claude-sonnet-4-6"),
|
||||
model=inner["model"],
|
||||
model_settings=inner.get("model_settings"),
|
||||
max_turns=int(inner.get("max_turns", 300)),
|
||||
is_whitebox=bool(inner.get("is_whitebox", False)),
|
||||
@@ -458,7 +458,7 @@ async def create_agent(
|
||||
child_run_config = make_run_config(
|
||||
sandbox_session=inner.get("sandbox_session"),
|
||||
sandbox_client=inner.get("sandbox_client"),
|
||||
model=inner.get("model", "anthropic/claude-sonnet-4-6"),
|
||||
model=inner["model"],
|
||||
model_settings_override=inner.get("model_settings"),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user