Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions agent/chat_completion_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
_repair_tool_call_arguments,
)
from tools.terminal_tool import is_persistent_env
from utils import base_url_host_matches, base_url_hostname
from utils import base_url_host_matches, base_url_hostname, env_int

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -2044,7 +2044,7 @@ def _call_anthropic():
def _call():
import httpx as _httpx

_max_stream_retries = int(os.getenv("HERMES_STREAM_RETRIES", 2))
_max_stream_retries = env_int("HERMES_STREAM_RETRIES", 2)

try:
for _stream_attempt in range(_max_stream_retries + 1):
Expand Down
4 changes: 3 additions & 1 deletion hermes_cli/kanban_specify.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@

from hermes_cli import kanban_db as kb

from utils import env_int

HERMES_KANBAN_SPECIFY_MAX_TOKENS = max(
1500,
int(os.getenv("HERMES_KANBAN_SPECIFY_MAX_TOKENS", "6000")),
env_int("HERMES_KANBAN_SPECIFY_MAX_TOKENS", 6000),
)

logger = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions hermes_cli/runtime_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)
from hermes_cli.config import get_compatible_custom_providers, load_config
from hermes_constants import OPENROUTER_BASE_URL
from utils import base_url_host_matches, base_url_hostname
from utils import base_url_host_matches, base_url_hostname, env_int


def _normalize_custom_provider_name(value: str) -> str:
Expand Down Expand Up @@ -1144,7 +1144,7 @@ def _resolve_explicit_runtime(
str(state.get("agent_key") or "").strip()
if _agent_key_is_usable(
state,
max(60, int(os.getenv("HERMES_NOUS_MIN_KEY_TTL_SECONDS", "1800"))),
max(60, env_int("HERMES_NOUS_MIN_KEY_TTL_SECONDS", 1800)),
)
else ""
)
Expand Down Expand Up @@ -1343,7 +1343,7 @@ def resolve_runtime_provider(
# expired, clear pool_api_key so we fall through to
# resolve_nous_runtime_credentials() which handles refresh.
if provider == "nous" and entry is not None and pool_api_key:
min_ttl = max(60, int(os.getenv("HERMES_NOUS_MIN_KEY_TTL_SECONDS", "1800")))
min_ttl = max(60, env_int("HERMES_NOUS_MIN_KEY_TTL_SECONDS", 1800))
nous_state = {
"agent_key": getattr(entry, "agent_key", None),
"agent_key_expires_at": getattr(entry, "agent_key_expires_at", None),
Expand Down
5 changes: 4 additions & 1 deletion plugins/browser/firecrawl/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def _headers(self) -> Dict[str, str]:
}

def create_session(self, task_id: str) -> Dict[str, object]:
ttl = int(os.environ.get("FIRECRAWL_BROWSER_TTL", "300"))
try:
ttl = int(os.environ.get("FIRECRAWL_BROWSER_TTL", "300"))
except (ValueError, TypeError):
ttl = 300

body: Dict[str, object] = {"ttl": ttl}

Expand Down
10 changes: 8 additions & 2 deletions plugins/platforms/google_chat/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,14 @@ def __init__(self, config: PlatformConfig):
# they don't sit in the chat forever as "Hermes is thinking…".
self._orphan_typing_messages: Dict[str, List[str]] = {}
# FlowControl knobs (env-configurable).
self._max_messages = int(os.getenv("GOOGLE_CHAT_MAX_MESSAGES", "1"))
self._max_bytes = int(os.getenv("GOOGLE_CHAT_MAX_BYTES", str(16 * 1024 * 1024)))
try:
self._max_messages = int(os.getenv("GOOGLE_CHAT_MAX_MESSAGES", "1"))
except (ValueError, TypeError):
self._max_messages = 1
try:
self._max_bytes = int(os.getenv("GOOGLE_CHAT_MAX_BYTES", str(16 * 1024 * 1024)))
except (ValueError, TypeError):
self._max_bytes = 16 * 1024 * 1024

# ------------------------------------------------------------------
# Configuration loading and validation
Expand Down
5 changes: 4 additions & 1 deletion plugins/platforms/irc/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ def __init__(self, config, **kwargs):

# Connection settings (env vars override config.yaml)
self.server = os.getenv("IRC_SERVER") or extra.get("server", "")
self.port = int(os.getenv("IRC_PORT") or extra.get("port", 6697))
try:
self.port = int(os.getenv("IRC_PORT") or extra.get("port", 6697))
except (ValueError, TypeError):
self.port = 6697
self.nickname = os.getenv("IRC_NICKNAME") or extra.get("nickname", "hermes-bot")
self.channel = os.getenv("IRC_CHANNEL") or extra.get("channel", "")
self.use_tls = (
Expand Down
4 changes: 2 additions & 2 deletions tools/browser_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
from pathlib import Path
from agent.auxiliary_client import call_llm
from hermes_constants import get_hermes_home
from utils import is_truthy_value
from utils import env_int, is_truthy_value
from hermes_cli.config import cfg_get

try:
Expand Down Expand Up @@ -1178,7 +1178,7 @@ def _socket_safe_tmpdir() -> str:
# Session inactivity timeout (seconds) - cleanup if no activity for this long
# Default: 5 minutes. Needs headroom for LLM reasoning between browser commands,
# especially when subagents are doing multi-step browser tasks.
BROWSER_SESSION_INACTIVITY_TIMEOUT = int(os.environ.get("BROWSER_INACTIVITY_TIMEOUT", "300"))
BROWSER_SESSION_INACTIVITY_TIMEOUT = env_int("BROWSER_INACTIVITY_TIMEOUT", 300)

# Track last activity time per session
_session_last_activity: Dict[str, float] = {}
Expand Down
4 changes: 3 additions & 1 deletion tools/checkpoint_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
from hermes_constants import get_hermes_home
from typing import Dict, List, Optional, Set, Tuple

from utils import env_int

logger = logging.getLogger(__name__)

# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -139,7 +141,7 @@
]

# Git subprocess timeout (seconds).
_GIT_TIMEOUT: int = max(10, min(60, int(os.getenv("HERMES_CHECKPOINT_TIMEOUT", "30"))))
_GIT_TIMEOUT: int = max(10, min(60, env_int("HERMES_CHECKPOINT_TIMEOUT", 30)))

# Max files to snapshot — skip huge directories to avoid slowdowns.
_MAX_FILES = 50_000
Expand Down
Loading