Files
wehub-resource-sync ec2b666284
Continuous Integration / Pre-commit Linter (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.10) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.11) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.12) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.10) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.11) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.12) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.14) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.10) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.11) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.12) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.13) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.14) (push) Waiting to run
Copybara PR Handler / close-imported-pr (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:25:13 +08:00

50 lines
1.8 KiB
Markdown

# Request Input Tool Sample
## Overview
This sample demonstrates how an LLM agent can proactively request clarification or confirmation from the user using the built-in `request_input` tool without losing its context/flow.
It showcases a highly realistic support assistant that dynamically constructs a JSON schema to only ask for missing details when creating IT support tickets.
## Sample Inputs
- `I want to file a technical ticket for a database crash.`
The agent will analyze the prompt, identify that the `title` and `category` are already provided, and dynamically call `request_input` with a schema requesting only `description` and `priority`.
- `File a priority HIGH technical ticket titled database crash explained as the MySQL server throwing OOM errors.`
The agent has all required details and will call `create_support_ticket` immediately without needing clarification.
## Graph
```mermaid
graph TD
User[User Prompt] --> Agent[Support Assistant Agent]
Agent -->|Needs Clarification| RequestInput[request_input tool]
RequestInput -->|User Response| Agent
Agent -->|All Details Gathered| CreateTicket[create_support_ticket tool]
```
## How To
This sample uses **Pattern B: Standalone Agents** with the `request_input` tool:
1. **Import `request_input`**:
```python
from google.adk.tools import request_input
```
1. **Add it to the LLM Agent's tools list**:
```python
root_agent = Agent(
name="support_assistant_agent",
tools=[create_support_ticket, request_input],
...
)
```
When the LLM decides it needs clarification, it calls `request_input` with a question and a dynamic `response_schema`. The ADK framework automatically intercepts this, yields a long-running interrupt to the client, and injects the user's reply back as a `FunctionResponse` into the LLM's chat history.