Skip to content

[Bug]: Provider plugins cannot return derived pool credentials without overwriting the persisted grant #155441

Description

@paulorha

Bug Description

Provider plugins have only one hook for turning a credential pool row into a request credential: ProviderProfile.prepare_pool_entry(entry, api_key) -> str in providers/base.py. It returns a single string and its docstring allows it to update entry. A provider whose request credential is derived from a durable grant (for example a short-lived bearer obtained by exchanging a long-lived token, often paired with an account-specific endpoint) has no way to hand core a temporary bearer and endpoint without writing them into the pool row.

When a plugin does write the derived bearer or endpoint into the row, that row is what core persists. The derived value can then replace the durable grant that later renewal depends on. Core also has no hook to re-mint the derived credential for the specific row that failed, so recovery cannot be scoped to the dispatched row and its failed bearer.

The GitHub Copilot provider plugin (NousResearch/hermes-labs-plugins, github-copilot) is the concrete consumer affected today, but the gap is in the generic provider-plugin SDK, not in vendor code.

Steps to Reproduce

Verified by offline regression tests in #154360 (synthetic credentials, isolated HERMES_HOME); no live provider requests. The contract tests are tests/providers/test_pool_runtime_contract.py and tests/agent/test_pool_runtime_credential_lifecycle.py.

  1. Register a provider plugin whose prepare_pool_entry exchanges the row's durable grant for a short-lived bearer and account endpoint.
  2. Add a pool row for that provider and dispatch a request through the pool (primary, auxiliary or delegated client).
  3. Inspect what is dispatched and what is persisted to the auth store after save and reload.

Expected Behavior

  • The durable grant stays in the persisted pool row unchanged.
  • The derived bearer and endpoint are used for the request as runtime-only state and are never written to auth.json.
  • On an auth failure, renewal re-mints only the row that was dispatched, matched by row ID and the bearer that failed, without benching the account or falling back to ambient credentials.
  • This works the same for primary, auxiliary and delegated clients and across the subprocess plugin host.

Actual Behavior

  • With only the string-returning hook, the derived pair must either be written into the row (and is then persisted, potentially replacing the durable grant) or is unavailable to core.
  • The fix: keep derived pool credentials runtime-only #154360 base-red regression shows pristine upstream dispatching the durable source token rather than the derived bearer.
  • There is no selected-row renewal hook, so recovery cannot be limited to the failed row and bearer.

Affected Component

Other (provider plugin SDK: providers/base.py, agent/credential_pool*.py, hermes_cli/plugin_host_*)

Messaging Platform (if gateway-related)

N/A (not platform specific)

Debug Report

n/a: hermes debug share is not applicable. This is an SDK contract gap found by code reading and reproduced only by the offline regression tests in #154360 (synthetic credentials, isolated HERMES_HOME). No user session, config or logs are involved.

Operating System

macOS (local test runs only)

Python Version

n/a: repository-managed test environment; not tied to a Python version.

Hermes Version

Source checkout, upstream main at 4b40ffb0ad6d7da5d3260f5e499e1691508dd4d5 (not a released build). Still present on current main: providers/base.py declares prepare_pool_entry(self, entry, api_key) -> str.

Root Cause Analysis

  • providers/base.py: prepare_pool_entry returns str only, and the docstring permits mutating entry. There is no typed way to return a key plus endpoint that core treats as transient.
  • hermes_cli/runtime_provider.py: the result of prepare_pool_entry replaces the pool API key directly; there is no notion of a runtime-only override bound to its source grant.
  • agent/credential_pool.py / agent/credential_pool_plugin.py: persisted row data and request credentials are the same fields, so anything a plugin writes to the row is saved.
  • Hosted plugins receive a data copy of entry across the subprocess plugin host, so row mutation is not a reliable channel there either.

Proposed Fix

#154360 adds an opt-in generic SDK in core:

  • PoolRuntimeCredential(api_key, base_url) in providers/base.py; prepare_pool_entry may return it instead of a string. Legacy string returns keep their current behavior.
  • refresh_pool_runtime_credentials(entry, *, reason) for renewal of the selected row only, and credential_pool_base_urls for explicit endpoint equivalence.
  • agent/credential_pool_plugin.py binds overrides to their source grant and keeps them out of persisted account data; runtime, rotation, cooldown reclaim, auxiliary (agent/auxiliary_pool_recovery.py) and delegation (tools/delegate_tool_child_run.py) paths prepare the selected row the same way; the plugin host restores the declared return types.

The Copilot consumer change is NousResearch/hermes-labs-plugins#77 and should ship after core.

Related

Are you willing to submit a PR for this?

Activity

  1. added
    area/auth
    comp/plugins
    P3
    type/security
    comp/agent
    on Nov 14, 2026
  2. alt-glitch commented on Nov 14, 2026

    @alt-glitch
    Contributor

    #154360 aims to fix this: it adds an opt-in hook that returns a short-lived bearer and endpoint as runtime-only values, so the durable grant stays in the saved pool row, plus a renewal hook that re-mints only the failed row.

  3. paulorha commented on Nov 15, 2026

    @paulorha
    Author

    Status update: I checked upstream main at fd8a6c41. The pool preparation contract still lets a provider plugin mutate the persisted entry, and main does not yet have the runtime-only credential or selected-row renewal hooks. This is from code inspection, not a fresh reproduction.

    #154360 is now rebased onto fd8a6c41 (head c0bbbe86) and no longer conflicts with main. Its pool/auth contract tests pass locally (153 tests across 9 files) and scripts/check passes. The dependent hermes-labs-plugins#77 passes the full github-copilot suite (180 tests) against that core commit and stays in draft until the core contract lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area/authcomp/agentcomp/pluginstype/security

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions