Expanding Managed Agents in Gemini API: background tasks, remote MCP and more
Google DeepMind has officially unveiled a suite of powerful upgrades for Managed Agents within the Gemini API, marking a significant step forward for developers aiming to deploy robust, production-grade AI agents. By introducing features such as asynchronous background execution, seamless integration with remote Model Context Protocol (MCP) servers, and refined credential management, Google is providing the infrastructure necessary to move beyond simple chat interfaces into the realm of autonomous, long-running task execution.
Elevating Agent Reliability and Performance
The core philosophy behind Managed Agents in the Gemini Interactions API is to abstract away the heavy lifting of AI development. When developers utilize this API, they are essentially offloading the complexities of reasoning, code execution, environment management, and package installation to an isolated, secure cloud sandbox.
"These updates directly address developer feedback and product needs so you can build reliable, production-ready agents," noted Philipp Schmid and Mariano Cocirio of the Google DeepMind team.
To begin integrating these capabilities, developers can utilize the @google/genai SDK. For those building AI coding agents, the process is streamlined via the Interactions API skill, which can be added with a simple command: npx skills add google-gemini/gemini-skills --skill gemini-interactions-api.
Mastering Long-Running Background Execution
One of the most significant pain points in developing autonomous agents is the fragility of maintaining an open HTTP connection for tasks that require extended processing time. Previously, long-running operations were prone to timeouts and connection drops.
The new background execution feature solves this by allowing developers to pass background: true within their interaction requests. This shifts the process to an asynchronous model where the API immediately returns an interaction ID. Client applications can then poll for status updates, stream progress, or reconnect at a later time, ensuring that the agent continues its work in the cloud sandbox regardless of the client's connection state.
This capability is particularly useful for complex analytical tasks, such as cloning repositories, performing deep code audits, or generating comprehensive documentation reports, where the agent needs to operate independently of the user's immediate session.
Bridging the Gap with Remote MCP Integration
A major hurdle for enterprise AI adoption has been the difficulty of connecting agents to private databases or internal proprietary APIs. Historically, this required the development of cumbersome proxy middleware.
Google is now simplifying this architecture by enabling direct connections to remote Model Context Protocol (MCP) servers. Developers can now mix and match these remote tools with built-in sandbox capabilities. By defining an mcp_server tool alongside standard features like Google Search or code execution, agents can securely interface with internal endpoints while maintaining the integrity of the sandbox environment. This allows for a more modular approach to tool-calling, where agents can pull real-time telemetry or database insights directly into their reasoning loop.
Orchestrating Custom Functions and Sandbox Tools
The updated API introduces a sophisticated approach to step matching, allowing developers to combine built-in sandbox tools with custom domain-specific functions.
The workflow is designed for clarity:
- Built-in tools: These are executed automatically within the server-side sandbox.
- Custom functions: When the agent identifies a need for a custom function, the interaction transitions to a
requires_actionstate. This signals the client to execute the necessary business logic locally.
This hybrid approach ensures that sensitive or proprietary logic remains on the client side, while the agent handles the heavy lifting of file management and code execution in the cloud. Developers can easily filter for pending domain calls, execute their local database queries or API requests, and feed the results back into the interaction flow.
Dynamic Credential Refresh and Security
Security remains a top priority, especially when agents interact with external services that rely on short-lived API keys or access tokens. The new API updates allow for network credential rotation without losing the state of the agent's environment.
By providing an environment_id alongside a new network configuration, developers can refresh authorization headers mid-session. Crucially, this update does not reset the sandbox; the filesystem, installed packages, and cloned repositories remain intact, allowing for uninterrupted workflows even as security credentials rotate.
Getting Started
These enhancements transform Managed Agents from simple request-response tools into persistent, asynchronous workers capable of operating within real-world development environments. By reducing the friction associated with long-running tasks, internal tool integration, and security management, Google is enabling developers to build agents that are not just experimental, but truly functional.
For those looking to dive deeper, the following resources are recommended:
- Gemini Interactions API Overview: A comprehensive look at the architecture and capabilities.
- Managed Agents Quickstart: A hands-on guide to configuring custom agent definitions and network rules.
- Advanced Streaming Patterns: Documentation on optimizing the communication flow between your client and the Gemini sandbox.
As the ecosystem for AI agents continues to mature, these infrastructure-level improvements provide a stable foundation for developers to push the boundaries of what autonomous systems can achieve in production environments.