Skip to content

Commit 3f78649

Browse files
committed
Address EL comments
1 parent aaa76ff commit 3f78649

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

backend/onyx/tools/tool_implementations/okta_profile/okta_profile_tool.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121

2222
OKTA_PROFILE_RESPONSE_ID = "okta_profile"
2323

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+
2431

2532
class OIDCConfig(BaseModel):
2633
issuer: str
@@ -182,11 +189,7 @@ def get_args_for_non_tool_calling_llm(
182189
prompt = f"""
183190
You are helping to determine if an Okta profile lookup tool should be called based on a user's query.
184191
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}
190193
191194
Query: {query}
192195
@@ -206,20 +209,19 @@ def get_args_for_non_tool_calling_llm(
206209
def run(
207210
self, override_kwargs: None = None, **llm_kwargs: Any
208211
) -> 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
214213
uid_candidate = None
214+
215+
# Try userinfo endpoint first
216+
userinfo_data = self._call_userinfo(self.access_token)
215217
if userinfo_data and isinstance(userinfo_data, dict):
216218
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")
223225

224226
if not uid_candidate:
225227
raise ValueError(

0 commit comments

Comments
 (0)