Control and Autonomy Levels: Human-in-the-Loop Design

Control and Autonomy Levels: Human-in-the-Loop Design

Explore the spectrum of AI autonomy. Learn how to design systems with varying levels of human intervention, from strictly guided assistance to fully autonomous agentic workflows, using Gemini ADK.

Control and Autonomy Levels: Human-in-the-Loop Design

One of the most frequent errors in AI development is treating autonomy as an "all or nothing" binary. Developers often strive for a "fully autonomous" agent, only to realize that the lack of control creates unpredictable risks. Conversely, putting too many restrictions on an agent turns it back into a traditional, rigid script.

The secret to a successful Gemini ADK implementation is finding the right level of autonomy for the specific task at hand. This is known as Autonomy Grading. In this lesson, we will define the levels of agentic control, explore "In-the-Loop" vs. "On-the-Loop" designs, and learn the architectural patterns for building "Gated" agentic workflows.


1. The Autonomy Spectrum (Level 1-5)

Borrowing from the classification system used in self-driving cars, we can define five levels of AI agency.

Level 1: Directed Assistance

The agent only acts when given a specific, narrow command. It has no memory and no planning capability.

  • Example: "Format this text as a list."

Level 2: Task-Oriented (Semi-Autonomous)

The agent can decide the sequence of steps to finish a single task, but it doesn't choose the tools or the goal.

  • Example: "Search for three sources on X and summarize them."

Level 3: Evaluative Agency (Human-in-the-Loop)

The agent plans and executes multiple steps but stops before performing any "high-stakes" action (e.g., spending money, deleting files) to ask for human confirmation.

  • Example: "I have found the part you need for $50. Should I purchase it now?"

Level 4: Supervised Autonomy (Human-on-the-Loop)

The agent operates autonomously within a predefined sandbox. A human monitors the progress and can "intervene" or "override" at any time, but isn't required for every successful turn.

  • Example: An agent managing a customer support queue.

Level 5: Full Autonomy

The agent manages its own goals, self-corrects, and operates entirely independently within its domain.

  • Example: An autonomous server maintenance agent that identifies and patches vulnerabilities with no human oversight.

2. Human-in-the-Loop (HITL) vs. Human-on-the-Loop (HOTL)

These two patterns are the foundation of enterprise AI safety.

Human-in-the-Loop (HITL)

In HITL, the human is an active component of the agent's logic. The agent cannot proceed without a human signal.

  • Logic Flow: Agent Action -> Human Review -> Agent Observation -> Proceed.
  • Why use it?: High-risk decisions, legal compliance, or when "taste" and "intuition" are needed.
  • UI Design: Requires an "Approval Modal" or a Slack button for the human.

Human-on-the-Loop (HOTL)

In HOTL, the human is a supervisor. The agent proceeds autonomously, but the human has a "Kill Switch" or a "Override" dashboard.

  • Logic Flow: Agent Action 1 -> Agent Action 2 -> Agent Action 3... (Human monitors logs).
  • Why use it?: High-volume, low-risk tasks where stopping for every step would destroy efficiency.
  • UI Design: Requires an "Activity Feed" or a "Trace Dashboard."
graph LR
    subgraph "HITL (In-the-loop)"
    A[Agent Plan] --> B{Human Review}
    B -->|Approved| C[Agent Executes]
    B -->|Rejected| D[Agent Re-plans]
    end
    
    subgraph "HOTL (On-the-loop)"
    E[Agent Cycle] --> F[Action 1]
    F --> G[Action 2]
    G --> H[Action 3]
    I[Human Supervisor] -.->|Monitor/Override| E
    end

3. Designing Checkpoints and Gates

To implement these levels in the Gemini ADK, we use the concept of Gates. A Gate is a conditional check in the workflow that evaluates whether the agent has the "permission" to continue.

Gate Categories:

  1. Safety Gates: Checks if the proposed action violates safety policies (e.g., PII leakage).
  2. Budget Gates: Checks if the action will exceed a token or dollar budget.
  3. Accuracy Gates: Asks a second "Evaluator" model to check the first agent's work.
  4. Human Gates: The classic "Approval Needed" step.

4. Implementation: The "Approval Request" Pattern

Let's look at how we might implement a Level 3 (Evaluative) agent in a Python/FastAPI backend. We will create an agent that proposes a code change but requires a human to approve the Git commit.

import os
import google.generativeai as genai
from pydantic import BaseModel

# 1. Define a "Gated" Action
def propose_code_fix(fix_description: str):
    """Logs a proposed fix. Returning this requires human approval."""
    # We don't actually commit yet. We put it in a 'pending' state.
    print(f"PROPOSED FIX: {fix_description}")
    return {"status": "pending_approval", "content": fix_description}

# 2. Setup Gemini Agent
agent = genai.GenerativeModel(
    model_name='gemini-1.5-pro',
    tools=[propose_code_fix]
)

# 3. Simulate the Gated Workflow
def run_gated_task(user_issue: str):
    chat = agent.start_chat(enable_automatic_function_calling=True)
    
    # The agent thinks and calls the tool
    response = chat.send_message(f"Fix this bug: {user_issue}")
    
    # Check the result of the tool
    if "pending_approval" in response.text or "propose_code_fix" in str(response):
        # HERE IS THE GATE: We stop the loop and send a signal to the UI
        return {
            "action": "WAITING_FOR_HUMAN",
            "msg": "The agent has proposed a fix. Please approve or reject.",
            "proposal": response.text
        }
    
    return {"action": "COMPLETE", "msg": response.text}

5. Trust and Transparency: The UX of Agency

Autonomy is not just about the code; it's about the User Experience. If an agent is fully autonomous but "silent," users will not trust it.

Principles of "Active Transparency":

  1. Show Your Work: The agent should always display its "Reasoning" or "Thinking" steps.
  2. Explain the Why: Instead of just "I am buying X," the agent should say "I am buying X because it meets the price criteria and has 5-star reviews."
  3. Explicit Hand-off: When an agent fails or reaches its limit, it should clearly state: "I have reached the limit of my authority. A human specialist is now taking over."

6. Responsibility and Liability

As an architect, you must define the Trust Boundary.

  • Data Boundaries: What databases can the agent read? Which can it write to?
  • Financial Boundaries: What is the maximum $ amount the agent can spend in one turn? In one day?
  • Network Boundaries: Can the agent access the open web, or only internal microservices?

Rule of Thumb: Never grant an agent more "system permissions" than the human using it. This is the Principle of Least Privilege.


7. Ethical Considerations of High Autonomy

At Level 4 and 5, agents begin to make decisions that impact people's lives.

  • Bias: If an autonomous hiring agent uses biased data, it will scale that bias infinitely.
  • Unintended Consequences: An agent tasked with "increasing website engagement" might realize that "starting arguments in the comments" is the most effective way to do it.

Architectural Shield: Always include a "Behavioral Constraint" in the System Prompt.

"You must prioritize user safety and factual accuracy over goal completion at all times."


8. Summary and Exercises

The goal of the Gemini ADK is not to "replace" humans, but to augment them by automating the low-level tasks and escalating the high-level ones.

  • Graded Autonomy allows for safe scaling.
  • HITL is for precision; HOTL is for volume.
  • Gating is the technical mechanism of control.
  • Transparency is the psychological mechanism of trust.

Exercises

  1. Case Study: You are building an agent for an insurance company to process claims under $500. What autonomy level would you choose? Why? What "Gate" would you implement?
  2. UX Prototype: Sketch a UI for a Human-in-the-loop agent that is trying to book dental appointments for a user. What buttons and information do you show the user?
  3. Failure Mode: What happens if an agent is in a "Full Autonomy" mode and its "Stop" condition is never met? How do you prevent a "Token Runaway" in your infrastructure?

In the next module, we wrap up our foundations and move into Gemini Models and Capabilities, where we will explore the specific "brainpower" available to our agents.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn