21
21
22
22
OKTA_PROFILE_RESPONSE_ID = "okta_profile"
23
23
24
+ OKTA_TOOL_DESCRIPTION = """
25
+ The Okta profile tool can retrieve user profile information from Okta including:
26
+ - User ID, status, creation date
27
+ - Profile details like name, email, department, location, title, manager, and more
28
+ - Account status and activity
29
+ """
30
+
24
31
25
32
class OIDCConfig (BaseModel ):
26
33
issuer : str
@@ -182,11 +189,7 @@ def get_args_for_non_tool_calling_llm(
182
189
prompt = f"""
183
190
You are helping to determine if an Okta profile lookup tool should be called based on a user's query.
184
191
185
- The Okta profile tool can retrieve user profile information from Okta including:
186
- - User ID, status, creation date
187
- - Profile details like name, email, department, title
188
- - Authentication and credential information
189
- - Account status and activity
192
+ { OKTA_TOOL_DESCRIPTION }
190
193
191
194
Query: { query }
192
195
@@ -206,20 +209,19 @@ def get_args_for_non_tool_calling_llm(
206
209
def run (
207
210
self , override_kwargs : None = None , ** llm_kwargs : Any
208
211
) -> Generator [ToolResponse , None , None ]:
209
- # Get user info to extract the UID
210
- userinfo_data = self ._call_userinfo (self .access_token )
211
- introspection_data = self ._call_introspection (self .access_token )
212
-
213
- # Extract UID from userinfo or introspection
212
+ # Try to get UID from userinfo first, then fallback to introspection
214
213
uid_candidate = None
214
+
215
+ # Try userinfo endpoint first
216
+ userinfo_data = self ._call_userinfo (self .access_token )
215
217
if userinfo_data and isinstance (userinfo_data , dict ):
216
218
uid_candidate = userinfo_data .get ("uid" )
217
- if (
218
- not uid_candidate
219
- and introspection_data
220
- and isinstance ( introspection_data , dict )
221
- ):
222
- uid_candidate = introspection_data .get ("uid" )
219
+
220
+ # Only try introspection if userinfo didn't provide a UID
221
+ if not uid_candidate :
222
+ introspection_data = self . _call_introspection ( self . access_token )
223
+ if introspection_data and isinstance ( introspection_data , dict ):
224
+ uid_candidate = introspection_data .get ("uid" )
223
225
224
226
if not uid_candidate :
225
227
raise ValueError (
0 commit comments