# Useful but Little-Known Features of ADK 2.0
🌍 How do you handle tasks that take minutes or hours within an agent workflow? ADK 2.0 has a dedicated class for exactly this.
ADK 2.0's `LongRunningFunctionTool` manages the orchestration of long-running tasks. The heavy computation runs on separate servers while the agent handles progress tracking and state transitions.
📌 Title: Long Running Function Tool
🔗 URL:
🧩 Overview
`LongRunningFunctionTool` is a class for integrating long-running tasks into agent workflows. It operates in four phases: initiation (kick off the task), initial updates (report progress), continue/wait (client decides the next action), and framework handling (the agent runner manages the pause). Crucially, this class manages orchestration — it does NOT execute the actual long-running task. The compute happens on separate servers.
🛠 How to use it
The tool function returns a dict with status and ticket ID, and the framework manages the state.
```python
from adk import LongRunningFunctionTool
def start_training(model_name: str, dataset: str) -> dict:
"""Start a model training job."""
# Send request to external server
ticket_id = external_api.start_job(model_name, dataset)
return {
"status": "in_progress",
"ticket_id": ticket_id,
"message": "Training started"
}
tool = LongRunningFunctionTool(func=start_training)
```
The agent runner pauses execution based on the returned state, and the client decides whether to continue or wait. The actual computation runs on a separate server — the tool function only handles progress checking and status reporting.
🏗 Building it into production
・Run actual heavy computation on dedicated compute servers; the tool function only makes API calls
・Build progress tracking with ticket IDs, using polling or webhooks for status updates
・Configure proper timeouts and error handling to detect task failures
・Implement continue/wait decision logic on the client side for smooth user experience
💡 Use cases
🤖 Manage and track ML model training jobs
🎬 Orchestrate time-consuming media processing like video encoding or rendering
📦 Run and monitor large-scale data ETL pipelines
🧪 Execute long-running test suites or benchmarks and retrieve results
⚠️ Watch out
`LongRunningFunctionTool` manages orchestration (state management and progress tracking), not the actual long-running task execution. Always run heavy computation on separate servers or services. Pay attention to session expiration and memory management — long-running tasks risk session disconnection, so consider persisting state externally.
✨ Seamlessly integrating long-running tasks into agent workflows is a powerful capability for building practical AI systems. Keep the separation between compute and orchestration clean.
#
ADK# #
AIAgent#