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/gateway/test_stale_platform_lock_retryable.py | .py | """Regression tests for platform-lock acquire behavior.
#54167 — stale platform lock must be retryable.
When a gateway process is killed (SIGKILL, crash) during Telegram
initialization, the scoped lock file survives. On next startup,
``acquire_scoped_lock()`` detects the stale lock and deletes it, but may
still return... | 185 | 6,274 |
hermes-agent | tests/cli/test_cli_provider_resolution.py | .py | import importlib
import sys
import types
from contextlib import nullcontext
from types import SimpleNamespace
import pytest
from hermes_cli.auth import AuthError
from hermes_cli import main as hermes_main
# ---------------------------------------------------------------------------
# Module isolation: _import_cli()... | 683 | 24,119 |
hermes-agent | tests/cli/test_modify_other_keys_aliases.py | .py | """Regression tests for issue #87711 — Ctrl+key / Alt+key combos broken
under modifyOtherKeys level 2.
When the CLI pushes ``ESC[>4;2m`` (modifyOtherKeys=2) to supported
terminals so Shift+Enter is distinguishable from Enter, the terminal
re-encodes EVERY Ctrl+key combo as ``ESC[27;5;<codepoint>~`` instead of
the raw ... | 436 | 16,778 |
hermes-agent | tests/cli/test_exit_watchdog_signal_arm.py | .py | """Exit watchdog: arm on shutdown *intent* (signal), never at chat startup.
Regression coverage for the #65998 class: a ``hermes --tui`` process whose
main thread wedges before ``app.run()`` returns never executes the ``finally``
that calls ``_run_cleanup`` — the only place the exit watchdog used to be
armed — so a "d... | 169 | 6,157 |
hermes-agent | tests/plugins/image_gen/test_krea_provider.py | .py | #!/usr/bin/env python3
"""Tests for Krea image generation provider."""
from __future__ import annotations
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
# ---------------------------------------------------------------------------
# Fixtures
# ------------------------------------... | 706 | 28,083 |
hermes-agent | tests/plugins/memory/test_openviking_provider.py | .py | import json
import os
import socket
import stat
import threading
import time
import zipfile
from types import SimpleNamespace
from unittest.mock import MagicMock
import pytest
import plugins.memory.openviking as openviking_module
from plugins.memory.openviking import (
OpenVikingMemoryProvider,
_DEFERRED_COMM... | 1,778 | 61,668 |
hermes-agent | tests/agent/test_async_token_accounting.py | .py | """Async token accounting — SessionDB background writer queue.
queue_token_counts() must take the per-call sessions UPDATE off the turn
thread while preserving update_token_counts() semantics exactly:
1. Deltas apply in enqueue order.
2. Coalescing consecutive same-route deltas is sum-equivalent to applying
them o... | 551 | 21,292 |
hermes-agent | tests/agent/test_repetition_guard.py | .py | """Unit tests for the truncated-response repetition guard (issue #86581)."""
from __future__ import annotations
from agent.repetition_guard import MIN_FRAGMENT_LENGTH, is_repetition_dominated
# The exact sentence from the #86581 incident (echoed hundreds of times by
# the model before the provider cut it off at fini... | 51 | 2,342 |
hermes-agent | tests/agent/test_subdirectory_hints.py | .py | """Tests for progressive subdirectory hint discovery."""
import pytest
from pathlib import Path
from unittest.mock import patch
from agent.subdirectory_hints import SubdirectoryHintTracker
@pytest.fixture
def project(tmp_path):
"""Create a mock project tree with hint files in subdirectories."""
# Root — alr... | 300 | 12,176 |
hermes-agent | tests/agent/test_gemini_native_adapter.py | .py | """Tests for the native Google AI Studio Gemini adapter."""
from __future__ import annotations
import json
from types import SimpleNamespace
import pytest
class DummyResponse:
def __init__(self, status_code=200, payload=None, headers=None, text=None):
self.status_code = status_code
self._payloa... | 460 | 16,111 |
hermes-agent | tests/agent/test_empty_response_guard.py | .py | """Tests for agent/empty_response_guard.py (NS-503).
The guard exists to stop the empty-retry loop re-billing large inputs for
deterministic empties (unsignaled provider refusals with zero output
tokens) while never tightening behaviour on ambiguous evidence.
Fail-open contract under test:
- Missing usage -> never de... | 358 | 13,930 |
hermes-agent | tests/agent/test_error_classifier.py | .py | """Tests for agent.error_classifier — structured API error classification."""
import pytest
from agent.error_classifier import (
ClassifiedError,
FailoverReason,
PROVIDER_STREAM_NON_JSON_ERROR_CODE,
classify_api_error,
_extract_status_code,
_extract_error_body,
_extract_error_code,
_cla... | 1,295 | 51,521 |
hermes-agent | tests/agent/test_turn_finalizer_iteration_limit_exit.py | .py | """Regression tests for iteration-limit exit normalization (#61631)."""
from types import SimpleNamespace
from unittest.mock import MagicMock
import pytest
from agent.turn_finalizer import finalize_turn
class _LimitAgent:
def __init__(
self,
*,
max_iterations=60,
budget_remainin... | 376 | 12,276 |
hermes-agent | tests/agent/test_shell_hooks.py | .py | """Tests for the shell-hooks subprocess bridge (agent.shell_hooks).
These tests focus on the pure translation layer — JSON serialisation,
JSON parsing, matcher behaviour, block-schema correctness, and the
subprocess runner's graceful error handling. Consent prompts are
covered in ``test_shell_hooks_consent.py``.
"""
... | 740 | 26,827 |
hermes-agent | tests/agent/test_curator_backup.py | .py | """Tests for agent/curator_backup.py — snapshot + rollback of the skills tree."""
from __future__ import annotations
import importlib
import json
import os
import sys
import tarfile
import tempfile
from pathlib import Path
import pytest
@pytest.fixture
def backup_env(monkeypatch, tmp_path):
"""Isolate HERMES_H... | 487 | 17,791 |
hermes-agent | tests/agent/test_model_metadata.py | .py | """Tests for agent/model_metadata.py — token estimation, context lengths,
probing, caching, and error parsing.
Coverage levels:
Token estimation — concrete value assertions, edge cases
Context length lookup — resolution order, fuzzy match, cache priority
API metadata fetch — caching, TTL, canonical sl... | 1,737 | 74,536 |
hermes-agent | tests/agent/test_prompt_builder.py | .py | """Tests for agent/prompt_builder.py — context scanning, truncation, skills index."""
import builtins
import importlib
import logging
import os
import sys
import pytest
from agent.prompt_builder import (
_scan_context_content,
_truncate_content,
_parse_skill_file,
_skill_should_show,
_find_hermes... | 1,016 | 39,863 |
hermes-agent | tests/agent/test_hygiene_timeout_cooldown_isolation.py | .py | """Hygiene idle-timeout cooldowns must not block the in-agent compressor."""
from __future__ import annotations
import time
from pathlib import Path
from unittest.mock import patch
from agent.context_compressor import ContextCompressor
from hermes_state import SessionDB
_HYGIENE_TIMEOUT_ERROR = (
"session hygie... | 95 | 3,036 |
hermes-agent | tests/agent/test_background_review_usage.py | .py | """Background-review usage attribution (issue #87250).
Background-review forks run with ``_session_db = None`` (persistence
isolation), so their provider-billed API calls were never recorded in
``session_model_usage``. ``_record_review_usage_to_parent`` closes that gap
by snapshotting the fork's in-memory counters and... | 199 | 6,196 |
hermes-agent | tests/agent/test_skill_utils.py | .py | """Tests for agent/skill_utils.py."""
from unittest.mock import patch
import pytest
from agent.skill_utils import (
extract_skill_config_vars,
extract_skill_conditions,
get_disabled_skill_names,
get_external_skills_dirs,
is_excluded_skill_path,
is_external_skill_path,
is_skill_support_pat... | 385 | 14,154 |
hermes-agent | tests/agent/test_verification_evidence.py | .py | import json
import sqlite3
import tempfile
from datetime import datetime, timedelta, timezone
from pathlib import Path
import pytest
from agent.verification_evidence import (
classify_verification_command,
mark_workspace_edited,
record_terminal_result,
verification_status,
)
def _node_project(root: ... | 353 | 10,014 |
hermes-agent | tests/agent/test_copilot_acp_client.py | .py | """Focused regressions for the Copilot ACP shim safety layer."""
from __future__ import annotations
import io
import json
import os
import tempfile
import unittest
from pathlib import Path
from unittest.mock import patch
from agent.copilot_acp_client import CopilotACPClient
class _FakeProcess:
def __init__(sel... | 320 | 11,966 |
hermes-agent | tests/agent/test_skill_commands.py | .py | """Tests for agent/skill_commands.py — skill slash command scanning and platform filtering."""
import os
from pathlib import Path
from unittest.mock import patch
import pytest
import tools.skills_tool as skills_tool_module
from agent.skill_commands import (
build_preloaded_skills_prompt,
build_skill_invocati... | 748 | 28,971 |
hermes-agent | tests/agent/test_bedrock_interrupt_post_worker.py | .py | """Regression: /stop must not be swallowed on the Bedrock streaming path.
Companion to the OpenAI/Anthropic streaming post-worker guard. The Bedrock
Converse stream callback (bedrock_adapter.stream_converse_with_callbacks) breaks
out of its event loop on interrupt and returns a PARTIAL response WITHOUT
raising. The wo... | 119 | 4,914 |
hermes-agent | tests/agent/test_sequential_tool_interrupt.py | .py | """Sequential tool execution must abandon the wait when the user interrupts.
Regression tests for the "interrupt doesn't end a running tool" class:
the sequential executor path previously ran the tool inline (when the
deadline was disabled) or waited in 5s slices without checking
``agent._interrupt_requested`` — a non... | 196 | 6,182 |
hermes-agent | tests/agent/transports/test_codex_transport.py | .py | """Tests for the ResponsesApiTransport (Codex)."""
import json
import pytest
from types import SimpleNamespace
from agent.transports import get_transport
from agent.transports.types import NormalizedResponse
@pytest.fixture
def transport():
import agent.transports.codex # noqa: F401
return get_transport("c... | 1,224 | 50,256 |
hermes-agent | tests/agent/transports/test_chat_completions.py | .py | """Tests for the ChatCompletionsTransport."""
import json
from types import SimpleNamespace
import httpx
import pytest
from openai import OpenAI
from agent.transports import get_transport
from agent.transports.types import NormalizedResponse
@pytest.fixture
def transport():
import agent.transports.chat_complet... | 813 | 30,451 |
hermes-agent | cron/lifecycle_guard.py | .py | """Gateway lifecycle guard for cron job creation (#30719).
An agent running inside a gateway can schedule a cron job that calls
``hermes gateway restart`` (or ``launchctl kickstart ai.hermes.gateway``
or ``systemctl restart hermes-gateway``). When the cron fires, the
gateway dies, the supervisor (launchd KeepAlive / ... | 802 | 35,156 |
hermes-agent | cron/scheduler.py | .py | """
Cron job scheduler - executes due jobs.
Provides tick() which checks for due jobs and runs them. The gateway
calls this every 60 seconds from a background thread.
Uses a file-based lock (~/.hermes/cron/.tick.lock) so only one tick
runs at a time if multiple processes overlap.
"""
import asyncio
import atexit
imp... | 6,831 | 311,454 |
hermes-agent | cron/jobs.py | .py | """
Cron job storage and management.
Jobs are stored in ~/.hermes/cron/jobs.json
Output is saved to ~/.hermes/cron/output/{job_id}/{timestamp}.md
"""
import contextlib
import copy
from contextvars import ContextVar
from dataclasses import dataclass
import json
import logging
import shutil
import tempfile
import threa... | 3,478 | 147,985 |
hermes-agent | gateway/session_state.py | .py | """Per-session gateway state consolidated into one container.
GatewayRunner historically carried ~19 separate ``Dict[str, ...]`` attributes
keyed by session_key, each with its own ad-hoc lifecycle. Three failure
classes grew out of that shape:
1. Boundary drift — every conversation boundary carried a hand-copied
... | 476 | 18,959 |
hermes-agent | gateway/status.py | .py | """
Gateway runtime status helpers.
Provides PID-file based detection of whether the gateway daemon is running,
used by send_message's check_fn to gate availability in the CLI.
The PID file lives at ``{HERMES_HOME}/gateway.pid``. HERMES_HOME defaults to
``~/.hermes`` but can be overridden via the environment variabl... | 2,377 | 93,566 |
hermes-agent | gateway/slash_commands.py | .py | """Gateway slash-command handlers for GatewayRunner.
Extracted from ``gateway/run.py`` (god-file decomposition Phase 3b). These are
the in-session slash commands (/model, /reset, /usage, /compress, ...) the
gateway dispatches from ``_handle_message``. There are 42 of them (~3,200 LOC);
lifting them into a mixin that `... | 5,978 | 285,753 |
hermes-agent | gateway/platforms/base.py | .py | """
Base platform adapter interface.
All platform adapters (Telegram, Discord, WhatsApp, Weixin, and more) inherit from this
and implement the required methods.
"""
import asyncio
import inspect
import ipaddress
import logging
import os
import random
import re
import socket as _socket
import subprocess
import sys
imp... | 7,358 | 327,586 |
hermes-agent | gateway/platforms/webhook.py | .py | """Generic webhook platform adapter.
Runs an aiohttp HTTP server that receives webhook POSTs from external
services (GitHub, GitLab, JIRA, Stripe, etc.), validates HMAC signatures,
transforms payloads into agent prompts, and routes responses back to the
source or to another configured platform.
Configuration lives in... | 1,463 | 63,593 |
hermes-agent | acp_adapter/session.py | .py | """ACP session manager — maps ACP sessions to Hermes AIAgent instances.
Sessions are persisted to the shared SessionDB (``~/.hermes/state.db``) so they
survive process restarts and appear in ``session_search``. When the editor
reconnects after idle/restart, the ``load_session`` / ``resume_session`` calls
find the per... | 696 | 28,282 |
hermes-agent | plugins/image_gen/krea/__init__.py | .py | """Krea image generation backend.
Exposes Krea's `Krea 2` foundation image model family — Krea 2 Medium and
Krea 2 Large — as an :class:`ImageGenProvider` implementation.
Krea's API is asynchronous: the generate endpoint returns a ``job_id``
that you poll at ``GET /jobs/{job_id}``. This provider hides that
roundtrip ... | 906 | 36,180 |
hermes-agent | plugins/platforms/discord/adapter.py | .py | from __future__ import annotations
"""
Discord platform adapter.
Uses discord.py library for:
- Receiving messages from servers and DMs
- Sending responses back
- Handling threads and channels
"""
import asyncio
import datetime as dt
import hashlib
import inspect
import json
import logging
import math
import os
impo... | 10,558 | 475,872 |
hermes-agent | plugins/memory/openviking/__init__.py | .py | """OpenViking memory plugin — full bidirectional MemoryProvider interface.
Context database by Volcengine (ByteDance) that organizes agent knowledge
into a filesystem hierarchy (viking:// URIs) with tiered context loading,
automatic memory extraction, and session management.
Original PR #3369 by Mibayy, rewritten to ... | 5,269 | 207,070 |
hermes-agent | evals/compaction/runner.py | .py | """Compaction eval runner.
Pipeline per transcript:
1. Load + cap the transcript.
2. Generate (or load cached) recall questions from the region that will be
summarized away under the CURRENT policy (the most conservative boundary:
anything the current policy summarizes is fair game for every policy).
3... | 357 | 14,601 |
hermes-agent | evals/compaction/fixtures.py | .py | """Transcript fixtures for the compaction eval harness.
Real transcripts are supplied by path (never committed). This module loads
them, estimates tokens the same way the harness scores them, and can generate
a small synthetic transcript so CI smoke tests run without real data.
"""
from __future__ import annotations
... | 80 | 2,872 |
hermes-agent | evals/compaction/test_region_scoping.py | .py | """Region-scoping tripwire: the summarizer must only see the compacted region.
Builds a transcript with sentinel strings planted in (a) the protected head,
(b) the middle (to-be-compacted) region, and (c) the tail, mocks call_llm to
capture the prompt, and asserts head/tail sentinels never reach the
summarizer while t... | 99 | 4,407 |
hermes-agent | evals/compaction/policies.py | .py | """Compaction policy matrix.
Each policy is a name -> spec mapping. A spec has:
ctor: extra kwargs for ContextCompressor(...)
attrs: attribute overrides applied after construction (lets us pin
tail_token_budget and other derived values without touching the
class)
The runner constructs one compre... | 55 | 1,754 |
hermes-agent | evals/compaction/report.py | .py | """Render a compaction-eval scorecard as a terminal table + markdown.
Usage: python evals/compaction/report.py <results_dir>
"""
from __future__ import annotations
import json
import sys
from pathlib import Path
def main():
out_dir = Path(sys.argv[1])
card = json.loads((out_dir / "scorecard.json").read_text... | 44 | 1,458 |
hermes-agent | evals/compaction/scripts/build_html_report.py | .py | #!/usr/bin/env python3
"""Build a self-contained HTML report comparing compaction runs.
Usage: build_report.py <runs_dir> <out_html>
Expects runs/<checkout>_<session>.json pairs from run_compaction.py.
"""
import html
import json
import sys
from pathlib import Path
RUNS = Path(sys.argv[1])
OUT = sys.argv[2]
pairs = ... | 185 | 9,073 |
hermes-agent | evals/compaction/scripts/codex_arm.py | .py | #!/usr/bin/env python3
"""Run the codex CLI as an eval arm on the same transcripts + question banks.
Per transcript:
1. Split the 500K-token prefix into ~150KB chunk files in a work dir.
2. `codex exec` reads every file (2-3 sentence summary each) — the read
volume exceeds codex's 258K window, so its auto-com... | 212 | 7,783 |
hermes-agent | evals/compaction/scripts/reconstruct_lineage.py | .py | #!/usr/bin/env python3
"""Reconstruct the full uncompacted transcript of a session LINEAGE.
Rotation children start with a copy of the compressed parent (head + summary +
tail). To rebuild the real history: walk the chain root->leaf, append messages
not seen before (hash of role+content+tool_calls), and skip synthetic... | 89 | 3,138 |
hermes-agent | evals/compaction/scripts/replay_lineage.py | .py | #!/usr/bin/env python3
"""Replay a ~500K-token prefix of a reconstructed lineage through compaction.
Usage: run_lineage_compaction.py <checkout> <lineage_json> <out_json> [cap_tokens]
Takes the chronological prefix of the lineage at the token cap (default 500K =
the 50% trigger on a 1M-context model), aligned to a to... | 82 | 2,672 |
hermes-agent | agent/conversation_compression.py | .py | """Context compression — extract the AIAgent methods that drive summarisation.
Three concerns live here:
* :func:`check_compression_model_feasibility` — startup probe of the
configured auxiliary compression model. Warns when the aux context
window can't fit the main model's compression threshold; auto-lowers
t... | 4,330 | 204,992 |
hermes-agent | agent/curator.py | .py | """Curator — background skill maintenance orchestrator.
The curator is an auxiliary-model task that periodically reviews agent-created
skills and maintains the collection. It runs inactivity-triggered (no cron
daemon): when the agent is idle and the last curator run was longer than
``interval_hours`` ago, ``maybe_run_... | 2,035 | 87,802 |
hermes-agent | agent/skill_commands.py | .py | """Shared slash command helpers for skills.
Shared between CLI (cli.py) and gateway (gateway/run.py) so both surfaces
can invoke skills via /skill-name commands.
"""
import json
import logging
import os
import re
from pathlib import Path
from typing import Any, Dict, Optional
from hermes_constants import display_her... | 862 | 35,487 |
hermes-agent | agent/context_compressor.py | .py | """Automatic context window compression for long conversations.
Self-contained class with its own OpenAI client for summarization.
Uses auxiliary model (cheap/fast) to summarize middle turns while
protecting head and tail context.
Improvements over v2:
- Structured summary template with Resolved/Pending question tr... | 7,859 | 390,184 |
hermes-agent | agent/subdirectory_hints.py | .py | """Progressive subdirectory hint discovery.
As the agent navigates into subdirectories via tool calls (read_file, terminal,
search_files, etc.), this module discovers and loads project context files
(AGENTS.md, CLAUDE.md, .cursorrules) from those directories. Discovered hints
are appended to the tool result so the mo... | 342 | 13,329 |
hermes-agent | agent/shell_hooks.py | .py | """
Shell-script hooks bridge.
Reads the ``hooks:`` block from ``cli-config.yaml``, prompts the user for
consent on first use of each ``(event, command)`` pair, and registers
callbacks on the existing plugin hook manager so every existing
``invoke_hook()`` site dispatches to the configured shell scripts — with
zero ch... | 1,156 | 43,705 |
hermes-agent | agent/empty_response_guard.py | .py | """Deterministic-empty detection and cost-aware retry budgets (NS-503).
When a provider returns an empty completion, the agent loop retries up to
3 times and then walks the fallback chain. Every attempt re-sends the full
conversation input — at large context on paid routes this bills the user
repeatedly for a turn tha... | 273 | 10,620 |
hermes-agent | agent/model_metadata.py | .py | """Model metadata, context lengths, and token estimation utilities.
Pure utility functions with no AIAgent dependency. Used by ContextCompressor
and run_agent.py for pre-flight context checks.
"""
import base64
import hashlib
import ipaddress
import json
import logging
import os
import re
import time
from pathlib imp... | 3,571 | 158,009 |
hermes-agent | agent/copilot_acp_client.py | .py | """OpenAI-compatible shim that forwards Hermes requests to `copilot --acp`.
This adapter lets Hermes treat the GitHub Copilot ACP server as a chat-style
backend. Each request starts a short-lived ACP session, sends the formatted
conversation as a single prompt, collects text chunks, and converts the result
back into t... | 841 | 31,290 |
hermes-agent | agent/background_review.py | .py | """Background memory/skill review — fork the agent to evaluate the turn.
After every turn, ``AIAgent.run_conversation`` may call
:func:`spawn_background_review` to fire off a daemon thread that replays
the conversation snapshot in a forked :class:`AIAgent` and asks itself
"should any skill/memory be saved or updated?"... | 1,377 | 68,440 |
hermes-agent | agent/system_prompt.py | .py | """System-prompt assembly for :class:`AIAgent`.
The agent's system prompt is built once per session and reused across all
turns — only context compression triggers a rebuild. This keeps the
upstream prefix cache warm. See ``hermes-agent-dev``'s
``references/system-prompt-invariant.md`` for the invariants and
``refer... | 991 | 45,823 |
hermes-agent | agent/prompt_builder.py | .py | """System prompt assembly -- identity, platform hints, skills index, context files.
All functions are stateless. AIAgent._build_system_prompt() calls these to
assemble pieces, then combines them with memory and ephemeral prompts.
"""
import json
import logging
import os
import sys
import threading
import contextvars
... | 2,459 | 121,487 |
hermes-agent | agent/agent_init.py | .py | """Implementation of :meth:`AIAgent.__init__` — extracted as a module function.
``AIAgent.__init__`` is one of the longest methods in the codebase (60+
parameters, ~1,400 lines of attribute initialization, provider
auto-detection, credential resolution, context-engine bootstrap, etc.).
Keeping it in ``run_agent.py`` b... | 2,953 | 148,417 |
hermes-agent | agent/gemini_native_adapter.py | .py | """OpenAI-compatible facade over Google AI Studio's native Gemini API.
Hermes keeps ``api_mode='chat_completions'`` for the ``gemini`` provider so the
main agent loop can keep using its existing OpenAI-shaped message flow.
This adapter is the transport shim that converts those OpenAI-style
``messages[]`` / ``tools[]``... | 1,218 | 46,144 |
hermes-agent | agent/title_generator.py | .py | """Auto-generate short session titles from the user's opening message.
Two stages, both off the critical path:
1. **Instant** — a deterministic title derived from the first user message,
written before the model is even called. Costs nothing, cannot fail, and
means a session is named the moment it starts instea... | 763 | 32,459 |
hermes-agent | agent/repetition_guard.py | .py | """Cheap content-sanity checks for the truncated-response continuation path.
Issue #86581: a model in a degenerate repetition loop can spend its ENTIRE
output budget echoing one fragment. The ``finish_reason=length``
continuation path in ``conversation_loop.py`` would then retry with a
"continue, don't repeat" nudge ... | 96 | 3,917 |
hermes-agent | agent/conversation_loop.py | .py | """The agent conversation loop — extracted from ``run_agent.AIAgent``.
This is the biggest single chunk pulled out of ``run_agent.py``: the
roughly 3,900-line :func:`run_conversation` body that drives one user
turn through the agent (model call, tool dispatch, retries, fallbacks,
compression, post-turn hooks, backgrou... | 8,266 | 463,404 |
hermes-agent | agent/curator_backup.py | .py | """Curator snapshot + rollback.
A pre-run snapshot of ``~/.hermes/skills/`` (excluding ``.curator_backups/``
itself) is taken before any mutating curator pass. Snapshots are tar.gz
files under ``~/.hermes/skills/.curator_backups/<utc-iso>/`` with a
companion ``manifest.json`` describing the snapshot (reason, time, siz... | 759 | 29,988 |
hermes-agent | agent/verification_evidence.py | .py | """Coding verification evidence ledger.
This module records what the agent actually proved while working in a code
workspace. It is deliberately passive: it never decides to run a suite, never
blocks completion, and never upgrades targeted checks into "repo green".
"""
from __future__ import annotations
import json
... | 801 | 25,461 |
hermes-agent | agent/error_classifier.py | .py | """API error classification for smart failover and recovery.
Provides a structured taxonomy of API errors and a priority-ordered
classification pipeline that determines the correct recovery action
(retry, rotate credential, fallback to another provider, compress
context, or abort).
Replaces scattered inline string-ma... | 2,011 | 88,828 |
hermes-agent | agent/turn_finalizer.py | .py | """Post-loop turn finalization for ``run_conversation``.
Extracted from ``agent/conversation_loop.py`` as part of the god-file
decomposition campaign (``~/.hermes/plans/god-file-decomposition.md``, Phase 1
step 4 — the post-loop ``TurnFinalizer`` seam). ``run_conversation``'s tail
(everything after the main tool-calli... | 837 | 40,916 |
hermes-agent | agent/tool_executor.py | .py | """Tool-call execution — sequential and concurrent dispatch.
Both AIAgent methods (``_execute_tool_calls_sequential`` and
``_execute_tool_calls_concurrent``) live here as module-level
functions that take the parent ``AIAgent`` as their first argument.
``run_agent`` keeps thin wrappers so existing call sites work; tes... | 2,763 | 125,671 |
hermes-agent | agent/skill_utils.py | .py | """Lightweight skill metadata utilities shared by prompt_builder and skills_tool.
This module intentionally avoids importing the tool registry, CLI config, or any
heavy dependency chain. It is safe to import at module level without triggering
tool registration or provider resolution.
"""
import ast
import logging
im... | 958 | 36,703 |
hermes-agent | agent/agent_runtime_helpers.py | .py | """Assorted AIAgent runtime helpers — moved out of run_agent.py for clarity.
Each function takes the parent ``AIAgent`` as its first argument
(``agent``) except for the static helpers (``sanitize_tool_call_arguments``,
``drop_thinking_only_and_merge_users``) which are stateless. AIAgent
keeps thin forwarders for back... | 4,345 | 203,511 |
hermes-agent | agent/chat_completion_helpers.py | .py | """Helper functions for the chat-completions code path.
Extracted from :class:`AIAgent` for cleanliness — bodies of the
non-streaming API call, request kwargs builder, assistant-message
materializer, provider-fallback activator, max-iterations handler,
and per-turn resource cleanup.
Each function takes the parent ``A... | 5,340 | 259,273 |
hermes-agent | agent/transports/hermes_tools_mcp_server.py | .py | """Hermes-tools-as-MCP server for the codex_app_server runtime.
When the user runs `openai/*` turns through the codex app-server, codex
owns the loop and builds its own tool list. By default, that means
Hermes' richer tool surface — web search, browser automation,
delegate_task subagents, vision analysis, persistent m... | 290 | 11,104 |
hermes-agent | agent/transports/codex.py | .py | """OpenAI Responses API (Codex) transport.
Delegates to the existing adapter functions in agent/codex_responses_adapter.py.
This transport owns format conversion and normalization — NOT client lifecycle,
streaming, or the _run_codex_stream() call path.
"""
import hashlib
import json
import re
from typing import Any, ... | 832 | 39,274 |
hermes-agent | agent/transports/chat_completions.py | .py | """OpenAI Chat Completions transport.
Handles the default api_mode ('chat_completions') used by ~16 OpenAI-compatible
providers (OpenRouter, Nous, NVIDIA, Qwen, Ollama, DeepSeek, xAI, Kimi, etc.).
Messages and tools are already in OpenAI format — convert_messages and
convert_tools are near-identity. The complexity l... | 999 | 45,308 |
AutoGPT | autogpt_platform/backend/backend/copilot/graphiti/falkordb_driver.py | .py | import asyncio
import logging
import random
from collections.abc import Awaitable
from typing import Any, cast
from graphiti_core.driver.falkordb import STOPWORDS
from graphiti_core.driver.falkordb_driver import FalkorDriver
from graphiti_core.helpers import validate_group_ids
from graphiti_core.utils.datetime_utils i... | 195 | 9,001 |
AutoGPT | autogpt_platform/backend/backend/copilot/graphiti/ingest.py | .py | """Async episode ingestion with per-user serialization.
graphiti-core requires sequential ``add_episode()`` calls within the same
group_id. This module provides a per-user asyncio.Queue that serializes
ingestion while keeping it fire-and-forget from the caller's perspective.
"""
import asyncio
import logging
import ... | 619 | 25,191 |
AutoGPT | autogpt_platform/backend/backend/copilot/graphiti/client.py | .py | """Graphiti client management with per-group_id isolation and LRU caching."""
import asyncio
import logging
import re
import weakref
from cachetools import TTLCache
from .config import graphiti_config
logger = logging.getLogger(__name__)
_GROUP_ID_PATTERN = re.compile(r"^[a-zA-Z0-9_-]+$")
_MAX_GROUP_ID_LEN = 128
... | 318 | 11,757 |
AutoGPT | autogpt_platform/backend/backend/copilot/graphiti/falkordb_driver_test.py | .py | from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from . import falkordb_driver as fdb
from .falkordb_driver import AutoGPTFalkorDriver
class _FakeResult:
"""Minimal stand-in for a falkordb query result (header + rows)."""
def __init__(self, header, result_set):
self.header = head... | 299 | 11,420 |
transformers | setup.py | .py | # Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | 358 | 12,998 |
transformers | tests/test_tokenization_common.py | .py | # Copyright 2019 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 2,877 | 134,462 |
transformers | tests/generation/test_utils.py | .py | # Copyright 2020 The HuggingFace Team Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a clone of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | 5,642 | 282,912 |
transformers | tests/models/step3p7/test_processing_step3p7.py | .py | # Copyright 2026 The StepFun and HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | 106 | 4,684 |
transformers | tests/models/step3p7/test_modeling_step3p7.py | .py | # Copyright 2026 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 331 | 15,354 |
transformers | tests/models/step3p7/test_image_processing_step3p7.py | .py | # Copyright 2026 The StepFun and HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | 177 | 7,792 |
transformers | tests/models/whisper/test_modeling_whisper.py | .py | # Copyright 2022 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | 3,464 | 249,241 |
transformers | utils/check_repo.py | .py | # Copyright 2020 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | 1,543 | 72,204 |
transformers | utils/check_config_attributes.py | .py | # Copyright 2023 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | 459 | 19,740 |
transformers | src/transformers/modeling_layers.py | .py | # Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | 676 | 30,838 |
transformers | src/transformers/convert_slow_tokenizer.py | .py | # Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | 2,082 | 75,081 |
transformers | src/transformers/conversion_mapping.py | .py | # Copyright (C) 2025 the HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 1,949 | 103,985 |
transformers | src/transformers/generation/candidate_generator.py | .py | # Copyright 2023 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | 1,795 | 93,980 |
transformers | src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py | .py | # Copyright 2021 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | 869 | 42,682 |
transformers | src/transformers/models/clip/tokenization_clip.py | .py | # Copyright 2021 The Open AI Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required... | 143 | 5,200 |
transformers | src/transformers/models/roberta/tokenization_roberta.py | .py | # Copyright 2018 The Open AI Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required... | 179 | 7,340 |
transformers | src/transformers/models/mpnet/tokenization_mpnet.py | .py | # Copyright 2018 The HuggingFace Inc. team, Microsoft Corporation.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http... | 194 | 8,590 |
transformers | src/transformers/models/herbert/tokenization_herbert.py | .py | # Copyright 2020 The Google AI Language Team Authors, Allegro.pl, Facebook Inc. and the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/li... | 112 | 3,909 |
transformers | src/transformers/models/layoutxlm/tokenization_layoutxlm.py | .py | # Copyright 2021 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | 945 | 46,172 |
transformers | src/transformers/models/luke/tokenization_luke.py | .py | # Copyright Studio-Ouisa and The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | 1,665 | 82,069 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.