Tóm tắt
Google đang mở rộng Managed Agents trong Gemini API với bốn khả năng chính: background execution, tích hợp remote MCP server, custom function calling và refresh credential giữa các interaction. Mục tiêu là giúp dev build agent production-ready mà không phải tự quản lý toàn bộ sandbox, code execution, package install, file management và web access.
Trong Gemini Interactions API, client gọi một endpoint; Gemini xử lý reasoning và các thao tác trong isolated cloud sandbox. Các ví dụ hiện dùng SDK @google/genai cho JavaScript.
Background execution cho tác vụ lâu
Giữ HTTP connection mở cho một job dài là cách rất dễ lỗi. Với background: true, interaction chạy async trên server và API trả ngay một ID. Ứng dụng client có thể poll trạng thái, stream progress hoặc reconnect sau khi mất kết nối.
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Clone https://github.com/googleapis/js-genai, find all TODO comments in the source code, and categorize them by module and priority in a markdown report.",
environment: "remote",
background: true,
});
console.log(`Background task started. Interaction ID: ${interaction.id}`);
let result = interaction;
while (result.status === "in_progress") {
await new Promise((resolve) => setTimeout(resolve, 5000));
result = await client.interactions.get(interaction.id);
}
if (result.status === "completed") {
console.log("Task Completed:\n", result.output_text);
} else {
console.error(`Task ended with status: ${result.status}`);
}
Dev nên quan tâm vì pattern này phù hợp với các job kiểu audit repo, tạo report, chạy analysis hoặc xử lý file lớn, nơi request-response truyền thống không đủ bền.
Remote MCP server integration
Managed Agents giờ có thể kết nối trực tiếp tới remote Model Context Protocol server. Thay vì viết proxy middleware riêng để nối database nội bộ hoặc API riêng, bạn truyền tool mcp_server vào interaction cùng với tool built-in như Google Search hoặc code execution.
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Check our internal observability server for recent latency spikes in the auth service and correlate them with git commits.",
environment: "remote",
tools: [
{ type: "google_search" },
{ type: "code_execution" },
{
type: "mcp_server",
name: "internal_telemetry",
url: "https://mcp.internal.example.com/mcp",
},
],
});
console.log(interaction.output_text);
Điểm cần kiểm tra kỹ là security boundary: remote agent có thể gọi tool ngoài từ sandbox, nên MCP server phải có auth, allowlist và audit log rõ ràng.
Custom function calling cùng sandbox tools
Google cũng hỗ trợ custom function bên cạnh tool built-in. Tool phía server như code execution tự chạy trong sandbox; còn function nghiệp vụ riêng có thể chuyển interaction sang trạng thái requires_action để client thực thi logic local rồi gửi kết quả ngược lại.
const getWeatherTool = {
type: "function",
name: "get_weather",
description: "Gets the current weather for a given location.",
parameters: {
type: "object",
properties: {
location: {
type: "string",
description: "The city and country, e.g. San Francisco, USA",
},
},
required: ["location"],
},
};
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Check the weather in Tokyo, write a Python script to convert the temperature to Fahrenheit, and save the result to weather.txt.",
environment: "remote",
tools: [{ type: "code_execution" }, getWeatherTool],
});
Thiết kế này tách phần có thể chạy an toàn trong sandbox khỏi phần phải chạm vào hệ thống nội bộ của bạn.
Refresh credential giữa các interaction
Access token và API key ngắn hạn sẽ hết hạn. Với environment_id, bạn có thể truyền network configuration mới ở interaction sau để refresh token hoặc rotate key. Sandbox vẫn giữ filesystem state, package đã cài và repo đã clone.
Đây là chi tiết nhỏ nhưng quan trọng cho production: agent dài hơi không nên chết chỉ vì token cũ hết hạn giữa chừng.
Ý nghĩa với dev
Managed Agents đang chuyển từ khái niệm demo sang hạ tầng agent có trạng thái, tool access và vòng đời tác vụ rõ hơn. Nếu đang tự build agent runner, queue, sandbox và tool proxy, bản cập nhật này là thứ nên benchmark thực tế. Nhưng đừng bỏ qua phần vận hành: logging, permission, chi phí sandbox và giới hạn network vẫn là các câu hỏi cần đo trước khi đưa vào luồng production.