Skip to content

The agent that grows with you

docs(plugins): conform classify_api_error dispatch wording to the mutating-hook taxonomy

webdevtodayjasona2a99418ee69
diff --git a/hermes_cli/plugins.py b/hermes_cli/plugins.py
index 6ee2ddd92e2..1ae219e7762 100644
--- a/hermes_cli/plugins.py
+++ b/hermes_cli/plugins.py
@@ -195,9 +195,14 @@ VALID_HOOKS: Set[str] = {
# "retryable": bool, "should_compress": bool,
# "should_rotate_credential": bool, "should_fallback": bool,
# "message": str, "error_context": dict} # all optional
- # First valid result (registration order) wins. Invalid dicts and
- # unknown reasons are skipped; exceptions are isolated — a broken
- # plugin can never break error classification.
+ # Dispatch is run-all-then-pick-first: every registered callback runs
+ # with its failures isolated (an early answer never stops later
+ # callbacks), then the first valid result in registration order wins —
+ # on conflict the first-registered plugin is the tie-break. Invalid
+ # dicts and unknown reasons are skipped; a broken plugin can never
+ # break error classification. Cold path: fires only on API failure.
+ # Privacy: error_message/error_body may carry an unredacted provider
+ # error dump.
"classify_api_error",
"on_session_start",
"on_session_end",
@@ -5813,13 +5818,19 @@ def get_plugin_error_classification(
its built-in pipeline, so a provider plugin can both add classifications
the core patterns miss and correct ones they get wrong for its provider.
- A callback returns ``None`` to pass, or a dict with a required
+ A callback returns ``None`` to decline, or a dict with a required
``"reason"`` (a :class:`agent.error_classifier.FailoverReason` member or
- its string name) plus optional recovery-hint overrides. The first result
- carrying a valid reason wins — mirroring
+ its string name) plus optional recovery-hint overrides. Dispatch is
+ run-all-then-pick-first: ``invoke_hook`` runs every registered callback
+ with failures isolated, then the first result carrying a valid reason
+ wins in registration order — mirroring
:func:`get_pre_tool_call_block_message`, invalid or irrelevant returns
are silently ignored so a misbehaving plugin degrades to a no-op.
+ Privacy: ``error_message`` and ``error_body`` may carry an unredacted
+ provider error dump; callbacks must not log or forward them without
+ redaction.
+
Returns a sanitized dict (``reason`` coerced to ``FailoverReason``, hint
fields coerced to ``bool``) or ``None`` when no plugin claimed the error.
"""
diff --git a/website/docs/user-guide/features/hooks.md b/website/docs/user-guide/features/hooks.md
index c72a241dfe6..ff3a67373c7 100644
--- a/website/docs/user-guide/features/hooks.md
+++ b/website/docs/user-guide/features/hooks.md
@@ -849,7 +849,7 @@ For standing guidance that should shape the built-in missing-evidence nudge, use
### `classify_api_error`
-Fires **once per failed API call**, at the top of `agent/error_classifier.classify_api_error()` — BEFORE the built-in classification pipeline. Provider plugins use it to own their provider's error quirks (a vendor-specific 404 that should fast-fallback, a misleading status code) without core patches.
+Fires **once per failed API call**, at the top of `agent/error_classifier.classify_api_error()` — BEFORE the built-in classification pipeline. Cold path: it never fires on a successful call. Provider plugins use it to own their provider's error quirks (a vendor-specific 404 that should fast-fallback, a misleading status code) without core patches.
This hook is **behavior-changing**: the returned classification drives retry, compression, credential-rotation, and fallback routing for the failed call.
@@ -889,7 +889,9 @@ return {
}
```
-Return `None` (or nothing) to pass the error to the built-in pipeline. The first valid result in registration order wins; invalid dicts and unknown reasons are skipped; exceptions are isolated so a broken plugin can never break error classification.
+Return `None` (or nothing) to decline and defer to the built-in pipeline. Dispatch is **run-all-then-pick-first**: every registered callback runs on each failed call (an earlier answer never stops later callbacks), each callback's failure is isolated, and the first valid result **in registration order** wins — if two plugins can both answer, the first-registered one is the tie-break. Invalid dicts and unknown reasons are skipped, so a broken plugin can never break error classification.
+
+**Privacy:** `error_message` and `error_body` may carry an unredacted provider error dump. Do not log or forward them from a callback without redaction.
**Python plugins only.** Shell hooks cannot register for this event: the shell response parser has no channel for the classification directive, so a shell registration is refused at config parse with a warning rather than being silently ignored.