from google.adk.tools.tool_context import ToolContext import datetime def update_customer_profile(field: str, value: str, tool_context: ToolContext) -> dict: """Updates a customer's profile information. Args: field: Profile field to update. value: New value. tool_context: Provided by ADK. Returns: dict: Success status and summary. """ try: profile_key = "user:customer_profile" profile = tool_context.state.get(profile_key, {}) if "update_history" not in profile: profile["update_history"] = [] old_value = profile.get(field) profile[field] = value profile["update_history"].append({ "field": field, "old_value": old_value, "new_value": value, "timestamp": datetime.datetime.now().isoformat() }) tool_context.state[profile_key] = profile return { "status": "success", "message": f"Updated {field} to '{value}'", "profile_summary": {k: v for k, v in profile.items() if k != "update_history"} } except Exception as e: return { "status": "error", "error_message": f"Failed to update profile: {str(e)}" } __ __