572ef2a2af
Critical fixes: - ``StrixOrchestrationHooks.on_agent_start`` now finds the ``CaidoCapability`` via ``ctx.context['caido_capability']`` instead of ``agent.capabilities`` (we use plain ``Agent``, not ``SandboxAgent``, so the latter never existed). The session manager's bundle already exposes the capability; ``run_strix_scan`` threads it through ``make_agent_context`` and ``create_agent`` forwards it to children. - ``run_strix_scan`` registers the ``StrixTracingProcessor`` with the SDK's tracing provider via ``add_trace_processor`` so SDK trace spans hit ``run_dir/events.jsonl`` (was previously a parallel stream the SDK ignored). - ``on_llm_end`` now writes to ``Tracer.record_llm_usage`` in addition to ``bus.record_usage`` so the CLI/TUI stats panel sees real numbers instead of zeros. - ``run_strix_scan`` accepts an externally-built ``AgentMessageBus`` + an explicit ``model`` arg. The TUI pre-creates the bus so its stop and chat-input handlers can submit ``bus.send`` / ``bus.cancel_descendants`` coroutines onto the scan thread's loop via ``asyncio.run_coroutine_threadsafe`` — replacing the TODO-stub no-ops. - ``model`` config now propagates root → context → child agents in ``create_agent`` (was hardcoded fallback). Dead-code removal: - Deleted the ``load_skill`` tool entirely (host module, sandbox module, TUI renderer, tests). The legacy implementation reached into a global ``_agent_instances`` registry that no longer exists; the post-migration stub returned ``success=True`` without injecting anything — pure theater. Skills are still preloaded via the system prompt at scan-bring-up. - Dropped ``tenacity`` and ``xmltodict`` from ``[project.dependencies]`` — neither is imported anywhere post-migration. - Stripped the system prompt's "use the load_skill tool" lines. Tests: 278/278 passing. Removed two ``load_skill`` test cases and a ``test_tool_registration_modes::test_load_skill_import_...`` assertion that exercised the deleted module. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
import importlib
|
|
import sys
|
|
from types import ModuleType
|
|
from typing import Any
|
|
|
|
from strix.config import Config
|
|
from strix.tools.registry import clear_registry
|
|
|
|
|
|
def _empty_config_load(_cls: type[Config]) -> dict[str, dict[str, str]]:
|
|
return {"env": {}}
|
|
|
|
|
|
def _reload_tools_module() -> ModuleType:
|
|
clear_registry()
|
|
|
|
for name in list(sys.modules):
|
|
if name == "strix.tools" or name.startswith("strix.tools."):
|
|
sys.modules.pop(name, None)
|
|
|
|
return importlib.import_module("strix.tools")
|
|
|
|
|
|
def test_non_sandbox_skips_browser_and_web_search_when_disabled(
|
|
monkeypatch: Any,
|
|
) -> None:
|
|
"""Browser registration is gated on STRIX_DISABLE_BROWSER and
|
|
web_search on PERPLEXITY_API_KEY; both should stay out of the
|
|
in-container ``register_tool`` registry when their gates are off.
|
|
Agents_graph is no longer in this registry — those tools are SDK
|
|
function tools (host-side only), not in-container tools.
|
|
"""
|
|
monkeypatch.setenv("STRIX_SANDBOX_MODE", "false")
|
|
monkeypatch.setenv("STRIX_DISABLE_BROWSER", "true")
|
|
monkeypatch.delenv("PERPLEXITY_API_KEY", raising=False)
|
|
monkeypatch.setattr(Config, "load", classmethod(_empty_config_load))
|
|
|
|
tools = _reload_tools_module()
|
|
names = set(tools.get_tool_names())
|
|
|
|
assert "browser_action" not in names
|
|
assert "web_search" not in names
|
|
|
|
|
|
def test_sandbox_registers_sandbox_tools_but_not_non_sandbox_tools(
|
|
monkeypatch: Any,
|
|
) -> None:
|
|
monkeypatch.setenv("STRIX_SANDBOX_MODE", "true")
|
|
monkeypatch.setenv("STRIX_DISABLE_BROWSER", "true")
|
|
monkeypatch.delenv("PERPLEXITY_API_KEY", raising=False)
|
|
monkeypatch.setattr(Config, "load", classmethod(_empty_config_load))
|
|
|
|
tools = _reload_tools_module()
|
|
names = set(tools.get_tool_names())
|
|
|
|
assert "terminal_execute" in names
|
|
assert "python_action" in names
|
|
assert "list_requests" in names
|
|
assert "create_agent" not in names
|
|
assert "finish_scan" not in names
|
|
assert "browser_action" not in names
|
|
assert "web_search" not in names
|