-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathworkday_agent.py
More file actions
94 lines (76 loc) · 3.16 KB
/
Copy pathworkday_agent.py
File metadata and controls
94 lines (76 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""Workday agent using the StackOne plugin for Google ADK.
Default mode — registers a small, scoped set of Workday tools with the agent.
Workday's full catalog (hundreds of actions) exceeds Gemini's `tools` payload
cap; for unscoped catalogs use ``search_and_execute_agent.py`` instead.
Setup:
export STACKONE_API_KEY="..."
export STACKONE_ACCOUNT_ID="..." # Workday account id
export GOOGLE_API_KEY="..." # for Gemini
Run:
uv run examples/workday_agent.py
"""
from __future__ import annotations
import asyncio
import contextlib
import logging
import os
import sys
import warnings
# Force-load authlib's deprecate filter so our ignore takes precedence.
with contextlib.suppress(ImportError):
import authlib.deprecate # noqa: F401
warnings.simplefilter("ignore")
for _name in ("google_genai", "google_genai.types", "google.genai", "google.adk"):
logging.getLogger(_name).setLevel(logging.ERROR)
from google.adk.agents import Agent # noqa: E402
from google.adk.apps import App # noqa: E402
from google.adk.runners import InMemoryRunner # noqa: E402
from stackone_adk import StackOnePlugin # noqa: E402
async def main() -> None:
if not os.getenv("STACKONE_API_KEY"):
sys.exit("Set STACKONE_API_KEY to run this example.")
account_id = os.getenv("STACKONE_ACCOUNT_ID")
if not account_id:
sys.exit("Set STACKONE_ACCOUNT_ID (Workday) to run this example.")
if not os.getenv("GOOGLE_API_KEY"):
sys.exit("Set GOOGLE_API_KEY to run this example.")
# Default mode sends every tool's schema to the LLM. Workday has hundreds
# of actions, so we scope to a handful to stay under Gemini's payload cap.
# For larger catalogs use search_and_execute_agent.py instead.
plugin = StackOnePlugin(
account_id=account_id,
providers=["workday"],
actions=[
"workday_list_workers",
"workday_get_worker",
"workday_list_jobs",
],
)
tools = plugin.get_tools()
print(f"Registered {len(tools)} Workday tool(s): {[t.name for t in tools]}\n")
agent = Agent(
model="gemini-3.1-pro-preview",
name="stackone_agent",
description="Provides access to connected SaaS data via StackOne.",
instruction=(
"You are an HR assistant with access to tools via StackOne "
"(e.g. Workday). Use the available tools to answer questions "
"about workers and HR records. Keep answers concise and reference "
"real data."
),
tools=tools,
)
app = App(name="stackone_app", root_agent=agent, plugins=[plugin])
prompt = "List the first 3 Workday workers and summarise who they are."
print(f"User: {prompt}")
print("=" * 60)
async with InMemoryRunner(app=app) as runner:
events = await runner.run_debug(prompt, quiet=True)
for event in reversed(events):
if event.content and event.content.parts:
text_parts = [p.text for p in event.content.parts if p.text]
if text_parts:
print(f"Agent: {''.join(text_parts)}\n")
break
if __name__ == "__main__":
asyncio.run(main())