The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(telemetry): compression verdict reads the stored class; consent offer names the reason
Tekniumc0bd379b38a3
diff --git a/hermes_cli/observability/shared_metrics_consent.py b/hermes_cli/observability/shared_metrics_consent.pyindex c3592a14928..ab62b0ca8f4 100644--- a/hermes_cli/observability/shared_metrics_consent.py+++ b/hermes_cli/observability/shared_metrics_consent.py@@ -28,7 +28,8 @@ OFFER_CHOICES = (_NO_THANKS = len(OFFER_CHOICES) - 1DOCS_URL = "https://hermes-agent.nousresearch.com/docs/developer-guide/relay-shared-metrics"_OFFER_DESCRIPTION = "\n".join((- "Shared metrics are bounded counters: activity, outcomes, error classes, model routes,",+ "Shared metrics are bounded counters: activity, outcomes, error classes (with a",+ "fixed-list reason when a memory write or compression fails), model routes,","token totals, feature use and coarse machine facts. Never prompts, files, paths,","setting values or error text. Collection stays on this machine; sending to Nous is","a separate choice, and data from before you opt in is never sent.",diff --git a/hermes_cli/observability/shared_metrics_events.py b/hermes_cli/observability/shared_metrics_events.pyindex 77741ca9f82..aeecbfd98df 100644--- a/hermes_cli/observability/shared_metrics_events.py+++ b/hermes_cli/observability/shared_metrics_events.py@@ -83,13 +83,15 @@ def finish_compression_attempt(pending, _compression_attempt.pending = getattr(_compression_attempt, "pending", None), Noneif not pending:return+ # Classify the stored value, so the outcome and the recorded reason always agree.+ reason = fields_.compression_failure_class("failed", failure_class)outcome = ("success" if commit_status == "committed"- else "skipped" if failure_class in _SKIPPED_COMPRESSION_CLASSES else "failed"+ else "skipped" if reason in _SKIPPED_COMPRESSION_CLASSES else "failed")record_compression(trigger=pending[0], outcome=outcome, tokens_before=pending[1], context_length=context_length,- failure_class=failure_class,+ failure_class=reason,)if outcome == "success" and agent is not None:from .shared_metrics_efficiency import record_cache_breakdiff --git a/hermes_cli/observability/shared_metrics_fields.py b/hermes_cli/observability/shared_metrics_fields.pyindex 6f196bb6ca5..5b15dc1ab9d 100644--- a/hermes_cli/observability/shared_metrics_fields.py+++ b/hermes_cli/observability/shared_metrics_fields.py@@ -132,7 +132,7 @@ def compression_failure_class(outcome: str, failure_class: Any) -> str:``exception:<Type>`` / ``rollback:<Type>`` keep only the prefix (the type name may be a plugin's)."""if outcome == "success":return "none"- value = _norm(failure_class).split(":", 1)[0]+ value = _norm(failure_class if isinstance(failure_class, str) else None).split(":", 1)[0]if not value:return "unknown"return value if value in contract.COMPRESSION_FAILURE_CLASSES - {"none", "unknown"} else "other"diff --git a/hermes_cli/setup.py b/hermes_cli/setup.pyindex 4fd94261100..dff486f9d55 100644--- a/hermes_cli/setup.py+++ b/hermes_cli/setup.py@@ -526,9 +526,10 @@ def setup_telemetry(config: dict):"""Configure the local shared-metrics subscriber and optional sending."""print_header("Shared Metrics")_info("Shared metrics contain only bounded counters: activity, session length,",- "outcomes, error classes (with a fixed-list reason when a memory write or context",- "compression is refused, fails or is skipped), model routes and token totals,",- "built-in tool, command and catalog names, bucketed setup counts, update results and timing, crashes,",+ "outcomes, error classes (with a fixed-list reason when a memory write or",+ "context compression is refused, fails or is skipped), model routes and",+ "token totals, built-in tool, command and catalog names, bucketed setup",+ "counts, update results and timing, crashes,","startup and reply speed, messaging-platform health, how Hermes gets used","(agent accuracy and efficiency, active time per surface, which features and","settings are used or switched off, provider setup outcomes), and coarse",diff --git a/tests/hermes_cli/test_relay_shared_metrics.py b/tests/hermes_cli/test_relay_shared_metrics.pyindex 0cdbebf0066..ce4d605df29 100644--- a/tests/hermes_cli/test_relay_shared_metrics.py+++ b/tests/hermes_cli/test_relay_shared_metrics.py@@ -1136,7 +1136,7 @@ def test_v2_task_and_tool_rows_recorded_before_an_upgrade_still_package(tmp_path}-def test_failure_class_rows_validate_and_v3_rows_still_drain(tmp_path):+def test_failure_class_rows_validate_and_v3_rows_still_drain(tmp_path, monkeypatch):"""v4 adds failure_class to compression and memory rows: a free-form compressor class collapses toa closed name before it is stored, and rows counted before the upgrade (v3 shape) still package."""from hermes_cli.observability.shared_metrics_fields import compression_fields@@ -1158,6 +1158,14 @@ def test_failure_class_rows_validate_and_v3_rows_still_drain(tmp_path):"exception:AcmeCorpSecretError": "exception", "rollback:KeyboardInterrupt": "rollback","acme_engine_reason": "other", None: "unknown",}+ # The skip/fail verdict reads the same normalized class that is stored, so they cannot disagree.+ from hermes_cli.observability import shared_metrics_events as events++ recorded = []+ monkeypatch.setattr(events, "record_compression", lambda **kw: recorded.append(kw))+ events.begin_compression_attempt("auto", 1)+ events.finish_compression_attempt("aborted", " Lock_Contended ", 10)+ assert [(kw["outcome"], kw["failure_class"]) for kw in recorded] == [("skipped", "lock_contended")][package_path] = store.create_and_export_package()package = json.loads(package_path.read_text(encoding="utf-8"))diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.mdindex e99ec3225b6..c9372ecae73 100644--- a/website/docs/developer-guide/relay-shared-metrics.md+++ b/website/docs/developer-guide/relay-shared-metrics.md@@ -344,7 +344,7 @@ itself ships.| `hermes.fallback.count` | from/to provider, error class | How often fallback providers rescue a turn, and from what. || `hermes.slash_command.count` | command, surface | Which built-in commands are used (`/retry`, `/undo`, `/new` are friction signals). Skill and plugin commands report `skill`/`plugin`. || `hermes.extension.install.count` | kind, source, name, outcome | Which catalog skills, MCP servers and plugins get installed. `name` is a bundled/optional skill, `optional-mcps/` or `plugin-catalog/` entry, otherwise `custom`. |-| `hermes.memory.op.count` | op (`add`/`replace`/`remove`/`read`/`search`/`other`), provider (`builtin`, a bundled memory plugin, else `plugin`), origin (`foreground`/`background_review`), outcome (`success`/`failed`/`rejected`), failure class | Is the learning loop writing memory, who asks for it (the user's turn or the background review), and how often writes are refused or fail, and why. Since package schema v4 `failure_class` names the reason from a closed list mapped from each refusal/failure return of the built-in store: `no_match` (old_text matched no entry), `ambiguous` (it matched several), `over_budget` (the write would pass the char limit), `would_empty` (a batch would remove the last entry), `drift` (the file holds text the store cannot round-trip), `read_failed` (the file exists but cannot be read), `retry_cap` (the per-turn retry budget is spent), `scan_blocked` (the content matched a threat pattern), `missing_content`, `missing_old_text`, `invalid_args`, `stale_entry` (a staged write's entry changed), `disabled` (that target is off in config), `staged` (held for the user's approval), `gate_refused` (the write-approval gate blocked it); `provider_error` / `exception` for a plugin provider's tool that returned an error or raised; `none` on success; `other`/`unknown` otherwise. Never the memory text, the old_text or the error message. |+| `hermes.memory.op.count` | op (`add`/`replace`/`remove`/`read`/`search`/`other`), provider (`builtin`, a bundled memory plugin, else `plugin`), origin (`foreground`/`background_review`), outcome (`success`/`failed`/`rejected`), failure class | Is the learning loop writing memory, who asks for it (the user's turn or the background review), and how often writes are refused or fail, and why. Since package schema v4 `failure_class` names the reason from a closed list mapped from each refusal/failure return of the built-in store: `no_match` (old_text matched no entry), `ambiguous` (it matched several), `over_budget` (the write would pass the char limit), `would_empty` (a batch would remove the last entry), `drift` (the file holds text the store cannot round-trip), `read_failed` (the file exists but cannot be read), `retry_cap` (the per-turn retry budget is spent), `scan_blocked` (the content matched a threat pattern), `missing_content`, `missing_old_text`, `invalid_args`, `stale_entry` (a staged write's entry changed), `disabled` (that target is off in config), `staged` (held for the user's approval), `gate_refused` (the write-approval gate blocked it); `provider_error` / `exception` for a plugin provider's tool that returned an error or raised; `none` on success; `other`/`unknown` otherwise. A batch applies all or none, so every op row of a refused batch carries the class of the op that stopped it. Never the memory text, the old_text or the error message. || `hermes.curator.run.count` | trigger (`scheduled`/`manual`), outcome (`success`/`failed`/`skipped`), archived/merged/patched/created buckets | Does the skill curator run, and does it actually consolidate anything. Dry runs report `skipped`; a scheduled check that finds another process already running the pass records nothing. Never skill names. || `hermes.delegation.run.count` | subagent-count bucket, depth (`1`–`3`, `gte_4`), mode (`foreground`/`background`), outcome (`success`/`partial`/`failed`/`cancelled`) | How wide and deep delegate_task fan-outs go and how often every child finishes. One row per call, however many completion units it splits into. || `hermes.execution_backend.count` | kind (`terminal`/`browser`/`code`), backend, outcome, error class | Which sandboxes carry real work and how reliable each is. Terminal backends are the `terminal.backend` values (else `other`); browser backends are `local`, `lightpanda`, `cdp`, `camofox`, `extension` or a bundled cloud provider (else `other`); execute_code is `local` or `remote`. A command's own nonzero exit is still a backend success, but a foreground command that hits its timeout is `failed`/`timeout`; terminal and execute_code calls a guard refuses before they reach the backend, Hermes' own listings for TUI/Desktop path completion, and calls made by the background review and curator forks are not counted. |