The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(agent): hug/pack bracket spans in async_utils + aux_accounting, fix E305 blank lines
Tekniumd0adf6486e2b
diff --git a/agent/async_utils.py b/agent/async_utils.pyindex 15c288f34de..2bc558fad21 100644--- a/agent/async_utils.py+++ b/agent/async_utils.py@@ -18,12 +18,9 @@ _DEFAULT_LOGGER = logging.getLogger(__name__)def safe_schedule_threadsafe(- coro: Coroutine[Any, Any, Any],- loop: Optional[asyncio.AbstractEventLoop],- *,+ coro: Coroutine[Any, Any, Any], loop: Optional[asyncio.AbstractEventLoop], *,logger: Optional[logging.Logger] = None,- log_message: str = "Failed to schedule coroutine on loop",- log_level: int = logging.DEBUG,+ log_message: str = "Failed to schedule coroutine on loop", log_level: int = logging.DEBUG,) -> Optional[Future]:"""Schedule ``coro`` on ``loop`` from a sync context, leak-safe.diff --git a/agent/aux_accounting.py b/agent/aux_accounting.pyindex ee9d15bff29..052c026afc1 100644--- a/agent/aux_accounting.py+++ b/agent/aux_accounting.py@@ -43,10 +43,7 @@ def reset_accounting_context(token) -> None:def record_aux_usage(- response: Any,- task: Optional[str],- *,- provider: Optional[str] = None,+ response: Any, task: Optional[str], *, provider: Optional[str] = None,base_url: Optional[str] = None,) -> None:"""Record an auxiliary response's token usage against the ambient session.@@ -85,17 +82,10 @@ def record_aux_usage(except Exception:logger.debug("Aux usage cost estimation failed", exc_info=True)session_db.record_auxiliary_usage(- session_id,- task,- model=model,- billing_provider=provider,- billing_base_url=base_url,- input_tokens=usage.input_tokens,- output_tokens=usage.output_tokens,- cache_read_tokens=usage.cache_read_tokens,- cache_write_tokens=usage.cache_write_tokens,- reasoning_tokens=usage.reasoning_tokens,- estimated_cost_usd=estimated_cost,+ session_id, task, model=model, billing_provider=provider, billing_base_url=base_url,+ input_tokens=usage.input_tokens, output_tokens=usage.output_tokens,+ cache_read_tokens=usage.cache_read_tokens, cache_write_tokens=usage.cache_write_tokens,+ reasoning_tokens=usage.reasoning_tokens, estimated_cost_usd=estimated_cost,)except Exception:logger.debug("Aux usage recording failed (non-fatal)", exc_info=True)diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.pyindex 61119701392..bdef510b0fa 100644--- a/agent/auxiliary_client.py+++ b/agent/auxiliary_client.py@@ -105,6 +105,7 @@ def aux_probe_mode():finally:_aux_probe_state.active = prev+from agent.credential_pool import load_poolfrom agent.model_metadata import (MINIMUM_CONTEXT_LENGTH, get_model_context_length,@@ -2422,6 +2423,8 @@ def _relay_sync_stream(model_name=str(kwargs.get("model") or fallback_model), finalizer=dict, metadata=metadata,completed_response_predicate=lambda value: hasattr(value, "choices"),)++_RUNTIME_MAIN_COMPAT_SNAPSHOT: Tuple[Any, ...] = ("", "", "", "", "", "")_RUNTIME_MAIN_COMPAT_LOCK = threading.Lock()