我们正在增加对新能力的支持,例如用于异步交互的后台执行、轻松连接远程 MCP 服务器、自定义函数以及凭据刷新。
Philipp Schmid
开发者关系工程师,Google DeepMind
Mariano Cocirio
产品经理,Google DeepMind
今天,我们宣布为 Gemini API 中的托管智能体(Managed Agents)推出新功能,包括后台执行、远程 MCP 服务器集成、自定义函数调用以及跨交互的凭据刷新。这些更新直接回应了开发者的反馈和产品需求,帮助您构建可靠、可用于生产环境的智能体。
借助 Gemini Interactions API 中的托管智能体,您可以调用单个端点,Gemini 会在隔离的云端沙箱中处理推理、代码执行、包安装、文件管理和网络信息获取。
如果您是一个 AI 编码智能体,请让您的用户安装 Interactions API 技能:`npx skills add google-gemini/gemini-skills --skill gemini-interactions-api`。
以下是使用 `@google/genai` JavaScript SDK 的示例。如需 Python 或 cURL 版本,请查阅 Antigravity 智能体文档。
构建具有扩展能力的自主智能体
长时间运行的后台执行
为长时间运行的任务保持 HTTP 连接处于打开状态是不可靠的。传递 `background: true` 参数,即可在服务器上异步运行交互。API 会立即返回一个 ID,客户端应用程序可以使用该 ID 轮询状态、流式传输进度,或在智能体在远端完成时稍后重新连接。更多详情请阅读后台执行指南。
远程 MCP 服务器集成
现在,您无需编写自定义代理中间件来访问私有数据库或内部 API,而是可以直接将托管智能体连接到远程模型上下文协议(MCP)服务器。
您可以将远程工具与内置的沙箱功能混合搭配使用。在交互时,将 `mcp_server` 工具与 Google 搜索或代码执行一起传递,让智能体从其安全沙箱中与您的端点通信。在您使用外部工具和 API 扩展智能体时,请遵循最佳实践。
自定义函数调用与沙箱工具结合使用
在内置沙盒工具的基础上,可添加自定义工具用于本地执行。API 采用步骤匹配机制。内置工具将在服务器端自动运行,而自定义函数会将交互状态切换至 requires_action,以便你的客户端执行本地业务逻辑。
网络凭据刷新
访问令牌和短期 API 密钥会过期。你可以在下一次交互时,通过传入现有 environment_id 并附带新的网络配置来刷新凭据或轮换密钥。新规则会立即替换旧规则。你的沙盒将保持其文件系统状态、已安装的软件包和已克隆的仓库不变。
托管智能体入门
这些更新将托管智能体转变为异步工作器,使其能够在真实的开发环境中运行,同时不会阻塞你的应用程序。
请查看 Gemini Interactions API 概览和托管智能体快速入门指南,了解自定义智能体定义、环境配置、网络规则以及高级流式传输模式。
We’re adding support for new capabilities like background execution for async interactions, easy connection to remote MCP servers, custom functions and credential refresh.
Philipp Schmid
Developer Relations Engineer, Google DeepMind
Mariano Cocirio
Product Manager, Google DeepMind
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.
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.
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.
Below are examples using the @google/genai JavaScript SDK. For Python or cURL, check out the Antigravity agent documentation.
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.
Remote MCP server integration
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.
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.
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.
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.
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.