Chuyển đến nội dung
tinAI
Quay lại

Gemini API mở rộng Managed Agents: task chạy nền, remote MCP và credential refresh

Bản dịch tiếng Việt của tinAI · Từ Expanding Managed Agents in Gemini API: background tasks, remote MCP and more (blog.google) · Ngày gốc: · Dịch ngày:

Bài gốc: Expanding Managed Agents in Gemini API: background tasks, remote MCP and more (blog.google)

Tác giả: Google

Ngày đăng: Dịch ngày:

TL;DR

Google thêm background execution, remote MCP server, custom function calling và credential refresh cho Managed Agents trong Gemini API. Với Interactions API, agent có thể chạy như worker bất đồng bộ trong cloud sandbox thay vì phụ thuộc vào một request HTTP dài hơi.

Ước tính đọc: 2 phút

Có gì mới

Google mở rộng Managed Agents trong Gemini API với bốn nhóm khả năng mới: background execution, remote MCP server, custom function calling và refresh credential giữa các interaction. Mục tiêu là biến agent thành worker chạy trong cloud sandbox, thay vì một request HTTP dài hơi dễ timeout.

Với Gemini Interactions API, ứng dụng gọi một endpoint, còn Gemini xử lý reasoning, code execution, package installation, file management và web information trong sandbox tách biệt. Các ví dụ trong bài dùng JavaScript SDK @google/genai và agent antigravity-preview-05-2026.

npm install @google/genai

Thay đổi quan trọng

Background execution

Long-running task không còn phải giữ HTTP connection mở từ đầu đến cuối. Khi truyền background: true, API trả về interaction.id; client có thể poll trạng thái, stream tiến trình hoặc reconnect sau.

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}`);
}

Remote MCP server

Managed agents giờ có thể kết nối trực tiếp tới remote Model Context Protocol server. Thay vì tự viết proxy middleware để agent chạm vào database, observability hoặc internal API, bạn truyền tool mcp_server cùng với Google Search hoặc code execution.

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",
    },
  ],
});

Custom function calling

Custom function có thể chạy cạnh các sandbox tool built-in. Điểm cần nhớ: built-in tool chạy tự động phía server; custom function đưa interaction sang trạng thái requires_action để client thực thi business logic cục bộ rồi trả kết quả lại.

Refresh credential cho environment hiện có

Token ngắn hạn và API key hết hạn là chuyện bình thường. Gemini API cho phép truyền lại environment_id với network configuration mới; rule mới thay thế rule cũ ngay, còn filesystem state, package đã cài và repo đã clone vẫn được giữ trong sandbox.

Cách nâng cấp

Dev đang thử Managed Agents nên kiểm tra lại những đoạn tự viết quanh timeout, queue worker, MCP proxy và credential rotation. Một phần trong số đó có thể chuyển về Interactions API nếu workflow phù hợp với remote sandbox của Google.

Nhóm đang build agent nội bộ nên đọc thêm Interactions API overview và managed agents quickstart, đặc biệt là security best practices khi nối agent với remote MCP hoặc internal API. Dù API đã đỡ thô hơn, tên agent antigravity-preview-05-2026 vẫn là tín hiệu cần giữ lớp abstraction mỏng để dễ thay đổi khi preview đổi hành vi.


Đường dẫn nguồn

tinAI dịch bài này sang tiếng Việt từ Expanding Managed Agents in Gemini API: background tasks, remote MCP and more (blog.google) · Loại nguồn: web và giữ bối cảnh từ bản tin tinAI đã giới thiệu bài này .

Bản tin này có 2 bài dịch liên quan từ cùng bản tin.