repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
hermes-agent | tests/hermes_cli/test_web_ui_build.py | .py | """Tests for _web_ui_build_needed — staleness check for the web UI dist.
The freshness check uses a SHA-256 content hash of the web source tree
(mirroring the desktop build), recorded in a stamp file under $HERMES_HOME,
NOT mtime comparison — so ``git pull`` / ``hermes update`` that rewrite
source mtimes without chang... | 430 | 19,315 |
hermes-agent | tests/hermes_cli/test_inventory.py | .py | """Behavior tests for hermes_cli.inventory.
Locks the invariants the three migrated consumers (web_server.py
/api/model/options, tui_gateway model.options, tui_gateway model.save_key)
depend on:
- load_picker_context() reproduces the inline 17-LOC config-slice exactly.
- with_overrides() is truthy-only (empty agent a... | 548 | 20,613 |
hermes-agent | tests/hermes_cli/test_cron_fire_dashboard.py | .py | """Tests for the Chronos cron-fire webhook ON THE DASHBOARD APP (web_server).
Regression guard for the relocation bug: the fire webhook MUST live on the
dashboard FastAPI app (`hermes_cli.web_server.app`) — the agent's public HTTP
surface on hosted deployments — not only on the aiohttp APIServerAdapter (which
hosted a... | 441 | 18,201 |
hermes-agent | tests/hermes_cli/test_dashboard_admin_endpoints.py | .py | """Tests for the dashboard admin API endpoints (MCP, pairing, webhooks,
credential pool, memory, gateway lifecycle, ops, skills hub).
These endpoints turn the web dashboard into an administration panel for
operators without CLI access to the host. The tests assert the request
contract and the CLI-config parity (server... | 1,066 | 37,833 |
hermes-agent | tests/hermes_cli/test_tui_npm_install.py | .py | """_tui_need_npm_install: auto npm when node_modules is behind the lockfile."""
import os
import types
from pathlib import Path
import pytest
@pytest.fixture
def main_mod():
import hermes_cli.main as m
return m
def _touch_ink(root: Path) -> None:
ink = root / "node_modules" / "@hermes" / "ink" / "pac... | 185 | 7,003 |
hermes-agent | tests/hermes_cli/test_worktree_command.py | .py | """Tests for the CLI ``/worktree`` command handler.
``/worktree`` (Copilot CLI-inspired) inspects or creates isolated git
worktrees mid-session. These drive the mixin handler against real git repos:
status/list output, ``new`` creation with cwd + TERMINAL_CWD retargeting,
named-tree collision refusal, and graceful non... | 132 | 3,854 |
hermes-agent | tests/hermes_cli/test_update_stale_dashboard.py | .py | """Tests for the stale-dashboard handling run at the end of ``hermes update``.
``hermes update`` detects ``hermes dashboard`` processes left over from the
previous version and kills them (SIGTERM + SIGKILL grace, or ``taskkill /F``
on Windows). Without this, the running backend silently serves stale Python
against a ... | 772 | 33,580 |
hermes-agent | tests/hermes_cli/test_stderr_timestamp.py | .py | """Tests for hermes_cli.stderr_timestamp."""
import re
import sys
from gateway.restart import EXTERNAL_GATEWAY_SUPERVISOR_ENV
from hermes_cli import stderr_timestamp
_STALE_GATEWAY_ARGV = [
sys.executable,
"-m",
"hermes_cli.main",
"gateway",
"run",
"--replace",
]
_LAUNCHD_ENV = {"PATH": "/usr... | 160 | 5,073 |
hermes-agent | tests/hermes_cli/test_serve_parent_watchdog.py | .py | """Regression tests for Desktop-owned ``hermes serve`` lifecycle tracking."""
from hermes_cli.web_server import _is_serve_orphaned, _valid_parent_start_marker
def test_parent_watchdog_tracks_recorded_desktop_pid_not_immediate_ppid():
"""Windows venv launch shims must not make a live Desktop look orphaned."""
... | 60 | 1,819 |
hermes-agent | tests/hermes_cli/test_scan_venv_blockers.py | .py | """Tests for hermes_cli/_scan_venv_blockers.py.
Tests call the real production functions (``main``, ``_redact_sensitive_cmdline``).
The detector is patched directly so no real process table interaction occurs.
"""
from __future__ import annotations
import builtins
import json
import sys
import types
from pathlib imp... | 371 | 13,894 |
hermes-agent | tests/hermes_cli/test_web_server_git.py | .py | import subprocess
from pathlib import Path
import pytest
from hermes_cli import web_server
pytest.importorskip("starlette.testclient")
from starlette.testclient import TestClient
@pytest.fixture
def client():
previous = getattr(web_server.app.state, "auth_required", None)
web_server.app.state.auth_required... | 197 | 6,975 |
hermes-agent | tests/hermes_cli/test_web_routers_tools_install_on_enable.py | .py | """Install-on-enable for toolset toggles (dashboard/desktop PUT endpoint).
When a toolset is toggled ON via ``PUT /api/tools/toolsets/{name}`` and its
provider carries a post_setup hook with a registered, UNSATISFIED
install-state predicate (``_POST_SETUP_INSTALLED`` — today: cua-driver),
the endpoint spawns the same ... | 148 | 5,284 |
hermes-agent | tests/hermes_cli/test_runtime_provider_resolution.py | .py | import base64
import json
import time
from types import SimpleNamespace
import pytest
from hermes_cli import runtime_provider as rp
def test_configured_api_key_provider_without_key_fails_closed(monkeypatch):
"""A saved provider must not resolve as another authenticated provider."""
monkeypatch.setattr(
... | 1,625 | 65,952 |
hermes-agent | tests/hermes_cli/test_imagegen_managed_gateway.py | .py | """Regression tests for image_gen use_gateway persistence (managed FAL clobber).
Bug: ``_select_plugin_image_gen_provider`` hardcoded
``image_gen.use_gateway = False``. When a user picked FAL through the
Nous-subscription managed flow, ``_write_provider_config`` first set
``use_gateway = True`` — then the image select... | 125 | 5,008 |
hermes-agent | tests/hermes_cli/test_plugins.py | .py | """Tests for the Hermes plugin system (hermes_cli.plugins)."""
import logging
import json
import sys
import types
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
import yaml
from hermes_cli.plugins import (
ENTRY_POINTS_GROUP,
VALID_HOOKS,
PluginContext,
PluginManage... | 2,069 | 82,915 |
hermes-agent | tests/hermes_cli/test_gateway_external_supervisor.py | .py | """Tests for explicit ownership by a wrapped external gateway supervisor."""
from types import SimpleNamespace
import pytest
import hermes_cli.gateway as gateway
def _clear_native_supervisor_markers(monkeypatch):
monkeypatch.delenv("INVOCATION_ID", raising=False)
monkeypatch.delenv("HERMES_S6_SUPERVISED_CH... | 149 | 4,282 |
hermes-agent | tests/hermes_cli/test_web_server_profile_unification.py | .py | """Regression tests for the machine-dashboard multi-profile unification.
The dashboard is ONE machine-level management surface: config, env, MCP,
model, and chat-PTY endpoints accept an optional ``profile`` so the global
profile switcher can target any profile's HERMES_HOME. These tests pin:
reads/writes land in the R... | 695 | 26,273 |
hermes-agent | tests/hermes_cli/test_update_fleet_restart_timeout.py | .py | """Regression for #68523 — one systemctl timeout must not abort fleet restarts.
On hosts with many profile-backed ``hermes-gateway*.service`` units,
``hermes update`` used to wrap the entire per-scope unit loop in a single
``except subprocess.TimeoutExpired``. A timeout on unit N skipped units
N+1…, leaving later gate... | 183 | 6,804 |
hermes-agent | tests/hermes_cli/test_cli_startup_model_cost_guard.py | .py | from argparse import Namespace
import sys
import types
import pytest
class _NonInteractiveStdin:
def isatty(self):
return False
def _chat_args(**overrides):
base = {
"continue_last": None,
"model": None,
"provider": None,
"resume": None,
"no_restore_cwd": Fal... | 310 | 9,524 |
hermes-agent | tests/hermes_cli/test_kanban_worktree_teardown.py | .py | """Tests for worktree workspace teardown at task completion/archive.
Covers the ownership gap where kanban ``worktree`` workspaces were never
reaped by anything: ``_cleanup_workspace`` preserved them by design, the CLI
startup pruner explicitly skips ``t_*`` worktrees ("dispatcher-driven
lifecycle"), and ``kanban gc``... | 221 | 8,312 |
hermes-agent | tests/hermes_cli/test_gateway_windows.py | .py | """Tests for hermes_cli.gateway_windows."""
import logging
import subprocess
from pathlib import Path
from types import SimpleNamespace
import pytest
import hermes_cli.gateway as gateway
import hermes_cli.gateway_windows as gateway_windows
import hermes_cli.setup as setup
_BREAKAWAY_MARKER = "_HERMES_GATEWAY_BREAK... | 373 | 14,831 |
hermes-agent | tests/hermes_cli/test_web_server.py | .py | """Tests for hermes_cli.web_server and related config utilities."""
import asyncio
import os
import json
import shutil
import sys
import threading
import time
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import patch, MagicMock
import pytest
import yaml
from hermes_cli.config import ... | 4,807 | 184,245 |
hermes-agent | tests/acp/test_session.py | .py | """Tests for acp_adapter.session — SessionManager and SessionState."""
import contextlib
import io
import json
import time
from types import SimpleNamespace
import pytest
from unittest.mock import MagicMock, patch
from acp_adapter import session as acp_session
from acp_adapter.session import SessionManager, SessionSt... | 378 | 13,201 |
hermes-agent | tests/tools/test_computer_use_cua_0_9.py | .py | """Behavior contracts for cua-driver's verify/escalate and typed-browser ladder.
The fixture used here is a deliberately selected and normalized ``tools/list``
capture. It contains schemas, not machine/user state, and records the 0.9-era
contract where input properties are the discovery surface.
"""
from __future__ ... | 959 | 30,774 |
hermes-agent | tests/tools/test_allowlist_quoted_metachars.py | .py | """Tests for the quote-aware allowlist shell-operator check.
Port of can1357/oh-my-pi#7553: `command_allowlist` glob rules (e.g.
``cargo *``) used to reject any command whose *quoted arguments* contained
shell metacharacters — a cargo benchmark regex filter like
``'^layer3/write/(a|b)$'`` disqualified the whole comman... | 122 | 5,103 |
hermes-agent | tests/tools/test_terminal_hints.py | .py | """Tests for tools/terminal_hints.py — output-pattern failure hints."""
import json
from unittest.mock import patch as mock_patch
import pytest
from tools.terminal_hints import annotate_failure, annotate_masked_success
class TestAnnotateFailureBasics:
def test_success_never_annotated(self):
assert anno... | 249 | 9,195 |
hermes-agent | tests/tools/test_mcp_streamable_http_arity.py | .py | """The streamable-HTTP transport must accept both SDK generations' arity.
``streamable_http_client`` yields ``(read, write, get_session_id)`` on mcp 1.x
and ``(read, write)`` on mcp 2.x. ``_run_http`` unpacked a fixed 3-tuple, which
is 1.x's shape, so on 2.x every HTTP and SSE server failed its handshake with
``ValueE... | 215 | 7,593 |
hermes-agent | tests/tools/test_mcp_oauth_bidirectional.py | .py | """Regression test for the ``HermesMCPOAuthProvider.async_auth_flow`` bidirectional
generator bridge.
PR #11383 introduced a subclass method that wrapped the SDK's ``auth_flow`` with::
async for item in super().async_auth_flow(request):
yield item
``httpx``'s auth_flow contract is a **bidirectional** asy... | 219 | 8,622 |
hermes-agent | tests/tools/test_delegate.py | .py | #!/usr/bin/env python3
"""
Tests for the subagent delegation tool.
Uses mock AIAgent instances to test the delegation logic without
requiring API keys or real LLM calls.
Run with: python -m pytest tests/test_delegate.py -v
or: python tests/test_delegate.py
"""
import json
import os
import threading
import ti... | 1,954 | 81,706 |
hermes-agent | tests/tools/test_single_query_approval_mode.py | .py | """Tests for approvals.single_query_mode — configurable approval behavior for
single-query (-q) sessions.
Background (#86878): ``hermes chat -q "..."`` runs one turn and exits. cli.py
exports ``HERMES_INTERACTIVE=1`` (needed for interactive sudo password
prompts), which previously made ``_is_interactive_cli()`` report... | 364 | 18,829 |
hermes-agent | tests/tools/test_mcp_circuit_breaker.py | .py | """Tests for MCP tool-handler circuit-breaker recovery.
The circuit breaker in ``tools/mcp_tool.py`` is intended to short-circuit
calls to an MCP server that has failed ``_CIRCUIT_BREAKER_THRESHOLD``
consecutive times, then *transition back to a usable state* once the
server has had time to recover (or an explicit rec... | 572 | 21,311 |
hermes-agent | tests/tools/test_bot_mode_probe.py | .py | """Tests for tools/bot_mode_probe.py — the Bot Mode teammate-protocol section."""
import textwrap
import pytest
from tools import bot_mode_probe
@pytest.fixture(autouse=True)
def _fresh_cache():
bot_mode_probe._reset_cache_for_tests()
yield
bot_mode_probe._reset_cache_for_tests()
def _make_bot_profil... | 203 | 7,799 |
hermes-agent | tests/tools/test_mcp_identity_header.py | .py | """Tests for the per-server MCP identity header (``identity_header``).
An optional per-server config key in ``mcp_servers`` attaches a static or
profile-derived identity header to that server's HTTP/SSE transport
requests:
mcp_servers:
remote_api:
url: "https://my-mcp-server.example.com/mcp"
... | 284 | 9,794 |
hermes-agent | tests/tools/test_skill_ledger.py | .py | """Tests for tools/skill_ledger.py — per-mutation audit ledger + rollback.
Covers tracker #79686 P3: ledger entries on patch/edit/delete/archive, blob
dedupe, single-entry rollback (incl. fail-closed safety capture), actor
tagging, and the skills.ledger config gate.
The first four tests are adapted from PR #50261 by ... | 368 | 12,556 |
hermes-agent | tests/tools/test_mcp_oauth_manager.py | .py | """Tests for the MCP OAuth manager (tools/mcp_oauth_manager.py).
The manager consolidates the eight scattered MCP-OAuth call sites into a
single object with disk-mtime watch, dedup'd 401 handling, and a provider
cache. See `tools/mcp_oauth_manager.py` for design rationale.
"""
import json
import os
import time
from un... | 490 | 17,904 |
hermes-agent | tests/tools/test_computer_use.py | .py | """Tests for the computer_use toolset (cua-driver backend, universal schema)."""
from __future__ import annotations
import base64
import json
import os
import sys
from typing import Any, Dict, List, cast
from unittest.mock import MagicMock, patch
import pytest
# ----------------------------------------------------... | 2,581 | 110,482 |
hermes-agent | tests/tools/test_local_env_blocklist.py | .py | """Tests for subprocess env sanitization in LocalEnvironment.
Verifies that Hermes-managed provider, tool, and gateway env vars are
stripped from subprocess environments so external CLIs are not silently
misrouted or handed Hermes secrets.
See: https://github.com/NousResearch/hermes-agent/issues/1002
See: https://git... | 1,029 | 46,279 |
hermes-agent | tests/tools/test_mcp_tool.py | .py | """Tests for the MCP (Model Context Protocol) client support.
All tests use mocks -- no real MCP servers or subprocesses are started.
"""
import asyncio
import json
import logging
import os
import sys
import threading
import time
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock, patch
... | 2,924 | 113,596 |
hermes-agent | tests/tools/test_mcp_oauth_cold_load_expiry.py | .py | """Tests for cold-load token expiry tracking in MCP OAuth.
PR #11383's consolidation fixed external-refresh reloading (mtime disk-watch)
and 401 dedup, but left two underlying latent bugs in place:
1. ``HermesTokenStorage.set_tokens`` persisted only relative ``expires_in``,
which is meaningless after a process res... | 479 | 17,849 |
hermes-agent | tests/tools/test_checkpoint_manager.py | .py | """Tests for tools/checkpoint_manager.py — CheckpointManager (v2 single-store)."""
import argparse
import json
import logging
import os
import shutil
import subprocess
import time
import pytest
from pathlib import Path
from unittest.mock import patch
from tools.checkpoint_manager import (
CheckpointManager,
_... | 1,151 | 47,179 |
hermes-agent | tests/tools/test_computer_use_zero_bounds.py | .py | """Zero-rect AX bounds must read as 'unknown', never as a clickable position.
Live QA (Aug 2026): KDE/Qt apps report [0,0,0,0] for elements that are
perfectly clickable by index (all of kcalc's radio buttons). A
plausible-looking zero rect invites coordinate=[0,0] derivation.
"""
from tools.computer_use.backend import... | 55 | 1,697 |
hermes-agent | tests/tools/test_mcp_dynamic_discovery.py | .py | """Tests for MCP dynamic tool discovery (notifications/tools/list_changed)."""
import asyncio
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from tools.mcp_tool import MCPServerTask, _register_server_tools
from tools.registry import ToolRegistry
def _make_mcp_... | 135 | 5,517 |
hermes-agent | tests/tools/test_skill_bundle_provenance.py | .py | """Multi-file third-party skill bundles and scanner provenance (#60598)."""
import json
import subprocess
import sys
import threading
from functools import partial
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from io import StringIO
from pathlib import Path
import pytest
from rich.console imp... | 246 | 9,623 |
hermes-agent | tests/tools/test_mcp_oauth.py | .py | """Tests for tools/mcp_oauth.py — OAuth 2.1 PKCE support for MCP servers."""
import json
import stat
import sys
from io import BytesIO
from unittest.mock import patch, MagicMock
import pytest
import asyncio
from tools.mcp_oauth import (
HermesTokenStorage,
OAuthNonInteractiveError,
build_oauth_auth,
... | 1,109 | 45,708 |
hermes-agent | tests/tools/test_mcp_elicitation.py | .py | """Tests for the MCP elicitation handler in tools.mcp_tool.
These tests exercise ElicitationHandler in isolation -- the underlying
approval system and the MCP transport layer are mocked, so no real MCP
server or user input is required.
Tests skip cleanly if the optional `mcp` SDK is not installed (it is an
optional d... | 285 | 11,064 |
hermes-agent | tests/tools/test_read_file_utf8_binary_regression.py | .py | """End-to-end regression tests for the UTF-8 'flagged as binary' class.
Covers the dupe-swarm cluster (#76886, #77047, #77842, #80221, #80251,
#80308, #80922) through the REAL local terminal backend — the transport
whose ``errors="replace"`` decode manufactured the U+FFFD that the old
text-layer heuristic misread as b... | 130 | 5,167 |
hermes-agent | tests/tools/test_mcp_capability_gating.py | .py | """Tests for capability-gated MCP tool discovery and keepalive.
Prompt-only / resource-only MCP servers do not implement the ``tools/*``
request family. Per the MCP spec, ``InitializeResult.capabilities.tools``
is non-None iff the server supports it. Before the capability gate, Hermes
always called ``tools/list`` duri... | 299 | 11,145 |
hermes-agent | tests/tools/test_mcp_tool_session_expired.py | .py | """Tests for MCP tool-handler transport-session auto-reconnect.
When a Streamable HTTP MCP server garbage-collects its server-side
session (idle TTL, server restart, pod rotation, …) it rejects
subsequent requests with a JSON-RPC error containing phrases like
``"Invalid or expired session"``. The OAuth token remains ... | 405 | 15,144 |
hermes-agent | tests/tools/test_computer_use_browser_contract_020.py | .py | """Behavior coverage for the cua-driver 0.20 public browser contract."""
import json
from typing import Any, Dict
from unittest.mock import Mock
from tools.computer_use.browser_route import CuaTypedBrowserRoute
from tools.computer_use.schema import COMPUTER_USE_SCHEMA
from tools.computer_use.tool import _dispatch
c... | 156 | 4,537 |
hermes-agent | tests/tools/test_tts_xai_speech_tags.py | .py | """Tests for xAI TTS speech-tag handling."""
from types import SimpleNamespace
from unittest.mock import Mock, patch
import pytest
from tools.tts_tool import (
_XAI_INLINE_SPEECH_TAGS,
_XAI_WRAPPING_SPEECH_TAGS,
_apply_xai_auto_speech_tags,
_generate_xai_tts,
)
def test_apply_xai_auto_speech_tags_a... | 308 | 10,704 |
hermes-agent | tests/tools/test_search_zero_match_and_multipath.py | .py | """Tests for search_files zero-match probes and multi-path recovery."""
import json
import os
import pytest
from tools.file_tools import search_tool
@pytest.fixture
def proj(tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path / ".hermes"))
d = tmp_path / "proj"
d.mkdir()
(d / "a.... | 182 | 7,959 |
hermes-agent | tests/tools/test_utf16_read.py | .py | """Tests for UTF-16 text file reading (transcode to UTF-8).
Ported from MoonshotAI/kimi-code#2647: UTF-16 text files (Windows Notepad
.txt, PowerShell `>` redirects) previously tripped the binary-file guard
because the terminal env decodes stdout as UTF-8 with errors="replace",
mangling the content with U+FFFD. ShellF... | 107 | 4,543 |
hermes-agent | tests/tools/test_approval.py | .py | """Tests for the dangerous command approval module."""
import os
import threading
import time
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import patch as mock_patch
import pytest
import tools.approval as approval_module
from hermes_constants import get_hermes_home
from tools.approva... | 1,785 | 73,342 |
hermes-agent | tests/tools/test_mcp_client_cert.py | .py | """Tests for mTLS client certificate config on MCP HTTP/SSE transports.
Covers:
1. ``_resolve_client_cert`` helper — string, tuple, encrypted-key, validation
errors, missing-file errors.
2. HTTP (new SDK ``streamable_http_client``) path forwards ``cert=`` into the
user-owned ``httpx.AsyncClient``.
3. SSE path... | 340 | 11,844 |
hermes-agent | tests/tools/test_image_generation.py | .py | """Tests for tools/image_generation_tool.py — FAL multi-model support.
Covers the pure logic of the new wrapper: catalog integrity, the three size
families (image_size_preset / aspect_ratio / gpt_literal), the supports
whitelist, default merging, GPT quality override, and model resolution
fallback. Does NOT exercise f... | 661 | 27,983 |
hermes-agent | tests/tools/test_plugin_guard.py | .py | """Tests for tools/plugin_guard.py — plugin install security scanning.
Inspired by Claude Cowork's skill & plugin security scanning
(pass/warn/fail on upload/edit). These tests exercise the plugin-adapted
scanner: clean plugins pass, provider plugins reading their own API keys
pass (the documented requires_env pattern... | 264 | 10,294 |
hermes-agent | tests/tools/test_delegation_live_log.py | .py | """Tests for tools/delegation_live_log.py — live subagent transcripts.
Covers:
- writer event rendering + truncation + append/flush semantics
- failure-swallowing when the target dir is unwritable
- the tool_progress_callback observe() demux (assistant/tool events in order)
- dispatch-time creation: paths pre-created ... | 337 | 12,462 |
hermes-agent | tests/tools/test_process_registry.py | .py | """Tests for tools/process_registry.py — ProcessRegistry query methods, pruning, checkpoint."""
import json
import os
import signal
import subprocess
import sys
import threading
import time
import pytest
from unittest.mock import MagicMock, patch
from tools.environments.local import _HERMES_PROVIDER_ENV_FORCE_PREFIX
... | 2,416 | 96,884 |
hermes-agent | tests/tools/test_terminal_signal_exit.py | .py | """Tests for signal-termination exit code interpretation.
Ported from Kilo-Org/kilocode#12698 ("settle signal-terminated shell
commands as 128 + signum"): the model must see a human-readable note for
signal deaths instead of a bare exit_code=-9 / 137 it burns turns
mis-diagnosing.
"""
import pytest
from tools.termin... | 96 | 3,375 |
hermes-agent | tests/tools/test_mcp_structured_content.py | .py | """Tests for MCP tool structuredContent preservation."""
import asyncio
import json
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from tools import mcp_tool
class _FakeContentBlock:
"""Minimal content block with .text and .type attributes."""
def __i... | 218 | 8,394 |
hermes-agent | tests/tools/test_image_generation_interrupt.py | .py | """_wait_fal_result must notice a user interrupt while the FAL job runs."""
import threading
import time
import pytest
import tools.image_generation_tool as image_tool
from tools.interrupt import set_interrupt
class _SlowHandler:
"""Fake FAL handler whose get() blocks like the real SDK."""
def __init__(se... | 83 | 2,252 |
hermes-agent | tests/tools/test_computer_use_input_target_guard.py | .py | """Input actions must not silently deliver to a different app than requested.
Live QA (Aug 2026, KDE desktop): with kcalc as the sticky target,
``type(text="777", app="kate")`` reported ok:true and typed 777 into
KCALC — app= was silently dropped on every input action. The guard
refuses provable mismatches with a one-... | 114 | 4,004 |
hermes-agent | tests/tools/test_xai_http_credentials.py | .py | import pytest
def _set_xai_oauth_unavailable(monkeypatch):
from hermes_cli import auth
monkeypatch.setattr(auth, "resolve_xai_oauth_runtime_credentials", lambda **_: {})
def test_xai_credentials_fail_closed_without_profile_scope(tmp_path, monkeypatch):
from agent import secret_scope
from hermes_cli... | 185 | 6,966 |
hermes-agent | tests/tools/test_computer_use_browser_authorization.py | .py | """Authorization plumbing for the cua-driver typed browser route.
Covers the authorization modes that let ``existing_profile`` attachment (and
bounded automation generally) work from Hermes:
* ``bounded`` permission mode — a private embedded daemon launched with a
user-reviewed capability manifest (``--capability-m... | 611 | 20,562 |
hermes-agent | tests/tools/test_computer_use_cua_0_10_permissions.py | .py | """Behavior contracts for cua-driver 0.10 permission-mode integration."""
from __future__ import annotations
from types import SimpleNamespace
from unittest.mock import Mock, patch
import pytest
@pytest.fixture(autouse=True)
def _reset_computer_use_state():
from tools.computer_use.tool import reset_backend_for... | 330 | 11,517 |
hermes-agent | tests/tools/test_mcp_dashboard_oauth.py | .py | """Hosted-dashboard bridge for MCP OAuth browser callbacks."""
import asyncio
import threading
import pytest
def test_dashboard_flow_exposes_authorization_url_and_accepts_callback():
from tools.mcp_dashboard_oauth import DashboardOAuthFlow
flow = DashboardOAuthFlow(
flow_id="flow-1",
server... | 117 | 3,901 |
hermes-agent | tests/tools/test_x_search_tool.py | .py | """Tests for the X (Twitter) Search tool backed by xAI Responses API.
Covers:
- HTTP request shape (URL, headers, payload, model from config)
- Handle filter validation (allowed vs excluded mutual exclusion)
- Inline url_citation extraction from message annotations
- Structured error handling (4xx with code, 5xx retry... | 435 | 15,337 |
hermes-agent | tests/tools/test_unicode_tag_strip.py | .py | """Tests for Unicode TAG character stripping (U+E0000–U+E007F).
Tag characters are invisible in terminals/chat UIs but visible to LLM
tokenizers — the "ASCII smuggling" prompt-injection channel for untrusted
tool output. Ported from block/goose#10746, with one deliberate divergence:
valid emoji tag sequences (regiona... | 56 | 2,428 |
hermes-agent | tests/run_agent/test_agent_guardrails.py | .py | """Unit tests for AIAgent pre/post-LLM-call guardrails.
Covers three static methods on AIAgent (inspired by PR #1321 — @alireza78a):
- _sanitize_api_messages() — Phase 1: orphaned tool pair repair
- _cap_delegate_task_calls() — Phase 2a: subagent concurrency limit
- _deduplicate_tool_calls() — Phase 2b: id... | 334 | 12,074 |
hermes-agent | tests/run_agent/test_background_review.py | .py | """Regression tests for background review agent cleanup."""
from __future__ import annotations
import run_agent as run_agent_module
from run_agent import AIAgent
def _bare_agent() -> AIAgent:
agent = object.__new__(AIAgent)
agent.model = "fake-model"
agent.platform = "telegram"
agent.provider = "ope... | 460 | 14,601 |
hermes-agent | tests/run_agent/test_tool_call_guardrail_runtime.py | .py | """Runtime tests for tool-call loop guardrails."""
import json
import uuid
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
from run_agent import AIAgent
def _make_tool_defs(*names: str) -> list[dict]:
return [
{
"type": "function",
"function": {
... | 426 | 16,444 |
hermes-agent | tests/run_agent/test_stream_stale_circuit_breaker.py | .py | """Cross-turn stream-stale circuit breaker (issue #58962).
A session wedged against an unresponsive provider can hit the stale-stream
detector on every turn and loop forever, burning the full 180s×retries each
turn with no response (observed: 494 consecutive failures over 3+ days).
These tests cover the guard added t... | 155 | 6,627 |
hermes-agent | tests/run_agent/test_run_agent.py | .py | """Unit tests for run_agent.py (AIAgent).
Tests cover pure functions, state/structure methods, and conversation loop
pieces. The OpenAI client and tool loading are mocked so no network calls
are made.
"""
import ast
import inspect
import io
import json
import logging
import re
import threading
import time
import uuid... | 6,684 | 276,660 |
hermes-agent | tests/run_agent/test_background_review_cost_controls.py | .py | """Unit coverage for the background-review aux-model selector + routed digest.
Covers the two behaviors this change adds:
• _resolve_review_runtime — auto/same-model → not routed (main model, warm
cache); a configured different model → routed with resolved credentials.
• _digest_history — compact replay used O... | 176 | 7,386 |
hermes-agent | tests/run_agent/test_continuation_repetition_guard.py | .py | """Regression tests for the truncated-response repetition guard (#86581).
A truncated response (``finish_reason=length``) dominated by verbatim
repeated text must NOT be continued: the continuation nudge would stitch the
pathological fragment into the final response (the #86581 incident delivered
60,698 chars as 31 Di... | 100 | 3,391 |
hermes-agent | tests/run_agent/test_anthropic_prompt_cache_policy.py | .py | """Tests for AIAgent._anthropic_prompt_cache_policy().
The policy returns ``(should_cache, use_native_layout)`` for five endpoint
classes. The test matrix pins the decision for each so a regression (e.g.
silently dropping caching on third-party Anthropic gateways, or applying
the native layout on OpenRouter) surfaces ... | 884 | 36,206 |
hermes-agent | tests/run_agent/test_turn_completion_explainer.py | .py | """Tests for the end-of-turn completion explainer (#34452).
When a turn ends abnormally after tools (empty content after retries, a
partial/truncated stream, exhausted retries, or an iteration/budget limit)
the user should get a single user-visible explanation of why the reply
stopped instead of a blank or fragmentary... | 429 | 16,897 |
hermes-agent | tests/state/test_compression_lineage_guard.py | .py | """Regression tests for stale writes after a compression session split."""
from __future__ import annotations
import time
import pytest
from hermes_state import SessionDB
@pytest.fixture()
def db(tmp_path):
session_db = SessionDB(db_path=tmp_path / "state.db")
try:
yield session_db
finally:
... | 326 | 11,549 |
hermes-agent | tests/hermes_state/test_aux_usage_accounting.py | .py | """Tests for auxiliary usage accounting (issue #23270).
Auxiliary LLM calls (vision, compression, title_generation, ...) record
their token usage into session_model_usage with a ``task`` dimension via
the ambient accounting context (agent/aux_accounting.py), making aux model
spend visible in analytics.
"""
from pathli... | 299 | 11,283 |
hermes-agent | tests/cron/test_scheduler.py | .py | """Tests for cron/scheduler.py — origin resolution, delivery routing, and error logging."""
import contextlib
import itertools
import json
import logging
import os
from unittest.mock import AsyncMock, patch, MagicMock
import pytest
from cron.scheduler import (
SILENT_MARKER,
_build_job_prompt,
_deliver_r... | 2,611 | 113,492 |
hermes-agent | tests/cron/test_cron_script.py | .py | """Tests for cron job script injection feature.
Tests cover:
- Script field in job creation / storage / update
- Script execution and output injection into prompts
- Error handling (missing script, timeout, non-zero exit)
- Path resolution (absolute, relative to HERMES_HOME/scripts/)
"""
import json
import os
import ... | 632 | 23,354 |
hermes-agent | tests/cron/test_jobs.py | .py | """Tests for cron/jobs.py — schedule parsing, job CRUD, and due-job detection."""
import threading
import pytest
from datetime import datetime, timedelta, timezone
from cron.jobs import (
parse_duration,
parse_schedule,
compute_next_run,
create_job,
load_jobs,
save_jobs,
get_job,
list_... | 1,385 | 59,956 |
hermes-agent | tests/cron/test_cron_no_agent.py | .py | """Tests for cronjob no_agent mode — script-driven jobs that skip the LLM.
Covers:
* ``create_job(no_agent=True)`` shape, validation, and serialization.
* ``cronjob(action='create', no_agent=True)`` tool-level validation.
* ``cronjob(action='update')`` flipping no_agent on/off.
* ``scheduler.run_job`` short-circuit p... | 370 | 13,776 |
hermes-agent | tests/cron/test_cron_context_from.py | .py | """Tests for cron job context_from feature (issue #5439 Option C)."""
import logging
import sys
from pathlib import Path
import pytest
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
@pytest.fixture
def cron_env(tmp_path, monkeypatch):
"""Isolated cron environment with temp HERMES_HOME."""
her... | 443 | 16,184 |
hermes-agent | tests/gateway/test_media_tag_cleanup.py | .py | """Tests for MEDIA_TAG_CLEANUP_RE regex matching behavior (#63632)."""
class TestMediaTagCleanup:
"""Tests for MEDIA_TAG_CLEANUP_RE regex matching behavior."""
def test_media_tag_with_directive_glued_to_extension(self):
"""Regression: MEDIA:<path>[[as_document]] must match when directive is glued
... | 99 | 4,265 |
hermes-agent | tests/gateway/test_session_hygiene.py | .py | """Tests for gateway session hygiene — auto-compression of large sessions.
Verifies that the gateway detects pathologically large transcripts and
triggers auto-compression before running the agent. (#628)
The hygiene system uses the SAME compression config as the agent:
compression.threshold × model context length... | 1,199 | 47,961 |
hermes-agent | tests/gateway/test_status.py | .py | """Tests for gateway runtime status tracking."""
import json
import os
import sys
import time
from pathlib import Path
from types import SimpleNamespace
import pytest
from gateway import status
class TestGatewayPidState:
def test_write_pid_file_records_gateway_metadata(self, tmp_path, monkeypatch):
mon... | 1,390 | 58,053 |
hermes-agent | tests/gateway/test_hygiene_failure_cooldown_ladder.py | .py | """Session-hygiene compression must escalate its cooldown for repeat failures.
Issue #79624: a gateway session whose summary model always times out retried
compaction on a flat ``hygiene_failure_cooldown_seconds`` interval forever.
The in-agent compressor already escalates repeat timeouts 60 -> 300 -> 900s via
``Cont... | 423 | 17,240 |
hermes-agent | tests/gateway/test_telegram_auth_check.py | .py | """Tests for Telegram adapter early authorization check.
Verifies that unauthorized users are blocked before any text batching,
event building, or response generation occurs.
"""
import asyncio
from types import SimpleNamespace
from unittest.mock import AsyncMock, patch
import pytest
from gateway.config import Platf... | 373 | 13,784 |
hermes-agent | tests/gateway/test_loop_command.py | .py | """Gateway /loop command tests — dispatch, routing capture, mid-run guard."""
import logging
import time
from unittest.mock import AsyncMock, Mock
import pytest
from gateway.config import GatewayConfig, Platform, PlatformConfig
from gateway.platforms.base import MessageEvent, MessageType
from gateway.run import Gate... | 251 | 8,534 |
hermes-agent | tests/gateway/test_webhook_adapter.py | .py | """Unit tests for the generic webhook platform adapter.
Covers:
- HMAC signature validation (GitHub, GitLab, generic)
- Prompt rendering with dot-notation template variables
- Event type filtering
- HTTP handler behaviour (404, 202, health)
- Idempotency cache (duplicate delivery IDs)
- Rate limiting (fixed-window, pe... | 1,027 | 39,658 |
hermes-agent | tests/gateway/test_baseexception_turn_notify.py | .py | """Regression: _process_message_background must notify the user when a turn
raises a BaseException such as SystemExit/KeyboardInterrupt (#86651).
The handler is fire-and-forget (create_task, never awaited). Before the fix
its except chain caught only asyncio.CancelledError and Exception, so a
SystemExit escaping from ... | 125 | 4,127 |
hermes-agent | tests/gateway/test_telegram_lazy_install_typehandler.py | .py | """Regression test for the Telegram lazy-install rebind path (#85272).
When ``plugins.platforms.telegram.adapter`` is imported before
python-telegram-bot is available, the top-level ``except ImportError`` block
binds every SDK symbol to a placeholder. ``check_telegram_requirements()`` then
lazy-installs the package an... | 146 | 4,893 |
hermes-agent | tests/gateway/test_multiplex_adapter_registry.py | .py | """Phase 3: secondary-profile adapter registry + same-token conflict detection."""
import logging
import asyncio
from contextlib import contextmanager
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock
import pytest
import gateway.run as gateway_run
from gateway.config import GatewayConfig, Platf... | 642 | 23,840 |
hermes-agent | tests/gateway/test_usage_command.py | .py | from hermes_state import AsyncSessionDB
"""Tests for gateway /usage command — agent cache lookup and output fields."""
import threading
from unittest.mock import MagicMock, patch
import pytest
def _make_mock_agent(**overrides):
"""Create a mock AIAgent with realistic session counters."""
agent = MagicMock()... | 278 | 11,055 |
hermes-agent | tests/gateway/test_telegram_reply_mode.py | .py | """Tests for Telegram reply_to_mode functionality.
Covers the threading behavior control for multi-chunk replies:
- "off": Never thread replies to original message
- "first": Only first chunk threads (default)
- "all": All chunks thread to original message
"""
import os
import sys
from unittest.mock import MagicMock, ... | 332 | 13,130 |
hermes-agent | tests/gateway/test_status_command.py | .py | from hermes_state import AsyncSessionDB, SessionDB
"""Tests for gateway /status behavior and token persistence."""
from datetime import datetime
import time
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock
import pytest
from gateway.config import GatewayConfig, Platform, PlatformConfi... | 539 | 19,129 |
hermes-agent | tests/gateway/test_model_command_profile_config.py | .py | """Regression coverage for profile-scoped gateway ``/model`` reads."""
from types import SimpleNamespace
import pytest
from gateway.config import Platform
from gateway.platforms.base import MessageEvent, MessageType
from gateway.run import GatewayRunner
from gateway.session import SessionSource
class _CapturingPic... | 82 | 2,672 |
hermes-agent | tests/gateway/test_discord_split_cap.py | .py | """Regression tests for the Discord split-delivery cap (issue #86581).
A degenerate turn can produce tens of thousands of characters. Without a
ceiling, the adapter posts every 2000-char chunk back-to-back and floods the
channel — the #86581 incident delivered 60,698 chars as 31 messages. The
cap keeps the first ``M... | 157 | 5,340 |
hermes-agent | tests/gateway/test_local_model_connection_reply.py | .py | """Regression tests for #86570: gateway provider error connection messaging."""
import pytest
from gateway.run import (
_GATEWAY_CONNECTION_ERROR_RE,
_gateway_provider_error_reply,
_looks_like_gateway_provider_error,
)
class TestGatewayConnectionErrorReply:
def test_connection_error_strings_produce_... | 64 | 2,588 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.