from veadk import Agent, Runner
from google.adk.a2a.executor.a2a_agent_executor import A2aAgentExecutor
from agentkit.apps import AgentkitA2aApp
logger = logging.getLogger(__name__)
a2a_app = AgentkitA2aApp()
def query_company_policy(topic: str) -> dict[str, str]:
"""Look up a company policy by topic.
The topic MUST be expressed in English, even when the user asks in another
language (translate their intent into the matching English topic first).
Only these three policy areas are supported:
- travel: business travel and expense reimbursement, e.g. "travel
reimbursement", "flight booking", "hotel expense", "taxi invoice"
- attendance: attendance and clock-in rules, e.g. "attendance", "clock-in
time", "check-in", "working hours", "late arrival"
- leave: time-off requests, e.g. "annual leave", "vacation", "sick leave",
"travel": "Travel reimbursement policy: flights and hotels must be booked through the approved company platform. Taxi reimbursement requires a digital invoice.",
"attendance": "Attendance policy: employees must check in before 10:00 AM on workdays. Late arrival over 30 minutes requires manager approval.",
"leave": "Leave policy: annual leave should be submitted in the HR system at least one business day in advance, except for emergencies.",
normalized_topic = topic.lower().strip().replace("-", " ")
"travel", "reimbursement", "reimburse", "trip", "expense",
"flight", "hotel", "accommodation", "lodging", "taxi", "cab",
"invoice", "allowance", "per diem", "business trip",
"attendance", "clock", "check in", "sign in", "late", "tardy",
"punctual", "work hour", "working hour", "time card", "timesheet",
"leave", "vacation", "annual leave", "day off", "days off",
"time off", "pto", "sick leave", "absence", "holiday request",
if any(keyword in normalized_topic for keyword in travel_keywords):
elif any(keyword in normalized_topic for keyword in attendance_keywords):
elif any(keyword in normalized_topic for keyword in leave_keywords):
"result": "No matching policy was found. Contact HR or the policy owner for clarification."
return {"result": policies[key]}
agent_name = "policy_support_agent"
description = "A company policy assistant."
"You are a company policy assistant. "
"Whenever the user asks about travel/expense reimbursement, attendance/clock-in, "
"or leave/vacation, call query_company_policy. "
"The tool only accepts English topics, so regardless of the user's language, "
"always translate their intent into one of the supported English topics: "
"travel reimbursement, attendance, or leave. "
"Do not invent policies that are not returned by the tool."
tools = [query_company_policy]
description=description,
instruction=system_prompt,
runner = Runner(agent=agent)
@a2a_app.agent_executor(runner=runner)
class MyAgentExecutor(A2aAgentExecutor):
if __name__ == "__main__":
from a2a.types import AgentCard, AgentProvider, AgentSkill, AgentCapabilities
capabilities=AgentCapabilities(streaming=True),
description=agent.description,
default_input_modes=["text"],
default_output_modes=["text"],
provider=AgentProvider(organization="veadk", url=""),
description="Company policy Q&A",
tags=["policy", "travel", "attendance", "leave"],
url="http://0.0.0.0:8000",