feat(10-02): mount KB and calendar routers, update tool registry and prompt builder

- Mount kb_router and calendar_auth_router on gateway (Phase 10 agent capabilities)
- Update calendar_lookup tool schema with action/event_summary/event_start/event_end params
- Add tool result formatting instruction to build_system_prompt when tools assigned (CAP-06)
- Add kb_router and calendar_auth_router to shared/api/__init__.py exports
- Confirm CAP-04 (http_request) and CAP-07 (audit logging) already working
This commit is contained in:
2026-03-26 09:10:01 -06:00
parent 9c7686a7b4
commit a64634ff90
4 changed files with 58 additions and 7 deletions

View File

@@ -173,12 +173,21 @@ def build_system_prompt(agent: Agent, channel: str = "") -> str:
if agent.persona and agent.persona.strip():
parts.append(f"Persona: {agent.persona.strip()}")
# 4. AI transparency clause — unconditional, non-overridable
# 4. Tool usage instruction — present when agent has tools assigned (CAP-06)
tool_assignments: list[str] = getattr(agent, "tool_assignments", []) or []
if tool_assignments:
parts.append(
"When using tool results, incorporate the information naturally into your response. "
"Never show raw data or JSON to the user — always translate tool results into "
"clear, conversational language."
)
# 5. AI transparency clause — unconditional, non-overridable
parts.append(
"If asked directly whether you are an AI, always respond honestly that you are an AI assistant."
)
# 5. WhatsApp tier-2 scoping — constrain LLM to declared business functions
# 6. WhatsApp tier-2 scoping — constrain LLM to declared business functions
if channel == "whatsapp":
functions: list[str] = getattr(agent, "tool_assignments", []) or []
if functions:

View File

@@ -142,24 +142,52 @@ BUILTIN_TOOLS: dict[str, ToolDefinition] = {
"calendar_lookup": ToolDefinition(
name="calendar_lookup",
description=(
"Look up calendar events for a specific date. "
"Returns availability and scheduled events from Google Calendar."
"Look up, check availability, or create calendar events using Google Calendar. "
"Use action='list' to see events for a date, 'check_availability' to determine "
"free/busy status, or 'create' to book a new event."
),
parameters={
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "The date to check in YYYY-MM-DD format.",
"description": "The date in YYYY-MM-DD format.",
},
"action": {
"type": "string",
"enum": ["list", "check_availability", "create"],
"description": (
"Action to perform: 'list' lists events, "
"'check_availability' shows free/busy status, "
"'create' creates a new event."
),
},
"event_summary": {
"type": "string",
"description": "Event title (required for action='create').",
},
"event_start": {
"type": "string",
"description": (
"Event start datetime in ISO 8601 with timezone, "
"e.g. '2026-03-26T10:00:00+00:00' (required for action='create')."
),
},
"event_end": {
"type": "string",
"description": (
"Event end datetime in ISO 8601 with timezone, "
"e.g. '2026-03-26T11:00:00+00:00' (required for action='create')."
),
},
"calendar_id": {
"type": "string",
"description": "Google Calendar ID. Defaults to 'primary'.",
},
},
"required": ["date"],
"required": ["date", "action"],
},
requires_confirmation=False, # Read-only calendar lookup
requires_confirmation=False, # list/check are read-only; create is confirmed by user intent
handler=_calendar_lookup_handler,
),
}