The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Merge remote-tracking branch 'origin/main' into ethie/pm-clean
ethernet0f65d698d0cb
diff --cc agent/anthropic_adapter.pyindex d875f46cb7b,704ff48ec77..252338da41e--- a/agent/anthropic_adapter.py+++ b/agent/anthropic_adapter.py@@@ -27,8 -25,9 +26,9 @@@ from agent.anthropic_endpoints importfrom agent.anthropic_message_convert import (convert_messages_to_anthropic, convert_tools_to_anthropic, normalize_model_name,)+ from agent.errors import EmptyStreamError-from hermes_cli import __version__ as _HERMES_VERSION+from hermes_cli.version_info import get_version_info# ``import anthropic`` is deliberately NOT at module top: the SDK costs ~220 ms of imports anddiff --cc agent/bedrock_adapter.pyindex dbc8046d7a0,912bca85675..fb8c5e59f49--- a/agent/bedrock_adapter.py+++ b/agent/bedrock_adapter.py@@@ -21,8 -20,23 +21,10 @@@ from urllib.parse import urlparsimport httpx+ from agent.errors import EmptyStreamError+logger = logging.getLogger(__name__)-# boto3 is not in the [all] extras; lazy_deps installs it on demand.-try:- # --------------------------------------------------------------------------- Ensure boto3/botocore are- # installed before any code in this module runs. Upstream removed boto3 from [all] extras (PRs #24220,- # #24515); lazy_deps handles on-demand installation so the Bedrock provider still works in the EKS- # deployment without baking boto3 into the base image.- # ---------------------------------------------------------------------------- from tools.lazy_deps import ensure- ensure("provider.bedrock", prompt=False)-except Exception as exc: # downstream imports surface the real error- logger.warning("boto3 lazy install did not complete: %s", exc)--_bedrock_runtime_client_cache: Dict[str, Any] = {}_bedrock_control_client_cache: Dict[str, Any] = {}# Routed multiplex profiles: one client per (profile home, region). boto3 freezes the credentialdiff --cc hermes_logging.pyindex 47611b6b062,78db2d9ed4a..cde747b6fc2--- a/hermes_logging.py+++ b/hermes_logging.py@@@ -299,9 -253,15 +336,16 @@@ def setup_logging``gateway.log`` and ``mode="gui"`` adds ``gui.log``."""global _logging_initialized+ global _fallback_warnedhome = hermes_home or get_hermes_home()log_dir = mkdir_under_hermes_home(home / "logs")++ # Stdout is block-buffered when piped (no TTY); line-buffer it so a+ # headless supervisor's log stream tracks the agent loop incrementally+ # (#92281). Runs before the initialized check so every entry mode that+ # reaches this function gets it; a no-op once this stdout is line-buffered.+ _line_buffer_piped_stdout()+# A second Hermes home in a process that already logs for another one — a dashboard or# ``hermes serve`` backend building agents for several profiles, a multiplexed gateway —# gets routed by record home. Stacking another file handler here would hand it EVERYdiff --cc plugins/model-providers/kimi-coding/__init__.pyindex 3a729578b11,3bf88f080cd..440c0df5f86--- a/plugins/model-providers/kimi-coding/__init__.py+++ b/plugins/model-providers/kimi-coding/__init__.py@@@ -12,7 -12,11 +12,11 @@@ from providers.base import OMIT_TEMPERA_HEADERS = {"HTTP-Referer": "https://hermes-agent.nousresearch.com","X-Title": "Hermes Agent",- "User-Agent": f"HermesAgent/{_HERMES_VERSION}",+ "User-Agent": f"HermesAgent/{get_version_info().base_version}",+ # Exclude brotli: httpx's brotlicffi backend has a streaming decode bug on+ # Moonshot's content-encoding: br SSE responses (#28043, #48428, #59556).+ # gzip sidesteps it while still compressing the transfer.+ "Accept-Encoding": "gzip",}diff --cc tests/test_hermes_logging.pyindex cbb42ebf2b7,a300c77d79f..ee38dce6949--- a/tests/test_hermes_logging.py+++ b/tests/test_hermes_logging.py@@@ -781,7 -766,41 +781,43 @@@ class TestSafeStderrassert isinstance(result, io.TextIOWrapper)assert result.encoding == "utf-8"assert result.errors == "replace"+ handler = logging.StreamHandler(result)+ handler.handle(logging.LogRecord("unicode", logging.INFO, "", 0, "Session — 日本", (), None))+ handler.flush()+ assert fake.buffer.getvalue() == "Session — 日本\n".encode("utf-8")++++ class TestLineBufferPipedStdout:+ """A piped stdout is line-buffered so headless log streams track the+ agent loop incrementally (#92281); a TTY stdout is left alone."""++ def _fake_stdout(self, isatty: bool):+ from unittest.mock import MagicMock++ stream = MagicMock()+ stream.isatty.return_value = isatty+ stream.reconfigure = MagicMock()+ return stream++ def test_tty_none_or_reconfigure_less_stdout_left_alone(self, monkeypatch):+ from types import SimpleNamespace++ tty = self._fake_stdout(isatty=True)+ monkeypatch.setattr(sys, "stdout", tty)+ hermes_logging._line_buffer_piped_stdout()+ tty.reconfigure.assert_not_called()++ monkeypatch.setattr(sys, "stdout", None)+ hermes_logging._line_buffer_piped_stdout() # must not raise+ # A stream without reconfigure() (e.g. a print-redirect shim).+ monkeypatch.setattr(sys, "stdout", SimpleNamespace(isatty=lambda: False))+ hermes_logging._line_buffer_piped_stdout()++ def test_setup_logging_applies_it_to_piped_stdout(self, tmp_path, monkeypatch):+ stream = self._fake_stdout(isatty=False)+ monkeypatch.setattr(sys, "stdout", stream)+ hermes_logging.setup_logging(hermes_home=tmp_path, force=True)+ # setup_logging runs per AIAgent build: a second call must not re-flush/reconfigure.+ hermes_logging.setup_logging(hermes_home=tmp_path, force=True)+ stream.reconfigure.assert_called_once_with(line_buffering=True)--