mirror of
https://github.com/usestrix/strix.git
synced 2026-08-24 11:52:38 +02:00
Strip narrative comments and module/helper docstrings
Five rounds of sweep across the tree. Net ~544 lines removed. Removed: - Section-divider banners and one-line section labels (# Display utilities, # ----- list_requests -----, # CVSS breakdown, etc.). - Module-level prose docstrings on internal modules. Kept one-line summaries; trimmed multi-paragraph narration about SDK/Strix responsibility splits, cache strategies, three-source precedence. - Internal-helper docstrings that just restate the function name — caido_api helpers (caido_url, get_client, view_request, etc.), settings-class one-liners (LLMSettings, RuntimeSettings, ...), UI helper docstrings. - Args/Returns blocks on non-LLM-facing internal helpers (build_strix_agent, render_system_prompt, create_or_reuse, bootstrap_caido) — kept only the genuinely non-obvious params. - Internal-history phrasing — "Mirrors main-branch shape", "pre-SDK harness", "previous lookup matched no attribute". - Narrative comments inside function bodies that explained what the next line does, design rationale obvious from the surrounding code, or "we used to..." asides. - Trailing periods on every error-string literal across the tool tree. - Duplicated roundtripTime quirk comment (kept the LLM-facing copy in tools/proxy/tools.py). Kept (every one names an upstream bug, vendored-code provenance, or non-obvious data quirk): - core/runner.py: SDK replay-with-empty-initial-input + on_agent_end lifecycle gap. - runtime/docker_client.py: VERBATIM COPY block of the upstream _create_container body, pinned to SDK v0.14.6. - runtime/session_manager.py: NO_PROXY for agent-browser CDP loopback. - tools/proxy/caido_api.py: generated-pydantic Request.raw quirk, replay double-history pitfall. - tools/proxy/tools.py: Caido roundtripTime=0 quirk for proxy captures.
This commit is contained in:
@@ -1,10 +1,4 @@
|
||||
"""SDK-native state for Strix's addressable agent graph.
|
||||
|
||||
The Agents SDK owns model/tool execution and per-agent conversation
|
||||
history. Strix owns only product semantics the SDK does not provide:
|
||||
agent ids, the parent/child graph, wake/stop signals, TUI-visible
|
||||
status, and process-resume metadata.
|
||||
"""
|
||||
"""SDK-native state for Strix's addressable agent graph."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -189,10 +189,7 @@ async def respawn_subagents(
|
||||
event_sink: StreamEventSink | None = None,
|
||||
hooks: RunHooks[dict[str, Any]] | None = None,
|
||||
) -> None:
|
||||
"""Re-spawn subagent runners from a restored coordinator snapshot."""
|
||||
async with coordinator._lock:
|
||||
# Snapshot the iteration view first so we can mutate via coordinator
|
||||
# below without "dict changed during iteration" trouble.
|
||||
agents_snapshot = [
|
||||
(aid, status, dict(coordinator.metadata.get(aid, {})))
|
||||
for aid, status in coordinator.statuses.items()
|
||||
|
||||
@@ -15,12 +15,10 @@ if TYPE_CHECKING:
|
||||
from strix.config.settings import ReasoningEffort
|
||||
|
||||
|
||||
# Default max_turns budget passed to the SDK runner.
|
||||
DEFAULT_MAX_TURNS = 500
|
||||
|
||||
|
||||
def build_root_task(scan_config: dict[str, Any]) -> str:
|
||||
"""Format the user-facing task for the root agent."""
|
||||
targets = scan_config.get("targets", []) or []
|
||||
diff_scope = scan_config.get("diff_scope") or {}
|
||||
user_instructions = scan_config.get("user_instructions", "") or ""
|
||||
@@ -81,7 +79,6 @@ def build_root_task(scan_config: dict[str, Any]) -> str:
|
||||
|
||||
|
||||
def build_scope_context(scan_config: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Build the system_prompt_context block consumed by the prompt template."""
|
||||
authorized: list[dict[str, str]] = []
|
||||
value_keys = {
|
||||
"repository": "target_repo",
|
||||
|
||||
+1
-23
@@ -1,9 +1,4 @@
|
||||
"""Top-level Strix scan runner.
|
||||
|
||||
The SDK owns model/tool execution and per-agent sessions. This module owns
|
||||
Strix-specific scan setup, child-agent startup, resume, and the small wake loop
|
||||
needed to keep every agent addressable after its SDK run parks.
|
||||
"""
|
||||
"""Top-level Strix scan runner."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -72,8 +67,6 @@ async def run_strix_scan(
|
||||
if scan_id is None:
|
||||
scan_id = f"scan-{uuid.uuid4().hex[:8]}"
|
||||
|
||||
# Resolve run_dir before any heavy bring-up so the log file captures
|
||||
# everything from sandbox start onwards.
|
||||
run_dir = run_dir_for(scan_id)
|
||||
run_dir.mkdir(parents=True, exist_ok=True)
|
||||
state_dir = runtime_state_dir(run_dir)
|
||||
@@ -105,15 +98,10 @@ async def run_strix_scan(
|
||||
logger.info("LLM model resolved: %s", resolved_model)
|
||||
chat_completions_tools = uses_chat_completions_tool_schema(resolved_model, settings)
|
||||
|
||||
# Caller may pre-create the coordinator so it can route stop/chat
|
||||
# commands while the scan loop runs in another thread.
|
||||
if coordinator is None:
|
||||
coordinator = AgentCoordinator()
|
||||
coordinator.set_snapshot_path(agents_path)
|
||||
|
||||
# Wire the per-agent todo store to ``{run_dir}/.state/todos.json`` (mirrored
|
||||
# on every CRUD) and reload any prior todos so respawned subagents
|
||||
# find their lists intact. Same for the shared notes store.
|
||||
from strix.tools.notes.tools import hydrate_notes_from_disk
|
||||
from strix.tools.todo.tools import hydrate_todos_from_disk
|
||||
|
||||
@@ -228,8 +216,6 @@ async def run_strix_scan(
|
||||
"spawn_child_agent": spawn_child_agent,
|
||||
}
|
||||
|
||||
# All agents share one SQLite database; SDK session_id separates
|
||||
# each agent's conversation inside that database.
|
||||
root_session = open_agent_session(root_id, agents_db)
|
||||
sessions_to_close.append(root_session)
|
||||
await coordinator.attach_runtime(root_id, session=root_session)
|
||||
@@ -291,16 +277,8 @@ async def run_strix_scan(
|
||||
)
|
||||
except BaseException:
|
||||
logger.exception("Strix scan %s failed", scan_id)
|
||||
# Cancel any descendant tasks the root spawned before unwinding.
|
||||
# cancel_descendants is idempotent and handles the empty-tree case.
|
||||
if root_id is not None:
|
||||
await coordinator.cancel_descendants(root_id)
|
||||
# The SDK's on_agent_end hook only fires after a successful
|
||||
# ``Runner.run_streamed`` reaches the agent's first turn. A
|
||||
# failure earlier (e.g., model-provider routing, sandbox
|
||||
# bring-up) leaves the root stuck at status="running" — the
|
||||
# TUI keeps animating "Initializing" forever. Finalize it
|
||||
# here so the coordinator reflects reality.
|
||||
with contextlib.suppress(Exception):
|
||||
await coordinator.set_status(root_id, "failed")
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user