mirror of
https://github.com/usestrix/strix.git
synced 2026-08-25 12:22:37 +02:00
Combined commits 2+3 of the migration plan because the FastAPI sidecar removal in commit 2 broke ``browser_action`` (which lived in the sidecar); they have to land together. Sandbox tool layer (commit 2 piece): - ``build_strix_agent`` now returns a ``SandboxAgent`` with ``capabilities=[Filesystem(), Shell()]``. The SDK runtime binds the capabilities to the live sandbox session per-run; agents get ``exec_command``, ``write_stdin``, ``apply_patch``, ``view_image`` function tools auto-merged into their tool list. Plain ``Agent`` short-circuits capability binding (``agents/sandbox/runtime.py:190``). - Drop ``Compaction`` from the default capability set — it's OpenAI-Responses-API-only and useless for our litellm-routed Anthropic setup. - Delete the entire custom in-container tool layer: - ``strix/tools/terminal/`` (5 files, 748 LoC libtmux) - ``strix/tools/file_edit/`` (3 files, 276 LoC) - ``strix/tools/python/`` (5 files, 459 LoC) - ``strix/runtime/tool_server.py`` (163 LoC FastAPI sidecar) - ``strix/tools/_sandbox_dispatch.py`` (117 LoC) - ``strix/tools/registry.py`` (109 LoC) - ``strix/tools/context.py`` (12 LoC) - Drop the corresponding TUI renderers (``terminal_renderer.py``, ``file_edit_renderer.py``, ``python_renderer.py``) and update ``interface/tool_components/__init__.py``. Browser → agent-browser CLI (commit 3 piece): - Install ``agent-browser@0.26.0`` globally in the Dockerfile right after the existing ``npm install -g`` block. Run ``agent-browser install --with-deps`` (apt, root) and ``agent-browser install`` (Chrome download, pentester) + ``agent-browser doctor --offline --quick`` smoke test. - Drop the explicit Playwright system-deps apt list (replaced by ``--with-deps``) and ``RUN .venv/bin/python -m playwright install chromium``. - Vendor ``agent-browser/skill-data/core/SKILL.md`` → ``strix/skills/tooling/agent_browser.md`` (476 lines). Adapt frontmatter to Strix format; strip the install/Quickstart and the ``agent-browser skills get electron|slack|...`` specialized-skills block; add the "Caido proxy is wired via env vars; do not pass ``--proxy``" note. - ``_resolve_skills`` now eagerly loads ``tooling/agent_browser`` for every agent (matches the previous unconditional ``browser_action`` in ``_BASE_TOOLS``). - Delete ``strix/tools/browser/`` (5 files, 1338 LoC) and the ``browser_renderer.py`` TUI render. Sandbox plumbing: - Drop ``bearer`` token, ``tool_server_host_port`` resolution + bundle keys, ``TOOL_SERVER_TOKEN``/``TOOL_SERVER_PORT``/ ``STRIX_SANDBOX_EXECUTION_TIMEOUT`` from the manifest env in ``session_manager.create_or_reuse``. Caido proxy env vars (``http_proxy``, ``https_proxy``, ``ALL_PROXY``) stay; manifest applies them to every ``docker exec``-spawned process. - Drop ``sandbox_token`` and ``tool_server_host_port`` params from ``make_agent_context`` and the ``create_agent`` graph tool. - Drop the tool-server health-check from ``entry.py`` (only Caido's ``wait_for_tcp_ready`` remains). - ``docker-entrypoint.sh``: delete the ~30 line ``Starting tool server...`` block (sudo + uvicorn launch + curl /health poll). Add ``NO_PROXY=localhost,127.0.0.1`` to ``/etc/profile.d/proxy.sh`` and ``/etc/environment`` so the agent-browser daemon's CDP traffic on localhost isn't routed through Caido. pyproject.toml: - ``[project.optional-dependencies] sandbox = []`` (every member of the previous list — fastapi, uvicorn, ipython, openhands-aci, playwright, libtmux — is gone with the sidecar). - Drop ``numpydoc.*``, ``IPython.*``, ``openhands_aci.*``, ``playwright.*``, ``uvicorn.*``, ``pyte.*``, ``libtmux.*`` from the missing-imports module list. - Drop the per-file ruff ignores for the deleted modules. Net delta: −5512 LoC. ruff drops to 3 errors (was 21 baseline). mypy falls to 69 errors over 3 files (was 84 over 8 — the drop comes from deleting the modules with the worst untyped-import problems).
159 lines
5.3 KiB
Python
159 lines
5.3 KiB
Python
"""``make_run_config`` — assemble a Strix-flavored ``RunConfig`` for ``Runner.run``.
|
|
|
|
Every scan goes through here so defaults apply uniformly. Per-call
|
|
overrides land via ``model_settings_override``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, Any, Literal
|
|
|
|
from agents import RunConfig
|
|
from agents.model_settings import ModelSettings
|
|
from agents.retry import (
|
|
ModelRetryBackoffSettings,
|
|
ModelRetrySettings,
|
|
retry_policies,
|
|
)
|
|
from agents.sandbox import SandboxRunConfig
|
|
from openai.types.shared import Reasoning
|
|
|
|
from strix.llm.multi_provider_setup import build_multi_provider
|
|
from strix.orchestration.filter import inject_messages_filter
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
from agents.sandbox.session.base_sandbox_session import BaseSandboxSession
|
|
|
|
from strix.orchestration.bus import AgentMessageBus
|
|
|
|
|
|
#: Default ``max_turns`` callers should pass to ``Runner.run``.
|
|
STRIX_DEFAULT_MAX_TURNS = 300
|
|
|
|
# Retry: 5 attempts with ``min(90, 2*2^n)`` backoff. 4xx auth/validation
|
|
# errors are excluded from the retryable status list — they can't be
|
|
# fixed by retrying and should fail fast.
|
|
_DEFAULT_RETRY = ModelRetrySettings(
|
|
max_retries=5,
|
|
backoff=ModelRetryBackoffSettings(
|
|
initial_delay=2.0,
|
|
max_delay=90.0,
|
|
multiplier=2.0,
|
|
jitter=False,
|
|
),
|
|
policy=retry_policies.any(
|
|
retry_policies.provider_suggested(),
|
|
retry_policies.network_error(),
|
|
retry_policies.http_status((429, 500, 502, 503, 504)),
|
|
),
|
|
)
|
|
|
|
|
|
def make_run_config(
|
|
*,
|
|
sandbox_session: BaseSandboxSession | None,
|
|
model: str = "anthropic/claude-sonnet-4-6",
|
|
reasoning_effort: Literal["low", "medium", "high"] | None = None,
|
|
model_settings_override: ModelSettings | None = None,
|
|
sandbox_client: Any | None = None,
|
|
) -> RunConfig:
|
|
"""Build a ``RunConfig`` with Strix defaults.
|
|
|
|
Note: ``max_turns`` is not a ``RunConfig`` field — pass it directly
|
|
to ``Runner.run``. ``STRIX_DEFAULT_MAX_TURNS`` is the budget Strix
|
|
uses.
|
|
|
|
Args:
|
|
sandbox_session: Live sandbox session shared by every agent in
|
|
this scan (one container per scan; see
|
|
:mod:`strix.sandbox.session_manager`). ``None`` is allowed
|
|
for unit tests and dry runs.
|
|
model: Model alias passed to ``MultiProvider``. Defaults to the
|
|
production Anthropic alias.
|
|
reasoning_effort: ``"low" | "medium" | "high"``; routes to
|
|
``ModelSettings.reasoning``.
|
|
model_settings_override: Optional per-run ``ModelSettings``
|
|
merged over factory defaults.
|
|
sandbox_client: Optional pre-built sandbox client (Strix Docker
|
|
subclass). The SDK instantiates its built-in if a session is
|
|
supplied without a client.
|
|
"""
|
|
base_settings = ModelSettings(
|
|
parallel_tool_calls=False,
|
|
tool_choice="required",
|
|
retry=_DEFAULT_RETRY,
|
|
)
|
|
if reasoning_effort is not None:
|
|
base_settings = base_settings.resolve(
|
|
ModelSettings(reasoning=Reasoning(effort=reasoning_effort)),
|
|
)
|
|
if model_settings_override is not None:
|
|
base_settings = base_settings.resolve(model_settings_override)
|
|
|
|
sandbox_config = (
|
|
SandboxRunConfig(client=sandbox_client, session=sandbox_session)
|
|
if sandbox_session is not None
|
|
else None
|
|
)
|
|
|
|
return RunConfig(
|
|
model=model,
|
|
model_provider=build_multi_provider(),
|
|
model_settings=base_settings,
|
|
sandbox=sandbox_config,
|
|
call_model_input_filter=inject_messages_filter,
|
|
tracing_disabled=False,
|
|
trace_include_sensitive_data=False,
|
|
)
|
|
|
|
|
|
def make_agent_context(
|
|
*,
|
|
bus: AgentMessageBus,
|
|
sandbox_session: BaseSandboxSession | None,
|
|
caido_host_port: int | None,
|
|
agent_id: str,
|
|
parent_id: str | None,
|
|
tracer: Any | None,
|
|
model: str = "anthropic/claude-sonnet-4-6",
|
|
model_settings: ModelSettings | None = None,
|
|
max_turns: int = 300,
|
|
is_whitebox: bool = False,
|
|
diff_scope: dict[str, Any] | None = None,
|
|
run_id: str | None = None,
|
|
sandbox_client: Any | None = None,
|
|
agent_factory: Any | None = None,
|
|
caido_client: Any | None = None,
|
|
) -> dict[str, Any]:
|
|
"""Build the per-agent ``context`` dict passed to ``Runner.run(context=...)``.
|
|
|
|
The canonical place where bus, sandbox handles, identity, tracer
|
|
reference, and per-agent toggles live. Tools, hooks, and
|
|
``inject_messages_filter`` reach in via ``ctx.context.get(...)``.
|
|
|
|
``agent_factory`` is a callable ``(name, skills) -> agents.Agent`` —
|
|
the ``create_agent`` graph tool uses it to spin up children that
|
|
inherit the same wiring. ``sandbox_client`` is the host-side Docker
|
|
subclass, reused across child runs.
|
|
"""
|
|
return {
|
|
"bus": bus,
|
|
"sandbox_session": sandbox_session,
|
|
"sandbox_client": sandbox_client,
|
|
"caido_host_port": caido_host_port,
|
|
"caido_client": caido_client,
|
|
"agent_id": agent_id,
|
|
"parent_id": parent_id,
|
|
"tracer": tracer,
|
|
"model": model,
|
|
"model_settings": model_settings,
|
|
"max_turns": max_turns,
|
|
"turn_count": 0,
|
|
"agent_finish_called": False,
|
|
"is_whitebox": is_whitebox,
|
|
"diff_scope": diff_scope,
|
|
"run_id": run_id,
|
|
"agent_factory": agent_factory,
|
|
}
|