Expanding Managed Agents in Gemini API: background tasks, remote MCP and more
Expanding Managed Agents in Gemini API: background tasks, remote MCP and more
扩展 Gemini API 中的托管智能体:后台任务、远程 MCP 等
We’re adding support for new capabilities like background execution for async interactions, easy connection to remote MCP servers, custom functions and credential refresh. 我们正在增加对新功能的支持,例如用于异步交互的后台执行、与远程 MCP 服务器的轻松连接、自定义函数以及凭据刷新。
Today we’re announcing new capabilities for Managed Agents in Gemini API, including background execution, remote MCP server integration, custom function calling and refreshing credentials across interactions. These updates directly address developer feedback and product needs so you can build reliable, production-ready agents. 今天,我们宣布了 Gemini API 中托管智能体(Managed Agents)的新功能,包括后台执行、远程 MCP 服务器集成、自定义函数调用以及跨交互的凭据刷新。这些更新直接响应了开发者的反馈和产品需求,旨在帮助您构建可靠且可投入生产的智能体。
With managed agents in the Gemini Interactions API, you call a single endpoint and Gemini handles reasoning, code execution, package installation, file management and web information inside an isolated cloud sandbox. 通过 Gemini Interactions API 中的托管智能体,您只需调用一个端点,Gemini 即可在隔离的云沙箱中处理推理、代码执行、包安装、文件管理和网络信息。
If you are an AI coding agent, ask your human to install the Interactions API skill: npx skills add google-gemini/gemini-skills --skill gemini-interactions-api.
如果您是一个 AI 编程智能体,请让您的用户安装 Interactions API 技能:npx skills add google-gemini/gemini-skills --skill gemini-interactions-api。
Below are examples using the @google/genai JavaScript SDK. For Python or cURL, check out the Antigravity agent documentation. 以下是使用 @google/genai JavaScript SDK 的示例。如需 Python 或 cURL 示例,请查看 Antigravity 智能体文档。
Build autonomous agents with expanded capabilities
构建具备扩展能力的自主智能体
Long-running background execution 长时间运行的后台执行
Holding an HTTP connection open for long-running tasks is fragile. Pass background: true to run interactions asynchronously on the server. The API immediately returns an ID, which client applications can use to poll for status, stream progress, or reconnect later while the agent finishes remotely. For more details read the background execution guide.
为长时间运行的任务保持 HTTP 连接是脆弱的。通过传递 background: true,可以在服务器上异步运行交互。API 会立即返回一个 ID,客户端应用程序可以使用该 ID 来轮询状态、流式传输进度,或在智能体远程完成任务时重新连接。有关更多详细信息,请阅读后台执行指南。
Remote MCP server integration 远程 MCP 服务器集成
Instead of writing custom proxy middleware to access private databases or internal APIs, you can now connect managed agents directly to remote Model Context Protocol (MCP) servers. 现在,您无需编写自定义代理中间件来访问私有数据库或内部 API,即可将托管智能体直接连接到远程模型上下文协议(MCP)服务器。
You can mix and match remote tools with built-in sandbox capabilities. Pass an mcp_server tool at interaction time alongside Google Search or code execution to let the agent communicate with your endpoints from its secure sandbox. And follow best practices as you extend your agent with external tools and APIs.
您可以将远程工具与内置的沙箱功能混合使用。在交互时,除了 Google 搜索或代码执行外,还可以传递 mcp_server 工具,让智能体从其安全沙箱中与您的端点进行通信。在通过外部工具和 API 扩展智能体时,请遵循最佳实践。
Custom function calling alongside sandbox tools 与沙箱工具并行的自定义函数调用
Add custom tools alongside built-in sandbox tools for local execution. The API uses step matching. Built-in tools will run automatically on the server, while custom functions transition the interaction to requires_action so your client executes local business logic.
您可以添加自定义工具与内置沙箱工具并行,以进行本地执行。该 API 使用步骤匹配机制。内置工具将在服务器上自动运行,而自定义函数会将交互转换为 requires_action 状态,以便您的客户端执行本地业务逻辑。
Network credential refresh 网络凭据刷新
Access tokens and short-lived API keys expire. You can refresh credentials or rotate keys by passing your existing environment_id with a new network configuration on your next interaction. The new rules replace the old ones immediately. Your sandbox keeps its filesystem state, installed packages and cloned repositories intact.
访问令牌和短期 API 密钥会过期。您可以在下一次交互时,通过传递现有的 environment_id 和新的网络配置来刷新凭据或轮换密钥。新规则会立即替换旧规则。您的沙箱将保持其文件系统状态、已安装的包和克隆的存储库不变。
Get started with managed agents
开始使用托管智能体
These updates turn managed agents into asynchronous workers that operate inside real development environments without blocking your application. 这些更新将托管智能体转变为异步工作者,它们可以在真实的开发环境中运行,而不会阻塞您的应用程序。
Check out the Gemini Interactions API overview and the managed agents quickstart to explore custom agent definitions, environment configurations, network rules, and advanced streaming patterns. 查看 Gemini Interactions API 概述和托管智能体快速入门,探索自定义智能体定义、环境配置、网络规则和高级流式传输模式。