7.2 Building Custom Agents on Agent Platform
Key Takeaways
- Agent Platform enables organizations to build autonomous, task-driven conversational agents that combine natural language understanding with dynamic workflow execution.
- Enterprise Gen AI agents comprise five core anatomical pillars: Goals and Personas, Playbooks and Instructions, Tools and Extensions (OpenAPI/Cloud Functions), Grounded Data Stores, and Multi-turn Session Memory.
- The ReAct (Reasoning + Acting) execution loop allows agents to iteratively decompose complex user requests, evaluate intermediate observations, decide between information retrieval and API actions, and adapt in real time.
- Deterministic business rules in playbooks provide governance over generative outputs, enforcing explicit escalation paths to human operators when confidence thresholds or compliance constraints are breached.
7.2 Building Custom Agents on Agent Platform
Executive Summary: Generative AI is rapidly evolving from passive informational interfaces (chatbots that merely answer questions) to autonomous task-driven agents (systems that reason, make decisions, invoke enterprise APIs, and complete complex multi-step workflows). Google Cloud's Agent Platform provides a unified developer platform to design, orchestrate, ground, and deploy enterprise-grade conversational and autonomous agents powered by Gemini foundation models. By uniting natural language instructions, structured tools, and real-time enterprise systems, Agent Builder transforms generative models into active digital workers.
The Evolution: From Static Chatbots to Autonomous Agents
To understand the strategic imperative of agents, business leaders must recognize the generational progression of conversational software:
- Generation 1: Rule-Based Decision Trees (2010s): Brittle, deterministic dialog trees (e.g., legacy IVR menus or primitive keyword bots). If a user deviated from the predefined path, the bot failed.
- Generation 2: Intent-Based Conversational AI (late 2010s): Powered by Natural Language Understanding (NLU) engines (such as Dialogflow ES). These models mapped user utterances to pre-classified intents (e.g.,
check_balance), extracted entities, and executed static backend webhook logic. - Generation 3: Grounded Q&A Chatbots (2023): Generative LLMs paired with RAG pipelines (such as Agent Search). These systems converse fluently and answer questions grounded in corporate documents, but they remain essentially read-only observers incapable of executing actions.
- Generation 4: Autonomous Task-Driven Agents (Present): Systems built with Agent Platform that possess agency. They perceive an open-ended user objective, decompose it into sequential sub-tasks, reason about required actions, dynamically query data stores, invoke external REST APIs to modify corporate databases, evaluate outcomes, and escalate to human agents when appropriate.
GENERATION 3: Grounded Chatbot (Passive Observer)
User: "What is my current travel policy allowance for hotels in Chicago?"
Bot: "According to the Corporate Travel Policy (Section 4), your allowance is $250/night." [Grounding only]
GENERATION 4: Autonomous Gen AI Agent (Active Task Executor)
User: "Find a policy-compliant hotel in Chicago for next Tuesday and book it using my corporate card."
Agent: 1. Queries Agent Search -> Discovers Chicago per-diem cap is $250.
2. Invokes Sabre/Amadeus Booking Tool via OpenAPI Extension -> Identifies compliant rooms.
3. Verifies user corporate travel profile in Salesforce CRM.
4. Calls Reservation API -> Charges corporate card and books room.
5. Dispatches calendar invitation and confirms booking ID via Slack.
Anatomical Components of an Enterprise Gen AI Agent
In Agent Platform, an enterprise agent is not a single monolith. It is composed of five interconnected anatomical pillars that govern identity, reasoning, capabilities, knowledge, and continuity:
+-----------------------------------------------------------------------------------+
| ENTERPRISE GEN AI AGENT |
| |
| +-----------------------------+ +-------------------------------------+ |
| | 1. GOAL & PERSONA | | 2. PLAYBOOKS & INSTRUCTIONS | |
| | Defines role, behavioral | | Natural language workflow logic, | |
| | tone, boundaries & identity | | business rules & escalation policy | |
| +-----------------------------+ +-------------------------------------+ |
| | | |
| +-------------------+ +-------------------+ |
| | | |
| v v |
| +-----------------------------------+ |
| | FOUNDATION MODEL REASONING CORE | |
| | (Gemini Pro / Flash ReAct) | |
| +-----------------------------------+ |
| ^ ^ |
| +-------------------+ +-------------------+ |
| | | |
| +-----------------------------+ +-------------------------------------+ |
| | 3. TOOLS & EXTENSIONS | | 4. GROUNDED DATA STORES | |
| | OpenAPI specs, Cloud Funcs, | | Agent Search, BigQuery, | |
| | ERP/CRM enterprise webhooks | | corporate policy PDF repositories | |
| +-----------------------------+ +-------------------------------------+ |
| |
| +-----------------------------------------------------------------------------+ |
| | 5. MULTI-TURN STATE & SESSION MEMORY | |
| | Context buffer, entity slots, user state, and cross-turn persistence | |
| +-----------------------------------------------------------------------------+ |
+-----------------------------------------------------------------------------------+
1. Goals & Personas
- Role Definition: Sets the operational identity and boundaries of the agent (e.g., "You are the IT Service Desk Autonomous Specialist for Global Logistics Corp.").
- Tone & Persona: Dictates linguistic demeanor—professional, concise, empathetic, or technically rigorous.
- Operational Constraints: Defines explicit behavioral guardrails (e.g., "Never provide legal counsel. Never reveal internal database schemas or API authentication keys.").
2. Playbooks & Natural Language Instructions
In traditional software, workflows are encoded via rigid flowchart logic or code state machines. In Agent Platform, workflows are structured as Playbooks:
- Declarative Workflows: Developers write instructions in clear natural language explaining the sequence of steps required to achieve a goal (e.g., "Step 1: Greet the user and extract their employee ID. Step 2: Validate active employment status via the HR Tool. Step 3: If active, ask for the target software license...").
- Deterministic Business Rules: Playbooks incorporate conditional branching (e.g., "IF the requested expense exceeds $5,000, DO NOT approve automatically; invoke the Escalation Tool to create a manager approval ticket.").
- Escalation Protocol: Specifies exact conditions under which autonomous execution must halt and transition gracefully to a human representative.
3. Tools & Extensions
An LLM in isolation is trapped within its static training weights. Tools provide the agent with hands to act upon the external world:
- OpenAPI Specifications: Developers provide a standard Swagger / OpenAPI JSON or YAML definition describing external REST endpoints (paths, parameters, authentication methods).
- Cloud Functions & Cloud Run: Agents can trigger serverless microservices on Google Cloud to execute custom business logic, compute actuarial risk formulas, or query legacy databases.
- Function Calling: Gemini natively detects when a user request requires external action, pauses generation, produces a structured JSON argument payload matching the tool's schema, and consumes the execution result.
4. Grounded Data Stores
Tools execute actions, whereas Data Stores provide authoritative factual memory:
- Direct integration with Agent Search data stores allows the agent to perform instant semantic queries across corporate manuals, technical wikis, or product catalogs.
- The agent autonomously decides whether an incoming user prompt requires querying a data store (e.g., "What are the diagnostic symptoms of code E-402?") or invoking a tool (e.g., "Reset router 14B").
5. Multi-Turn State & Session Memory
Human conversations are inherently contextual and multi-turn:
- Context Maintenance: Retains conversation history across multiple back-and-forth interactions so users do not have to repeat previously stated details.
- Entity Extraction & Slot Filling: Extracts and tracks key business variables (e.g., order IDs, dates, flight numbers, dollar amounts) throughout the session lifecycle.
- Session State Storage: Manages state across conversational branches, allowing users to pause a task, ask a tangential clarifying question, and resume the original workflow seamlessly.
Cognitive Execution Loops: The ReAct Paradigm
How does an agent decide what to do when confronted with an ambiguous, multi-step prompt? Modern generative agents utilize the ReAct (Reasoning + Acting) framework.
USER REQUEST: "My laptop screen is flickering, and if it's under warranty, I want a replacement order initiated."
[ ITERATION 1: REASONING ]
Thought: The user has a hardware issue and wants a replacement if under warranty. First, I must look up warranty status.
Action: Invoke Tool: HardwareDatabaseAPI(action="lookup_warranty", user="alice")
[ ITERATION 1: OBSERVATION ]
Observation: Laptop serial #8841-A; Purchased 8 months ago; 3-Year Enterprise Warranty ACTIVE.
[ ITERATION 2: REASONING ]
Thought: Warranty is confirmed active. Now I should check the troubleshooting knowledge base to see if flickering is fixable via driver update before ordering hardware.
Action: Query Data Store: IT_Troubleshooting_Store(query="laptop screen flickering Model 8841-A")
[ ITERATION 2: OBSERVATION ]
Observation: KB-104: Known firmware issue resolved by Display Patch 4.2. If patch fails, hardware replacement is required.
[ ITERATION 3: REASONING ]
Thought: I should advise Alice to run Patch 4.2 first, but pre-authorize the replacement ticket if she confirms the patch did not work.
Action: Synthesize final empathetic response with actionable instructions and ticket ID.
Deconstructing the ReAct Loop
- Reasoning (Thought): The agent's underlying Gemini model analyzes the conversation history, user goal, and available tools to formulate an internal rationale regarding the next logical step.
- Acting (Action): The agent generates a structured API call or data store query to gather data or alter state in an external system.
- Observation: The external system returns a payload (JSON response, error code, or search snippet). The agent ingests this observation into its active context window.
- Reflection & Progression: The agent evaluates whether the observation satisfies the user's objective. If not, it initiates another reasoning cycle. Once resolved, it synthesizes the final grounded user-facing response.
Balancing Autonomous Agency with Deterministic Governance
A critical exam topic and enterprise leadership concern is avoiding "runaway agents" or hallucinated actions. If an agent has access to financial transaction APIs or production infrastructure, purely probabilistic decision-making introduces unacceptable enterprise risk.
Agent Platform solves this by enabling hybrid orchestration:
| Control Mechanism | Implementation in Agent Builder | Enterprise Protection Benefit |
|---|---|---|
| Deterministic Playbook Guardrails | Explicit natural language constraints with conditional logic | Guarantees compliance; prevents agent from skipping mandatory legal or identity verification steps. |
| Schema-Enforced Tool Validation | Strict OpenAPI JSON typing and parameter schema checks | Prevents malformed API payloads or arbitrary database query injections. |
| Confirmation Interlocks | Interactive confirmation prompts before destructive actions | Ensures sensitive transactions (funds transfer, resource deletion) require explicit user consent. |
| Human-in-the-Loop (HITL) Routing | Automated escalation triggers based on sentiment or confidence | Automatically routes agitated customers or edge cases beyond the agent's confidence threshold to live staff. |
| Audit Logging & Tracing | Cloud Logging and Cloud Trace integration | Every internal thought, tool invocation payload, and observation is recorded for post-hoc regulatory auditing. |
Component Table: Anatomy of an Enterprise Gen AI Agent
| Component | Architectural Role | Configuration Method | Concrete Enterprise Example |
|---|---|---|---|
| Goals & Personas | Behavioral identity and operational scope | Natural language system prompts | "Corporate Benefits Concierge; courteous, concise, compliant with ERISA regulations." |
| Playbooks | Declarative workflow logic and state machine | Structured natural language instructions | Step-by-step guidance for employee parental leave application and manager sign-off. |
| Tools / Extensions | Read/write execution in external systems | OpenAPI 3.0 specifications / Cloud Functions | Workday API integration to check paid time off (PTO) balances and log leave requests. |
| Data Stores | Grounded informational factual retrieval | Agent Search connection | Unstructured PDF store of corporate employee benefit handbooks and dental insurance schedules. |
| Session State | Multi-turn entity tracking and context memory | Managed session store / parameter slots | Storing employee ID, selected leave start date, and return date across conversational turns. |
Strategic Leadership Guidance: Exam Tips & Common Pitfalls
[!TIP] Exam Tip: On the Google Cloud Generative AI Leader exam, pay careful attention to the operational verb in the question:
- If the system only needs to retrieve, summarize, and cite static information from corporate files, recommend Agent Search.
- If the system must take action, invoke external software APIs, query transactional databases, or complete multi-step workflows, recommend Agent Platform (leveraging Tools, Extensions, and Playbooks).
[!CAUTION] Common Pitfall: Never assume that agents operate purely autonomously without human oversight. Enterprise architectures mandate Human-in-the-Loop (HITL) controls for high-stakes decisions (such as credit denials, medical triage, or production database mutations). An agent in Agent Platform can execute routine tasks autonomously while systematically escalating complex or high-risk requests to human operators.
An enterprise development team is configuring an autonomous customer service agent using Agent Platform. The agent must verify customer shipment statuses in an external ERP database and cancel unshipped orders upon request. Which architectural component in Agent Builder connects the foundation model to these external transactional systems?
During a multi-step user interaction, a Agent Platform agent receives an open-ended request: 'Check my account tier, and if I am a Gold member, apply a 20% promotional discount to invoice INV-9042.' How does the ReAct (Reasoning + Acting) execution pattern enable the agent to fulfill this request?
A financial services institution is deploying an agent to assist clients with commercial loan applications. Federal lending compliance regulations mandate that loan approval decisions above $100,000 must undergo human loan officer review and cannot be granted autonomously under any circumstances. How should the institution configure this constraint within Agent Platform?