mirror of
https://github.com/usestrix/strix.git
synced 2026-08-24 11:52:38 +02:00
feat(logging): per-scan `{run_dir}/strix.log` with scan/agent context tagging
Every scan now writes a complete log file at ``{run_dir}/strix.log``
captured from the moment ``run_dir`` is resolved through teardown.
Stdlib ``logging`` only — no parallel framework.
New ``strix/telemetry/logging.py``:
* ``setup_scan_logging(run_dir, debug=)`` attaches a ``FileHandler``
(DEBUG, all ``strix.*``) plus a ``StreamHandler`` (ERROR by
default; DEBUG via ``STRIX_DEBUG=1``).
* ``ContextVar``-backed ``scan_id`` and ``agent_id`` injected by a
``Filter`` so every line is auto-tagged across asyncio tasks
without callers passing them explicitly.
* Third-party noise (``httpx``, ``litellm``, ``openai``,
``anthropic``, ``urllib3``, ``httpcore``) capped at WARNING.
* Returns a teardown handle for ``finally`` cleanup.
Wiring:
* ``orchestration/scan.py`` calls ``setup_scan_logging`` once per
scan after ``run_dir`` resolves; sets scan_id; tears down in
``finally``. Adds INFO logs for sandbox bring-up + scan
start/end.
* ``orchestration/hooks.py`` sets/clears ``agent_id`` ContextVar in
``on_agent_start`` / ``on_agent_end`` and emits INFO for agent
lifecycle, DEBUG for every tool start/end and LLM call.
* ``interface/main.py`` drops the ``setLevel(ERROR)`` silencer.
Coverage expanded across ~20 files (orchestration, agents, runtime,
llm, tools, interface, config, skills) with INFO for lifecycle and
DEBUG for verbose detail. Per the system instructions in
``logger.warning(f"…{e}")`` were converted to module logger calls.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
9d7f754b59
commit
46ff025209
@@ -10,6 +10,8 @@ through to the SDK's built-in litellm routing.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from agents.exceptions import UserError
|
||||
from agents.models.interface import Model, ModelProvider
|
||||
from agents.models.multi_provider import MultiProvider, MultiProviderMap
|
||||
@@ -17,6 +19,9 @@ from agents.models.multi_provider import MultiProvider, MultiProviderMap
|
||||
from strix.llm.anthropic_cache_wrapper import AnthropicCachingLitellmModel
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class _AnthropicCachingProvider(ModelProvider):
|
||||
"""Routes ``anthropic/<model>`` aliases through
|
||||
:class:`AnthropicCachingLitellmModel`.
|
||||
@@ -33,6 +38,7 @@ class _AnthropicCachingProvider(ModelProvider):
|
||||
"Anthropic provider requires a non-empty model name (e.g. 'claude-sonnet-4-6').",
|
||||
)
|
||||
full = model_name if model_name.startswith("anthropic/") else f"anthropic/{model_name}"
|
||||
logger.debug("Anthropic provider: building cached model for %s", full)
|
||||
return AnthropicCachingLitellmModel(model=full)
|
||||
|
||||
|
||||
@@ -45,4 +51,5 @@ def build_multi_provider() -> MultiProvider:
|
||||
"""
|
||||
pmap = MultiProviderMap() # type: ignore[no-untyped-call]
|
||||
pmap.add_provider("anthropic", _AnthropicCachingProvider())
|
||||
logger.debug("MultiProvider built with anthropic/ caching route")
|
||||
return MultiProvider(provider_map=pmap)
|
||||
|
||||
Reference in New Issue
Block a user