The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(plugins): honor portable per-server call deadlines
Tekniumfcc170b7983e
diff --git a/hermes_cli/agent_plugins.py b/hermes_cli/agent_plugins.pyindex 64269e56413..6cdc3a372bd 100644--- a/hermes_cli/agent_plugins.py+++ b/hermes_cli/agent_plugins.py@@ -6,6 +6,7 @@ import ipaddressimport jsonimport osimport re+import threadingfrom dataclasses import dataclassfrom pathlib import Pathfrom typing import Any, Dict, Mapping, Tuple@@ -104,11 +105,11 @@ def _server_declarations(raise AgentPluginError(f"server declaration '{name}' must be an object")if "liveness" in raw and "app" not in raw and "requires" not in raw:raise AgentPluginError(f"server declaration '{name}' has liveness without app or requires")- unknown = set(raw) - {"app", "requires", "liveness", "trust"}+ unknown = set(raw) - {"app", "requires", "liveness", "trust", "timeout"}if unknown:raise AgentPluginError(f"server declaration '{name}' has unknown keys {sorted(unknown)}")- if set(raw) == {"trust"}:- continue # trust only (see _server_trust): no application to declare+ if raw and set(raw) <= {"trust", "timeout"}:+ continue # transport settings alone do not declare an applicationtry:declaration = parse_declaration(name, raw.get("app"), raw.get("requires"),@@ -147,6 +148,20 @@ def _server_trust(manifest: Mapping[str, Any], mcp_servers: Mapping[str, dict[streturn trust+def _server_timeouts(manifest: Mapping[str, Any], mcp_servers: Mapping[str, dict[str, Any]]) -> dict[str, float]:+ """Translate optional Hermes call deadlines without changing other servers' defaults."""+ raw_servers = manifest.get("extensions", {}).get(_HERMES_EXTENSION, {}).get("servers", {})+ timeouts: dict[str, float] = {}+ for name, raw in (raw_servers.items() if isinstance(raw_servers, dict) else ()):+ if not isinstance(raw, dict) or "timeout" not in raw or name not in mcp_servers:+ continue+ value = raw["timeout"]+ if isinstance(value, bool) or not isinstance(value, (int, float)) or not 0 < value <= threading.TIMEOUT_MAX:+ raise AgentPluginError(f"server declaration '{name}' timeout must be positive seconds within the platform wait limit")+ timeouts[name] = float(value)+ return timeouts++def _inside(path: Path, root: Path) -> bool:try:return path.resolve(strict=False).is_relative_to(root.resolve(strict=True))@@ -451,6 +466,8 @@ def load_agent_plugin(plugin_root: Path, data_root: Path) -> AgentPluginPackage:mcp_servers = _discover_mcp(root, resolved_data, diagnostics)for name, tier in _server_trust(manifest, mcp_servers).items():mcp_servers[name] = {**mcp_servers[name], "trust": tier}+ for name, timeout in _server_timeouts(manifest, mcp_servers).items():+ mcp_servers[name] = {**mcp_servers[name], "timeout": timeout}return AgentPluginPackage(name=manifest["name"], version=manifest.get("version", ""),description=manifest.get("description", ""), root=root, data_root=resolved_data,diff --git a/tests/hermes_cli/test_agent_plugins.py b/tests/hermes_cli/test_agent_plugins.pyindex 6152e91862f..3e4d92d79fb 100644--- a/tests/hermes_cli/test_agent_plugins.py+++ b/tests/hermes_cli/test_agent_plugins.py@@ -172,6 +172,36 @@ def test_unknown_trust_value_disables_package(tmp_path: Path) -> None:load_agent_plugin(tmp_path, tmp_path / "data")[email protected]("transport", ["stdio", "streamable-http"])+def test_server_timeout_is_opt_in_and_scoped_to_its_server(tmp_path: Path, transport: str) -> None:+ from tools.mcp_tool_common import _resolve_tool_timeout++ server = {"type": "stdio", "command": "python"} if transport == "stdio" else {+ "type": "streamable-http", "url": "https://mcp.example.com/mcp"}+ _write_json(tmp_path / "mcp.json", {+ "$schema": MCP_SCHEMA_V1, "mcpServers": {"slow": server, "ordinary": server}})+ for settings in ({}, {"timeout": 1000, "trust": "untrusted"}, {}):+ _write_json(tmp_path / "plugin.json", _manifest(extensions={+ "com.nousresearch.hermes": {"servers": {"slow": settings}}} if settings else {}))+ package = load_agent_plugin(tmp_path, tmp_path / "data")+ assert "timeout" not in package.mcp_servers["ordinary"]+ assert "slow" not in package.server_declarations+ if settings:+ assert _resolve_tool_timeout(package.mcp_servers["slow"]) == 1000+ assert package.mcp_servers["slow"]["trust"] == "untrusted"+ else:+ assert "timeout" not in package.mcp_servers["slow"]++[email protected]("timeout", [True, None, "1000", 0, -1, float("inf"), float("nan")])+def test_server_timeout_rejects_invalid_deadlines(tmp_path: Path, timeout: object) -> None:+ _remote_package(tmp_path)+ _write_json(tmp_path / "plugin.json", _manifest(extensions={+ "com.nousresearch.hermes": {"servers": {"trade": {"timeout": timeout}}}}))+ with pytest.raises(AgentPluginError, match="timeout must be"):+ load_agent_plugin(tmp_path, tmp_path / "data")++def test_unknown_fields_and_non_object_extensions_are_nonfatal(tmp_path: Path) -> None:_write_json(tmp_path / "plugin.json",diff --git a/website/docs/developer-guide/plugins/index.md b/website/docs/developer-guide/plugins/index.mdindex e21dc01aae7..7a77bf37c9b 100644--- a/website/docs/developer-guide/plugins/index.md+++ b/website/docs/developer-guide/plugins/index.md@@ -141,6 +141,27 @@ the package's entry, including its trust. Other harnesses ignore this extension.`trust` can sit beside `app`, `requires` and `liveness` in the same serverentry (see [Application declarations](./application-declarations.md)).+A long-running server can also declare a Hermes-specific tool-call `timeout`+(in seconds) in `plugin.json`, without changing other servers' defaults:++```json+{+ "extensions": {+ "com.nousresearch.hermes": {+ "servers": { "analysis": { "timeout": 1000 } }+ }+ }+}+```++The value must be a positive finite number within the platform's thread-wait+limit. It maps to the native per-server `timeout`; omission preserves the+existing `timeouts.mcp.tool_call` fallback. A same-name native `mcp_servers`+entry still replaces the entire package entry, including its timeout. This+extends the wait budget, not the cancellation or permission policy. Configure+any server-internal analysis deadline separately and leave time for its result+to reach the client. Other harnesses ignore this extension.+The [rendered specification](https://agent-plugins.org/specification) currentlylabels v1.0.0 a Working Draft, while the[versioned specification repository](https://github.com/agentplugins/agent-plugins-spec/blob/main/spec/1.0.0.md)