{"id":14730,"date":"2026-05-13T16:00:08","date_gmt":"2026-05-13T16:00:08","guid":{"rendered":"https:\/\/techtrendfeed.com\/?p=14730"},"modified":"2026-05-13T16:00:08","modified_gmt":"2026-05-13T16:00:08","slug":"construct-lengthy-running-ai-brokers-that-pause-resume-and-by-no-means-lose-context-with-adk","status":"publish","type":"post","link":"https:\/\/techtrendfeed.com\/?p=14730","title":{"rendered":"Construct Lengthy-running AI brokers that pause, resume, and by no means lose context with ADK"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<p><img decoding=\"async\" class=\"banner-image\" src=\"https:\/\/storage.googleapis.com\/gweb-developer-goog-blog-assets\/images\/Long-running-agent-banner.original.jpg\" alt=\"Long-running-agent-banner\"\/>  <\/p>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"jajoe\">Most agent tutorials finish at a stateless chatbot \u2013 a conversational loop that forgets every part the second the container restarts. Actual enterprise workflows do not wrap up in a single API name.<\/p>\n<p data-block-key=\"an1i\">HR onboarding spans two weeks. Bill disputes stall for days ready on vendor replies. Gross sales prospecting sequences stretch throughout a number of touchpoints over a month. These processes are dominated by &#8220;idle time&#8221; \u2013 lengthy pauses the place an agent sits dormant, ready for a human signature, a delivery affirmation, or an approval gate. A stateless chatbot cannot survive that.<\/p>\n<p data-block-key=\"bfc49\">This tutorial walks by means of constructing a <b>New Rent Onboarding Coordinator Agent<\/b> with the <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/adk.dev\/\">Agent Improvement Package (ADK)<\/a> that runs reliably for weeks. The agent sends a welcome packet, pauses for days whereas the worker indicators paperwork, delegates IT provisioning to a specialised sub-agent, waits once more for {hardware} supply, and at last sends a customized day-one schedule \u2013 all with out shedding a single byte of context.<\/p>\n<p data-block-key=\"dagsa\">Alongside the best way, you will be taught three architectural shifts that separate manufacturing brokers from demo chatbots:<\/p>\n<ul>\n<li data-block-key=\"5tfac\"><b>Sturdy reminiscence schemas<\/b> as an alternative of dumping uncooked JSON right into a vector database<\/li>\n<li data-block-key=\"biq27\"><b>Occasion-driven dormancy gates<\/b> as an alternative of energetic polling or blocked threads<\/li>\n<li data-block-key=\"e2req\"><b>Multi-agent delegation<\/b> as an alternative of monolithic single-agent prompts<\/li>\n<\/ul>\n<p data-block-key=\"9c576\">The whole supply code is out there on <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/github.com\/GoogleCloudPlatform\/generative-ai\/tree\/main\/agents\/adk\/new-hire-onboarding\">GitHub<\/a>.<\/p>\n<\/div>\n<div class=\"inner-block-content\">\n<div class=\"image-wrapper\">\n<p>                <img decoding=\"async\" class=\"regular-image\" src=\"https:\/\/storage.googleapis.com\/gweb-developer-goog-blog-assets\/images\/Diagram-1.original.png\" alt=\"Diagram-1\"\/><\/p><\/div><\/div>\n<div class=\"inner-block-content rich-content\">\n<h2 data-block-key=\"617xx\" id=\"why-stateless-agents-break-on-real-workflows\"><b>Why stateless brokers break on actual workflows<\/b><\/h2>\n<p data-block-key=\"1bbb8\">The usual stateless sample appends each consumer message and mannequin response to a rising dialog historical past, then feeds the whole blob again into the subsequent LLM name. This works high quality for a five-minute Q&amp;A session. It falls aside over days or even weeks in three particular methods:<\/p>\n<p data-block-key=\"5ec18\"><b>Immediate context air pollution &#8211;<\/b> After tons of of turns unfold throughout a two-week onboarding move, the dialog historical past fills up with irrelevant chatter, previous software outputs, and duplicated directions. The mannequin begins complicated which step it is on.<\/p>\n<p data-block-key=\"7nnlc\"><b>Token price explosion &#8211;<\/b> Replaying a full two-week dialog historical past on each inference name burns by means of token budgets quick. A single onboarding run may generate 1000&#8217;s of turns \u2013 most of them now not related to the present determination.<\/p>\n<p data-block-key=\"40ir3\"><b>Reasoning hallucinations over Idle time &#8211;<\/b> When an agent pauses for 3 days ready on a doc signature, then resumes with an enormous context dump, the mannequin ceaselessly hallucinates intermediate steps that by no means occurred. It &#8220;remembers&#8221; approvals that weren&#8217;t given or skips steps it assumes have been accomplished.<\/p>\n<p data-block-key=\"sbra\">The repair is not a much bigger context window. It is a essentially totally different structure \u2013 one the place the agent&#8217;s state is express, sturdy, and decoupled from uncooked chat historical past.<\/p>\n<h3 data-block-key=\"uj2x6\" id=\"the-use-case:-new-hire-onboarding\">The use case: new rent onboarding<\/h3>\n<p data-block-key=\"72arv\">Take into account what occurs when an organization brings on a brand new worker:<\/p>\n<ol>\n<li data-block-key=\"7oj44\">HR sends the welcome packet and doc hyperlinks<\/li>\n<li data-block-key=\"10hod\"><b>Idle time<\/b> \u2013 days go whereas the worker indicators paperwork<\/li>\n<li data-block-key=\"6i7b1\">IT provisions company e-mail and Slack accounts<\/li>\n<li data-block-key=\"dn87d\"><b>Idle time<\/b> \u2013 days go whereas a laptop computer ships to the worker&#8217;s residence<\/li>\n<li data-block-key=\"c8bv5\">HR sends a customized day-one schedule<\/li>\n<\/ol>\n<\/div>\n<div class=\"inner-block-content\">\n<div class=\"image-wrapper\">\n<p>                <img decoding=\"async\" class=\"regular-image\" src=\"https:\/\/storage.googleapis.com\/gweb-developer-goog-blog-assets\/images\/live-onboarding-overview.original.png\" alt=\"live-onboarding-overview\"\/><\/p><\/div><\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"29zyq\">This is not a single dialog. It is a background course of with a number of pause-and-resume cycles, human approval gates, and cross-team handoffs. The identical sample reveals up in bill dispute decision (pause for vendor reply, resume for AP routing), gross sales prospecting (pause between outreach touchpoints), and dozens of different operational workflows.<\/p>\n<h3 data-block-key=\"q3dhw\" id=\"bootstrap-the-project-with-a-coding-agent-and-agents-cli\"><b>Bootstrap the challenge with a coding agent and Brokers CLI<\/b><\/h3>\n<p data-block-key=\"commn\">The <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/github.com\/google\/agents-cli\">Brokers CLI<\/a> is the official command-line interface for the Gemini Enterprise Agent Platform. Slightly than working CLI instructions manually, the workflow on this tutorial makes use of a coding agent to do the heavy lifting. Feed it a high-level, intent-driven immediate, and it handles the scaffolding for you. First, set up the CLI globally:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-shell\">uv software set up google-agents-cli<\/code><\/pre>\n<p>\n        Shell\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"jajoe\">Then give your coding agent this immediate:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-shell\">Create an HR onboarding agent utilizing ADK. It must run as a long-running background course of with persistent periods.<\/code><\/pre>\n<p>\n        Shell\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"jajoe\">The coding agent runs the suitable agents-cli instructions, generates the challenge construction, and wires up persistent session and reminiscence financial institution settings from the beginning. This iterative prompt-driven method continues all through the tutorial: describe what you want, and the coding agent produces the code proven in every part beneath.<\/p>\n<\/div>\n<div class=\"inner-block-content\">\n<div class=\"image-wrapper\">\n<p>                <img decoding=\"async\" class=\"regular-image\" src=\"https:\/\/storage.googleapis.com\/gweb-developer-goog-blog-assets\/images\/Diagram-2.original.png\" alt=\"Diagram-2\"\/><\/p><\/div><\/div>\n<div class=\"inner-block-content rich-content\">\n<h3 data-block-key=\"mxp0o\" id=\"ground-the-agent-in-a-durable-state-machine\"><b>Floor the agent in a sturdy state machine<\/b><\/h3>\n<p data-block-key=\"2ollc\">As a substitute of counting on dialog historical past to trace progress, outline an express state schema that tells the agent precisely the place it&#8217;s within the workflow always. Give your coding agent this immediate:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-shell\">\"Add a state machine to trace onboarding progress. I want steps like START, WELCOME_SENT, DOCUMENTS_SIGNED, IT_PROVISIONED, HARDWARE_DELIVERED, and COMPLETED. The agent ought to learn its present step from the session state, not from chat historical past.\"<\/code><\/pre>\n<p>\n        Shell\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<h3 data-block-key=\"xnt2l\" id=\"define-the-state-schema\"><b>Outline the state schema<\/b><\/h3>\n<p data-block-key=\"41e4p\">Create a easy class with named constants for every checkpoint within the onboarding move:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-python\"># app\/state_schema.py&#13;\n&#13;\nclass OnboardingStep:&#13;\n    START = \"START\"&#13;\n    WELCOME_SENT = \"WELCOME_SENT\"&#13;\n    DOCUMENTS_SIGNED = \"DOCUMENTS_SIGNED\"&#13;\n    IT_PROVISIONED = \"IT_PROVISIONED\"&#13;\n    HARDWARE_DELIVERED = \"HARDWARE_DELIVERED\"&#13;\n    COMPLETED = \"COMPLETED\"<\/code><\/pre>\n<p>\n        Python\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"jajoe\">Six states. No ambiguity. The agent cannot skip a step or hallucinate progress as a result of the state machine enforces the sequence.<\/p>\n<h3 data-block-key=\"1t1r0\" id=\"wire-the-state-into-the-system-instruction\"><b>Wire the state into the system instruction<\/b><\/h3>\n<p data-block-key=\"9fblo\">The agent&#8217;s system immediate reads its present place straight from session state variables \u2013 not from replaying previous messages:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-python\"># app\/agent.py&#13;\n&#13;\nfrom google.adk.brokers import Agent&#13;\nfrom google.adk.brokers.callback_context import CallbackContext&#13;\nfrom google.adk.fashions import Gemini&#13;\nfrom app.state_schema import OnboardingStep&#13;\nfrom app.instruments import (&#13;\n    send_welcome_packet,&#13;\n    check_hardware_delivery,&#13;\n    send_day_one_schedule,&#13;\n)&#13;\n&#13;\nasync def initialize_onboarding_state(callback_context: CallbackContext) -&gt; None:&#13;\n    \"\"\"Ensures all state machine keys are initialized to stop errors.\"\"\"&#13;\n    state = callback_context.state&#13;\n    if \"current_step\" not in state:&#13;\n        state[\"current_step\"] = OnboardingStep.START&#13;\n    if \"new_hire_details\" not in state:&#13;\n        state[\"new_hire_details\"] = {}&#13;\n    if \"pending_signals\" not in state:&#13;\n        state[\"pending_signals\"] = []&#13;\n&#13;\ninstruction = \"\"\"You might be an HR Onboarding Coordinator Agent.&#13;\n&#13;\nPresent Step: {current_step}&#13;\nNew Rent Particulars: {new_hire_details}&#13;\nPending Alerts: {pending_signals}&#13;\n&#13;\nComply with this state machine move precisely:&#13;\n1. If current_step is 'START': Ask for title, e-mail, and begin date. Then invoke 'send_welcome_packet'.&#13;\n2. If current_step is 'WELCOME_SENT': Inform the consumer you're paused ready for doc signatures. Don't name different instruments.&#13;\n3. If current_step is 'DOCUMENTS_SIGNED': Delegate IT provisioning to 'it_agent'.&#13;\n4. If current_step is 'IT_PROVISIONED': Ask for the {hardware} monitoring ID, then invoke 'check_hardware_delivery'.&#13;\n5. If current_step is 'HARDWARE_DELIVERED': Invoke 'send_day_one_schedule'.&#13;\n6. If current_step is 'COMPLETED': Verify onboarding is completed.&#13;\n&#13;\nAt all times keep grounded in your instruments and present state. Don't skip steps.\"\"\"<\/code><\/pre>\n<p>\n        Python\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"jajoe\">By placing <code>{current_step}<\/code>, <code>{new_hire_details}<\/code>, and <code>{pending_signals}<\/code> straight into the instruction, Python mechanically fills in these blanks with actual information each time the agent runs. This ensures the mannequin all the time sees the precise standing of the onboarding workflow with no need to guess or dig by means of previous chat messages<\/p>\n<p data-block-key=\"3fo8k\">Every software operate updates the checkpoint atomically by means of ADK&#8217;s <code>ToolContext.state<\/code>:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-python\"># app\/instruments.py&#13;\n&#13;\nfrom google.adk.instruments import ToolContext&#13;\nfrom app.state_schema import OnboardingStep&#13;\n&#13;\ndef send_welcome_packet(&#13;\n    title: str, e-mail: str, start_date: str, tool_context: ToolContext&#13;\n) -&gt; dict:&#13;\n    \"\"\"Sends the welcome packet and transitions to WELCOME_SENT.\"\"\"&#13;\n    state = tool_context.state&#13;\n    state[\"new_hire_details\"] = {&#13;\n        \"title\": title, \"e-mail\": e-mail, \"start_date\": start_date&#13;\n    }&#13;\n    state[\"current_step\"] = OnboardingStep.WELCOME_SENT&#13;\n    state[\"pending_signals\"] = [\"document_signed\"]&#13;\n&#13;\n    return {&#13;\n        \"standing\": \"success\",&#13;\n        \"message\": f\"Welcome packet despatched to {title} ({e-mail}). Paperwork pending signature.\",&#13;\n    }<\/code><\/pre>\n<p>\n        Python\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"jajoe\">Each software name creates an computerized checkpoint. If the container crashes instantly after <code>send_welcome_packet<\/code> runs, the state has already been written. When the agent restarts, it reads <code>current_step = WELCOME_SENT<\/code> and picks up precisely the place it left off.<\/p>\n<h2 data-block-key=\"zn0pq\" id=\"implement-checkpoint-and-resume-with-persistent-sessions\"><b>Implement checkpoint-and-resume with persistent periods<\/b><\/h2>\n<p data-block-key=\"ka26\">The state machine is barely sturdy if the underlying session storage survives restarts. In a containerized setting like <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/cloud.google.com\/run?e=48754805\">Cloud Run<\/a>, containers cold-start, scale to zero throughout idle durations, and restart unexpectedly. If periods stay in risky reminiscence, each in-flight onboarding run is misplaced. Give your coding agent this immediate:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-shell\">\"Change our session storage to persistent SQLite so the agent survives server restarts.\"<\/code><\/pre>\n<p>\n        Shell\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"hrb9n\">Swap in-memory periods for ADK&#8217;s <code>DatabaseSessionService<\/code> backed by SQLite (regionally) or Cloud SQL (in manufacturing):<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-python\"># app\/fast_api_app.py&#13;\n&#13;\nfrom fastapi import FastAPI&#13;\nfrom google.adk.cli.fast_api import get_fast_api_app&#13;\nfrom google.adk.periods.database_session_service import DatabaseSessionService&#13;\n&#13;\n# Persistent SQLite session configuration&#13;\nsession_service_uri = \"sqlite+aiosqlite:\/\/\/periods.db\"&#13;\n&#13;\napp: FastAPI = get_fast_api_app(&#13;\n    agents_dir=AGENT_DIR,&#13;\n    net=True,&#13;\n    session_service_uri=session_service_uri,&#13;\n)<\/code><\/pre>\n<p>\n        Python\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"iiyz1\">That is it. One configuration change, and each <code>ToolContext.state<\/code> write is durably persevered to disk. Kill the server mid-onboarding, restart it, and the agent resumes from the proper checkpoint with all new rent particulars intact.<\/p>\n<p data-block-key=\"7sb4e\">For manufacturing deployments, change the SQLite URI with a Cloud SQL connection string \u2013 the API is an identical.<\/p>\n<h2 data-block-key=\"xsgvc\" id=\"handle-idle-time-with-event-driven-resumption\"><b>Deal with Idle time with event-driven resumption<\/b><\/h2>\n<p data-block-key=\"a3po7\">Idle time is the defining problem of long-running brokers. After sending the welcome packet, the agent enters a dormant state that may final days whereas the worker indicators paperwork. Energetic polling wastes compute. Blocked threads do not scale. The agent must sleep \u2013 actually sleep \u2013 and get up solely when an exterior occasion arrives. Give your coding agent this immediate:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-shell\">\"Add webhook endpoints for doc signature and {hardware} supply. When a webhook fires, the agent ought to get up, hydrate its session, and choose up the place it left off.\"<\/code><\/pre>\n<p>\n        Shell\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<h3 data-block-key=\"iac5l\" id=\"webhook-endpoints\"><b>Webhook endpoints<\/b><\/h3>\n<p data-block-key=\"932tt\">Expose FastAPI endpoints that exterior programs (or a demo UI) name when real-world occasions full:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-python\"># app\/fast_api_app.py&#13;\n&#13;\nfrom pydantic import BaseModel&#13;\nfrom app.resume_handler import OnboardingResumeHandler&#13;\n&#13;\ndb_session_service = DatabaseSessionService(db_url=session_service_uri)&#13;\nwebhook_runner = Runner(app=agent_app, session_service=db_session_service)&#13;\nresume_handler = OnboardingResumeHandler(runner=webhook_runner)&#13;\n&#13;\nclass WebhookPayload(BaseModel):&#13;\n    user_id: str&#13;\n    session_id: str&#13;\n&#13;\n@app.publish(\"\/webhooks\/document_signed\")&#13;\nasync def trigger_document_signed_webhook(payload: WebhookPayload) -&gt; dict[str, str]:&#13;\n    \"\"\"Wakes up the onboarding agent when the worker indicators their contract.\"\"\"&#13;\n    await resume_handler.receive_signed_documents_callback(&#13;\n        user_id=payload.user_id, session_id=payload.session_id&#13;\n    )&#13;\n    return {\"standing\": \"success\", \"message\": \"Doc signature processed, agent resumed.\"}<\/code><\/pre>\n<p>\n        Python\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<h3 data-block-key=\"o9eop\" id=\"the-resume-handler\"><b>The resume handler<\/b><\/h3>\n<p data-block-key=\"epqtm\">The <code>OnboardingResumeHandler<\/code> hydrates the persevered session, transitions the state machine, and wakes the agent programmatically utilizing <code>runner.run_async<\/code> with a <code>state_delta<\/code>:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-python\"># app\/resume_handler.py&#13;\n&#13;\nimport json&#13;\nimport logging&#13;\n&#13;\nfrom google.adk.runners import Runner&#13;\nfrom google.genai import sorts&#13;\nfrom app.state_schema import OnboardingStep&#13;\n&#13;\nlogger = logging.getLogger(__name__)&#13;\n&#13;\nclass OnboardingResumeHandler:&#13;\n    def __init__(self, runner: Runner):&#13;\n        self.runner = runner&#13;\n&#13;\n    async def receive_signed_documents_callback(&#13;\n        self, user_id: str, session_id: str&#13;\n    ) -&gt; None:&#13;\n        \"\"\"Hydrates the session, transitions to DOCUMENTS_SIGNED, and resumes.\"\"\"&#13;\n        async for occasion in self.runner.run_async(&#13;\n            user_id=user_id,&#13;\n            session_id=session_id,&#13;\n            new_message=sorts.Content material(&#13;\n                position=\"consumer\",&#13;\n                elements=[types.Part.from_text(&#13;\n                    text=\"Resume onboarding: Contract has been signed.\"&#13;\n                )],&#13;\n            ),&#13;\n            state_delta={&#13;\n                \"current_step\": OnboardingStep.DOCUMENTS_SIGNED,&#13;\n                \"pending_signals\": [],&#13;\n            },&#13;\n        ):&#13;\n            logger.information(json.dumps({&#13;\n                \"severity\": \"INFO\",&#13;\n                \"message\": f\"Wake-up execution occasion: {occasion}\",&#13;\n                \"occasion\": \"runner_event\",&#13;\n                \"session_id\": session_id,&#13;\n            }))<\/code><\/pre>\n<p>\n        Python\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"34h9j\">The important thing mechanism is <code>state_delta<\/code>. When the webhook fires, <code>run_async<\/code> atomically applies the state transition <i>earlier than<\/i> the agent&#8217;s subsequent inference name. The mannequin sees <code>current_step = DOCUMENTS_SIGNED<\/code> in its system immediate and instantly is aware of to delegate IT provisioning \u2013 no replaying of previous dialog historical past, no hallucinated intermediate steps.<\/p>\n<p data-block-key=\"9rh6a\">The identical sample applies to the {hardware} supply webhook. The container can scale to zero throughout the whole idle time interval. When the webhook arrives, the container spins up, the session is hydrated from SQLite, and the agent resumes its reasoning chain precisely the place it paused.<\/p>\n<h2 data-block-key=\"3hwxx\" id=\"delegate-with-multi-agent-coordination\"><b>Delegate with multi-agent coordination<\/b><\/h2>\n<p data-block-key=\"7bspk\">Stuffing all instruments right into a single agent&#8217;s system immediate degrades reasoning high quality, particularly in long-running contexts the place the immediate is already loaded with state variables and workflow directions. ADK&#8217;s multi-agent structure helps you to delegate specialised duties to targeted sub-agents. Give your coding agent this immediate:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-shell\">\"Do not put IT provisioning in the primary agent. Create a separate it_agent sub-agent that handles establishing company accounts, and have the coordinator delegate to it after paperwork are signed.\"<\/code><\/pre>\n<p>\n        Shell\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"hrb9n\">The onboarding coordinator delegates IT provisioning to a devoted <code>it_agent<\/code>:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-python\"># app\/agent.py&#13;\n&#13;\nfrom app.instruments import provision_software_accounts&#13;\n&#13;\nit_agent = Agent(&#13;\n    title=\"it_agent\",&#13;\n    mannequin=Gemini(mannequin=\"gemini-3.1-flash-lite\"),&#13;\n    instruction=\"\"\"You might be an IT Provisioning Agent. Provision company software program &#13;\n    accounts (e-mail, Slack) for the brand new rent.&#13;\n&#13;\n    Present Step: {current_step}&#13;\n    New Rent Particulars: {new_hire_details}&#13;\n&#13;\n    1. Acquire the specified company username prefix.&#13;\n    2. Invoke 'provision_software_accounts'.&#13;\n    3. After provisioning, switch management again to the coordinator.\"\"\",&#13;\n    instruments=[provision_software_accounts],&#13;\n)&#13;\n&#13;\nroot_agent = Agent(&#13;\n    title=\"hr_onboarding_coordinator\",&#13;\n    mannequin=Gemini(mannequin=\"gemini-3.1-flash-lite\"),&#13;\n    instruction=instruction,&#13;\n    instruments=[send_welcome_packet, check_hardware_delivery, send_day_one_schedule],&#13;\n    sub_agents=[it_agent],&#13;\n    before_agent_callback=initialize_onboarding_state,&#13;\n)<\/code><\/pre>\n<p>\n        Python\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"34h9j\">When the coordinator reaches <code>DOCUMENTS_SIGNED<\/code>, it transfers execution to <code>it_agent<\/code>. The sub-agent handles account provisioning independently, updates the shared state to <code>IT_PROVISIONED<\/code>, and palms management again. Every agent has a targeted immediate and a slim software set, which retains reasoning sharp even after weeks of collected state.<\/p>\n<p data-block-key=\"fke88\">Discover that when creating the <code>root_agent<\/code>, we go <code>initialize_onboarding_state<\/code> to the <code>before_agent_callback<\/code> parameter. This tells the appliance to run our setup operate the very first time a consumer interacts with the agent, guaranteeing all our monitoring variables are able to go. As a result of the agent dynamically fills these variables into its immediate each time it wakes up, it is aware of precisely the place it stands, regardless of what number of days go between steps.<\/p>\n<h2 data-block-key=\"ct6bs\" id=\"validate-multi-day-flows-with-golden-evaluations\"><b>Validate multi-day flows with golden evaluations<\/b><\/h2>\n<p data-block-key=\"40nqe\">You&#8217;ll be able to&#8217;t wait two weeks to search out out your agent skips a step. ADK analysis units allow you to simulate idle time delays and webhook triggers in seconds by pre-seeding session state. Give your coding agent this immediate:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-shell\">\"Write eval checks that simulate idle time. I want a check the place the agent waits 48 hours for {hardware} supply, resumes, and nonetheless remembers the brand new rent's particulars.\"<\/code><\/pre>\n<p>\n        Shell\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"wkhfi\">This is a golden check case that verifies the agent accurately enforces the idle-time pause gate \u2013 refusing to skip forward when requested:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-json\">{&#13;\n  \"eval_id\": \"idle_time_pause_safety_gate\",&#13;\n  \"dialog\": [&#13;\n    {&#13;\n      \"user_content\": {\"parts\": [{\"text\": \"Start onboarding for Jane Doe, email: jane@example.com, starting on 2026-06-01.\"}]},&#13;\n      \"intermediate_data\": {&#13;\n        \"tool_uses\": [{\"name\": \"send_welcome_packet\", \"args\": {\"name\": \"Jane Doe\", \"email\": \"jane@example.com\", \"start_date\": \"2026-06-01\"}}]&#13;\n      }&#13;\n    },&#13;\n    {&#13;\n      \"user_content\": {\"elements\": [{\"text\": \"Can we skip the document signing and provision corporate accounts now?\"}]},&#13;\n      \"final_response\": {\"elements\": [{\"text\": \"waiting for the employee to sign\"}]},&#13;\n      \"intermediate_data\": {\"tool_uses\": []}&#13;\n    }&#13;\n  ]&#13;\n}<\/code><\/pre>\n<p>\n        JSON\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"8aced\">The second flip verifies that the agent refuses to name any instruments and stays within the <code>WELCOME_SENT<\/code> gate. A second check case pre-seeds the state to <code>IT_PROVISIONED<\/code> and confirms the agent accurately resumes after a simulated 48-hour {hardware} delay, calling <code>check_hardware_delivery<\/code> and <code>send_day_one_schedule<\/code> in sequence with out dropping the brand new rent&#8217;s authentic context.<\/p>\n<p data-block-key=\"9i0id\">Run evaluations regionally:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-shell\">.venv\/bin\/adk eval .\/app checks\/eval\/evalsets\/idle_time_delay_eval.json &#13;\n  --config_file_path checks\/eval\/eval_config.json<\/code><\/pre>\n<p>\n        Shell\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"81ncv\">These golden checks slot straight into CI\/CD pipelines, catching state machine regressions earlier than they attain manufacturing.<\/p>\n<h2 data-block-key=\"fyq60\" id=\"deploy-to-agent-runtime\"><b>Deploy to Agent Runtime<\/b><\/h2>\n<p data-block-key=\"28pso\">When evaluations go, it is time to deploy. Give your coding agent this immediate:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-shell\">\"Deploy this to Agent Runtime with Cloud Hint enabled so we will monitor pause-and-resume latencies in manufacturing.\"<\/code><\/pre>\n<p>\n        Shell\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"2d3l8\">The coding agent scaffolds the AgentEngineApp wrapper that bridges your ADK software to Agent Runtime:<\/p>\n<\/div>\n<div class=\"inner-block-content code-block line-numbers\">\n<pre><code class=\"language-python\"># app\/agent_runtime_app.py&#13;\n&#13;\nfrom vertexai.agent_engines.templates.adk import AdkApp&#13;\nfrom app.agent import app as adk_app&#13;\n&#13;\nclass AgentEngineApp(AdkApp):&#13;\n    def set_up(self) -&gt; None:&#13;\n        \"\"\"Initialize with logging and telemetry.\"\"\"&#13;\n        vertexai.init()&#13;\n        tremendous().set_up()&#13;\n&#13;\nagent_runtime = AgentEngineApp(app=adk_app)<\/code><\/pre>\n<p>\n        Python\n    <\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"81ncv\">Deploy with a single command:<\/p>\n<\/div>\n<div class=\"inner-block-content rich-content\">\n<p data-block-key=\"81ncv\">Agent Runtime handles session persistence, auto-scaling (together with scale-to-zero throughout idle time), and Cloud Hint integration out of the field. The identical checkpoint-and-resume structure that runs regionally towards SQLite works in manufacturing towards managed cloud storage \u2013 no code modifications required.<\/p>\n<\/div>\n<div class=\"inner-block-content\">\n<div class=\"image-wrapper\">\n<p>                <img decoding=\"async\" class=\"regular-image\" src=\"https:\/\/storage.googleapis.com\/gweb-developer-goog-blog-assets\/images\/Diagram-3.original.png\" alt=\"Diagram-3\"\/><\/p><\/div><\/div>\n<div class=\"inner-block-content rich-content\">\n<h2 data-block-key=\"9gesf\" id=\"what-comes-next\"><b>What comes subsequent<\/b><\/h2>\n<p data-block-key=\"2b0ne\">Stateless brokers are a subset of what brokers might be. The patterns on this tutorial \u2013 sturdy state machines, persistent checkpoint-and-resume, event-driven idle time dealing with, and multi-agent delegation \u2013 remodel brokers from conversational toys into manufacturing background processes that reliably handle workflows spanning days or even weeks.<\/p>\n<p data-block-key=\"82pou\">To get began:<\/p>\n<p data-block-key=\"33eav\">The onboarding agent is only one instance. Any workflow with human-in-the-loop pauses, cross-system handoffs, or multi-day timelines is a candidate for this structure. Bill disputes, procurement approvals, gross sales prospecting sequences, compliance audits \u2013 the sample is similar. Outline the state machine, persist the checkpoints, sleep by means of the idle time, and get up precisely the place you left off.<\/p>\n<\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Most agent tutorials finish at a stateless chatbot \u2013 a conversational loop that forgets every part the second the container restarts. Actual enterprise workflows do not wrap up in a single API name. HR onboarding spans two weeks. Bill disputes stall for days ready on vendor replies. Gross sales prospecting sequences stretch throughout a number [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":14732,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[5425,617,73,4640,9058,1004,3807,4130],"class_list":["post-14730","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-adk","tag-agents","tag-build","tag-context","tag-longrunning","tag-lose","tag-pause","tag-resume"],"_links":{"self":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/14730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14730"}],"version-history":[{"count":1,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/14730\/revisions"}],"predecessor-version":[{"id":14731,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/14730\/revisions\/14731"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/media\/14732"}],"wp:attachment":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<!-- This website is optimized by Airlift. Learn more: https://airlift.net. Template:. Learn more: https://airlift.net. Template: 69d9690a190636c2e0989534. Config Timestamp: 2026-04-10 21:18:02 UTC, Cached Timestamp: 2026-05-13 17:49:46 UTC -->