100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.
Fix consultant tool schema, customer-support memory, and governance approval bypass (#1050)
Thejeshb96d19ad0509
diff --git a/advanced_ai_agents/single_agent_apps/ai_agent_governance/ai_agent_governance.py b/advanced_ai_agents/single_agent_apps/ai_agent_governance/ai_agent_governance.pyindex c96be0af..2070554a 100644--- a/advanced_ai_agents/single_agent_apps/ai_agent_governance/ai_agent_governance.py+++ b/advanced_ai_agents/single_agent_apps/ai_agent_governance/ai_agent_governance.py@@ -242,12 +242,25 @@ class PolicyEngine:def evaluate(self, action: Action) -> PolicyResult:"""Evaluate an action against all policy rules"""+ allow_result = Nonefor rule in self.rules:result = rule.evaluate(action)- if result and result.is_terminal:- self._log_audit(action, result)- return result-+ if not result or not result.is_terminal:+ continue+ if result.decision == Decision.ALLOW:+ # An allow is not final: a later rule may still deny the action+ # or require approval for it. Remember the first allow but keep+ # evaluating so deny/approval rules can override it.+ if allow_result is None:+ allow_result = result+ continue+ self._log_audit(action, result)+ return result++ if allow_result is not None:+ self._log_audit(action, allow_result)+ return allow_result+# Default allow if no rule blocksresult = PolicyResult(decision=Decision.ALLOW,diff --git a/advanced_ai_agents/single_agent_apps/ai_consultant_agent/ai_consultant_agent.py b/advanced_ai_agents/single_agent_apps/ai_consultant_agent/ai_consultant_agent.pyindex 42ed1621..c0f48831 100644--- a/advanced_ai_agents/single_agent_apps/ai_consultant_agent/ai_consultant_agent.py+++ b/advanced_ai_agents/single_agent_apps/ai_consultant_agent/ai_consultant_agent.py@@ -1,6 +1,7 @@import loggingfrom typing import Dict, Any, List, Unionfrom dataclasses import dataclass+from functools import wrapsimport base64import requestsimport os@@ -58,6 +59,7 @@ def safe_tool_wrapper(tool_func):Returns:Wrapped function that sanitizes output"""+ @wraps(tool_func)def wrapped_tool(*args, **kwargs):try:result = tool_func(*args, **kwargs)@@ -69,10 +71,9 @@ def safe_tool_wrapper(tool_func):"tool": tool_func.__name__,"status": "error"}-- # Preserve function metadata- wrapped_tool.__name__ = tool_func.__name__- wrapped_tool.__doc__ = tool_func.__doc__++ # @wraps copies __wrapped__ so ADK's inspect.signature() sees the real+ # parameters (a bare *args/**kwargs wrapper is declared to Gemini with none).return wrapped_tool@dataclassdiff --git a/advanced_ai_agents/single_agent_apps/ai_customer_support_agent/customer_support_agent.py b/advanced_ai_agents/single_agent_apps/ai_customer_support_agent/customer_support_agent.pyindex e130d38a..39d51d41 100644--- a/advanced_ai_agents/single_agent_apps/ai_customer_support_agent/customer_support_agent.py+++ b/advanced_ai_agents/single_agent_apps/ai_customer_support_agent/customer_support_agent.py@@ -26,6 +26,9 @@ if openai_api_key:"port": 6333,}},+ # mem0 defaults to v1.0, whose search()/get_all() return a bare+ # list; the code below expects the v1.1 {"results": [...]} shape.+ "version": "v1.1",}try:self.memory = Memory.from_config(config)