From 9da7efd17cc535d20e1d20a40f66edfcf8eee756 Mon Sep 17 00:00:00 2001 From: Otto Date: Mon, 9 Feb 2026 00:31:06 +0000 Subject: [PATCH] fix: add missing Credentials import and host-scoped credential check - Import Credentials type from backend.data.model - Add host-scoped credential matching to find_matching_credential (consistent with match_user_credentials_to_graph) --- .../backend/backend/api/features/chat/tools/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/autogpt_platform/backend/backend/api/features/chat/tools/utils.py b/autogpt_platform/backend/backend/api/features/chat/tools/utils.py index 4f514c5524..c48cd09458 100644 --- a/autogpt_platform/backend/backend/api/features/chat/tools/utils.py +++ b/autogpt_platform/backend/backend/api/features/chat/tools/utils.py @@ -8,6 +8,7 @@ from backend.api.features.library import model as library_model from backend.api.features.store import db as store_db from backend.data.graph import GraphModel from backend.data.model import ( + Credentials, CredentialsFieldInfo, CredentialsMetaInput, HostScopedCredentials, @@ -288,13 +289,15 @@ def find_matching_credential( available_creds: list[Credentials], field_info: CredentialsFieldInfo, ) -> Credentials | None: - """Find a credential that matches the required provider, type, and scopes.""" + """Find a credential that matches the required provider, type, scopes, and host.""" for cred in available_creds: if cred.provider not in field_info.provider: continue if cred.type not in field_info.supported_types: continue - if not _credential_has_required_scopes(cred, field_info): + if cred.type == "oauth2" and not _credential_has_required_scopes(cred, field_info): + continue + if cred.type == "host_scoped" and not _credential_is_for_host(cred, field_info): continue return cred return None