Skip to content

ImportError: cannot import 'AuthMethod' from acp.schema — ACP version/import mismatch (CI failing) #456

Description

@koffie

During CI (see failing job: https://github.com/math-inc/OpenGauss/actions/runs/24005864186/job/70009361883) the ACP adapter crashes with an ImportError:

ImportError: cannot import name 'AuthMethod' from 'acp.schema'

Observed in: acp_adapter/server.py (import list around line 17) when the ACP server initializes. The repository's declared dependency in pyproject.toml is:

acp = ["agent-client-protocol>=0.8.1,<1.0"]

This report covers two likely root causes and asks for a corrective action:

Problem summary

  • The code imports AuthMethod from acp.schema, but the installed agent-client-protocol version does not provide AuthMethod at that location (or at all), causing the import error and failing the ACP start / CI job.

Possible fixes (pick one as appropriate)

  1. Pin/upgrade the agent-client-protocol package to a version that exposes AuthMethod at acp.schema (or otherwise provides the expected API). Update pyproject.toml accordingly (e.g. bump the lower/upper bounds or pin to a specific working release). Verify that the CI environment installs that version.

  2. If AuthMethod was moved/renamed in the currently allowed ACP versions, update the import and initialization code in acp_adapter/server.py to use the correct symbol/location or to construct the authentication metadata without relying on AuthMethod (for example, use a plain dict for auth method metadata or the correct class from the current ACP package).

Suggested changes to the code (non-exhaustive)

  • Option A (depend on ACP having AuthMethod):

    • Update pyproject.toml to allow the ACP version that includes AuthMethod (e.g. set a specific working version range).
    • Confirm by running pip install agent-client-protocol==<version> locally and running the failing code path.
  • Option B (make code compatible with current ACP):

    • Replace the AuthMethod usage in acp_adapter/server.py initialize() with a plain mapping or with the correct class from the current ACP version. Example sketch:
provider = detect_provider()
auth_methods = None
if provider:
    auth_methods = [
        {
            "id": provider,
            "name": f"{provider} runtime credentials",
            "description": f"Authenticate Gauss using the currently configured {provider} runtime credentials.",
        }
    ]
  • Verify the fix by running the ACP server and CI.

Reproduction

  • Run the failing GitHub Actions job (see URL above) or locally with the environment used by CI.
  • Run python -m acp_adapter or gauss acp after installing dependencies via pip install -e '.[acp]' and observe the ImportError.

Expected behavior

  • The ACP adapter should import the correct symbols and start without raising ImportError.

Additional notes

  • pyproject.toml currently constrains agent-client-protocol>=0.8.1,<1.0. If AuthMethod was added in a later major release (>=1.0) then choosing to update the dependency should be done intentionally and with compatibility testing.

Please either update the dependency bounds in pyproject.toml to allow an ACP version that provides AuthMethod, or change the import/use of AuthMethod in acp_adapter/server.py to be compatible with the currently-allowed ACP versions.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions