Skip to content

Commit 55aefbc

Browse files
committed
a2a
1 parent 273e1b5 commit 55aefbc

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

jacspy/python/jacs/a2a_discovery.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
import asyncio
3333
import logging
34+
import os
35+
import warnings
3436
from typing import Any, Dict, Optional, TYPE_CHECKING
3537

3638
try:
@@ -182,8 +184,11 @@ async def discover_and_assess(
182184
"trust_level": trust.get("trustLevel", "untrusted"),
183185
"allowed": trust.get("allowed", False),
184186
}
185-
except Exception:
186-
logger.debug("binding-core assess_a2a_agent failed, falling back to local logic")
187+
except (ImportError, AttributeError):
188+
logger.warning(
189+
"Falling back to local trust policy evaluation "
190+
"— binding-core assess_a2a_agent unavailable"
191+
)
187192

188193
# Fallback: deprecated local logic when no client is available
189194
is_trusted = getattr(client, "is_trusted", None) if client is not None else None
@@ -308,6 +313,15 @@ def _evaluate_trust_policy(
308313
"allowed": bool,
309314
}
310315
"""
316+
if os.environ.get("JACS_SHOW_DEPRECATIONS"):
317+
warnings.warn(
318+
"_evaluate_trust_policy() is deprecated. "
319+
"Use binding-core's assess_a2a_agent() via "
320+
"JACSA2AIntegration.assess_remote_agent() instead.",
321+
DeprecationWarning,
322+
stacklevel=2,
323+
)
324+
311325
effective_policy = _validate_trust_policy(policy)
312326

313327
jacs_registered = _has_jacs_extension(card)

jacspy/python/jacs/adapters/base.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,28 @@ def assess_trust(
322322
from ..a2a_discovery import _evaluate_trust_policy, _validate_trust_policy
323323

324324
effective_policy = _validate_trust_policy(policy)
325-
326325
card = json.loads(agent_card_json)
326+
327+
# Prefer binding-core delegation when available
328+
if hasattr(self._client, "_agent"):
329+
try:
330+
canonical_json = self._client._agent.assess_a2a_agent(
331+
agent_card_json, effective_policy
332+
)
333+
trust = json.loads(canonical_json)
334+
return {
335+
"card": card,
336+
"jacs_registered": trust.get("jacsRegistered", False),
337+
"trust_level": trust.get("trustLevel", "untrusted"),
338+
"allowed": trust.get("allowed", False),
339+
}
340+
except (ImportError, AttributeError):
341+
logger.warning(
342+
"Falling back to local trust policy evaluation "
343+
"— binding-core assess_a2a_agent unavailable"
344+
)
345+
346+
# Fallback: deprecated local logic
327347
trust = _evaluate_trust_policy(
328348
card,
329349
policy=effective_policy,

0 commit comments

Comments
 (0)