Skip to content

The agent that grows with you

feat(metrics): count connector file-input refusals by error class

Siddharth Balyan56b10be73325
diff --git a/hermes_cli/observability/shared_metrics_contract.py b/hermes_cli/observability/shared_metrics_contract.py
index e82b4e13303..67dc047cb72 100644
--- a/hermes_cli/observability/shared_metrics_contract.py
+++ b/hermes_cli/observability/shared_metrics_contract.py
@@ -1828,6 +1828,9 @@ _CONNECTOR_CODE_CLASSES = {
"TOOL_NOT_ALLOWED": "not_allowed",
**dict.fromkeys(("ALIAS_REQUIRED", "ALIAS_UNKNOWN"), "alias"),
"INVALID_ARGUMENTS": "invalid_arguments",
+ # Agent-side file input refusals (``tools.connectors.gateway.wire.FILE_ERROR_FAMILIES``).
+ "FILE_NOT_ALLOWED": "not_allowed",
+ **dict.fromkeys(("FILE_NOT_FOUND", "FILE_TOO_LARGE"), "invalid_arguments"),
}
_CONNECTOR_FAMILY_CLASSES = {"backend": "connector_backend"}
diff --git a/tests/hermes_cli/test_shared_metrics_connectors.py b/tests/hermes_cli/test_shared_metrics_connectors.py
index 319e5d6eb70..13a70d35467 100644
--- a/tests/hermes_cli/test_shared_metrics_connectors.py
+++ b/tests/hermes_cli/test_shared_metrics_connectors.py
@@ -39,6 +39,9 @@ _BASE = {"session_id": "s1", "task_id": "t1", "turn_id": "turn-1", "api_request_
("SOMETHING_NEW", "backend", "connector_backend"), # an unlisted code falls back to its family
("SOMETHING_NEW", "product", "tool_error"),
("TOOL_NOT_FOUND", "product", "tool_error"),
+ ("FILE_NOT_ALLOWED", "product", "not_allowed"),
+ ("FILE_TOO_LARGE", "product", "invalid_arguments"),
+ ("FILE_UPLOAD_FAILED", "backend", "connector_backend"),
])
def test_a_failed_connector_entry_is_classed_by_its_gateway_code(code, family, expected):
result = json.dumps({"error": {"code": code, "family": family, "message": "private text"}})
@@ -48,11 +51,12 @@ def test_a_failed_connector_entry_is_classed_by_its_gateway_code(code, family, e
assert expected in contract.TOOL_ERROR_CLASSES
-def test_every_classed_code_is_a_gateway_execute_code():
- from tools.connectors.gateway.wire import EXECUTE_ERROR_CODES
+def test_every_classed_code_is_a_known_product_code():
+ from tools.connectors.gateway.wire import EXECUTE_ERROR_CODES, FILE_ERROR_FAMILIES
- assert set(contract._CONNECTOR_CODE_CLASSES) <= set(EXECUTE_ERROR_CODES)
- assert all(EXECUTE_ERROR_CODES[code][0] == "product" for code in contract._CONNECTOR_CODE_CLASSES)
+ families = {**{code: family for code, (family, _status) in EXECUTE_ERROR_CODES.items()}, **FILE_ERROR_FAMILIES}
+ assert set(contract._CONNECTOR_CODE_CLASSES) <= set(families)
+ assert all(families[code] == "product" for code in contract._CONNECTOR_CODE_CLASSES)
def test_connector_and_bridge_calls_are_named_without_a_slug():
diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.md
index 70f4c959614..3af1e82395a 100644
--- a/website/docs/developer-guide/relay-shared-metrics.md
+++ b/website/docs/developer-guide/relay-shared-metrics.md
@@ -393,7 +393,9 @@ gateway's error code in its result: `connection_required` (connection required
or expired), `not_allowed`, `alias` (alias required or unknown),
`invalid_arguments`, and `connector_backend` for every backend-family code
(vendor error, rate limit, timeout, policy or gateway failure); other codes keep
-`tool_error`. Hermes does not infer retries from repeated tool names or
+`tool_error`. Hermes's own file-input refusals count the same way: a refused
+path is `not_allowed`, a missing or oversized file is `invalid_arguments`, and a
+failed upload is `connector_backend`. Hermes does not infer retries from repeated tool names or
adjacent calls; when the
hook does not provide an explicit retry relationship, the retry bucket is
`unknown`. Approval decisions are emitted as `hermes.tool_approval` marks and