Inspiration

Monitoring and managing IaaS and PaaS and Saas offerings from vendors like DigitalOcean requires a wide range of domain knowledge and diverse skill sets. AI agents can automate much of this by connecting to MCP servers that provide tools based on the vendors’ API, like those provided by the MCP DigitalOcean Integration project. Toolsets based on large APIs like the DigitalOcean API however can consume a large number of input tokens before execution even begins. There are also limited ways to transform and filter the results of MCP tool calls before passing them through the model, or perform operations like aggregation, joins across multiple data sources, or select and extract specific fields, all of which increases the input token requirements. AI agents in general have far more training data for correct program generation in languages like JavaScript than for reasoning over tool usage for system administration tasks. As the context window size grows the possibility for the model performing system administration tasks to make mistakes using the API or misunderstand the user’s intentions or the consequences of an operation increases. Recent events have highlighted the dangers of AI-assisted changes to production infrastructure and deployments.

What it does

Donna is a .NET AI agent for monitoring and safely automating DigitalOcean system administration tasks. Donna provides an alternative approach to using traditional MCP servers to provide agents with access to the DigitalOcean API by allowing the agent to search documentation and generate code against a typed SDK in a modern language environment that also enforces safety constraints and restrictions on what the code can do.

Donna is implemented similarly to Cloudflare's Code Mode for accessing the Cloudflare API. The Donna agent has access to only two basic tools: a tool to search the Donna API specification (provided by a DigitalOcean knowledge base) and a tool to execute JavaScript against the API (provided by the Donna CLI.) The Donna API is a .NET binding the DigitalOcean OpenAPI v3 compatible API. The agent generates a complete JavaScript program to carry out the user's instructions and executes it using the embedded language interpreter tool without having to wait to process and reason over intermediate tool results.

Since using AI to execute code is always fraught with problems the Donna JavaScript interpreter has a number of safety constraints imposed on it:

  • No built-in modules or objects apart from those in the standard ECMAScript 2015 language spec.
  • No access to shell commands or local or network I/O. All API methods are just proxies to regular .NET methods which actually perform the network operations, but this is invisible to the JavaScript interpreter.
  • No access to ‘eval’ or other potentially unsafe JavaScript features.
  • Digital Ocean API methods that cause configuration changes require confirmation by the user.

This approach of allowing the agent to use code APIs instead of using direct tool calls has several advantages over regular MCP:

  • No large tool definitions that overload the context window
  • No need to pass intermediate tool results through the model
  • Context efficient API results can be transformed and filtered before processing by the model
  • More powerful and context-efficient control flow
  • Safeguards on API methods that are potentially destructive

This approach to AI agent system administration reduces significantly the total tokens required for using the DigitalOcean API compared to using MCP, while giving the agent access to the full capabilities and objects of the Digital Ocean API and a modern language runtime for which it has huge amounts of training data, while additionally enforcing safety constraints and guardrails against potentially insecure or unsafe or damaging operations. Reducing token usage and the 'cognitive load' on the agent is one approach to improving the safety of using AI agents for system administration. This code mode way of using an API may be overkill for single tool calls but can be better when the agent is required to orchestrate multiple tool calls.

The Donna agent can be accessed using a conversational user interface from the CLI via the netdo donna command. The search and execute tools can alternatively be exposed as an MCP server using the –mcp startup flag.

How we built it

netdo

netdo is a set of libraries that makes DigitalOcean IaaS and PaaS and Gradient AI services available to .NET developers. netdo provides C# bindings for the DigitalOcean OpenAPIv3 HTTP API as well as a higher-level library for integrating Gradient AI services with .NET agent libraries and frameworks like Microsft.Extensions.AI and Microsoft Agent Framework Microsoft Agent Framework via netdo allows .NET developers to develop agentic AI applications using Gradient AI agent hosting and knowledge bases and observability and other feature. See the netdo source and examples for more info.

.NET

Donna is is a CLI application written in NET and C#. It uses the Jint library which provides an ECMAScript 2024 JavaScript engine written in C# and designed to be embedded in .NET applications to script .NET code. The Donna agent is implemented using netdo and the Microsoft Agent Framework connecting to the private OpenAI-compatible endpoint of a Gradient AI hosted agent.

Gradient AI Agent Platform

The Gradient AI Agent Platform hosts the Donna agent together with the model, parameters, and system instructions and allows its responses to be quickly tested in the agent playground. The platform automatically provides the 'search' tool required by agent code generation by automatically searching a knowledge base on agent queries. Clients interact with the Donna agent via its OpenAPI-compatible private endpoint.

Gradient AI Knowledge Base

A Gradient AI knowledge base indexes the Donna JavaScript API specification that is used as the reference for code generation for the DigitalOcean API and provides efficient and accurate searching of the methods and types required for code generation. Using a knowledge base means only the parts of the specification relevant to the user's query must be introduced into the context. When other agents use the Donna MCP server it queries the knowledge base to assist them in the code generation process.

DigitalOcean Object Spaces

The Donna API specification is stored in a DigitalOcean Object Spaces bucket

Accomplishments that we're proud of

I was able to implement an experimental approach to solving a common industry concern for agentic AI development.

What we learned

I learned a great deal about DigitalOcean and Gradient AI and and it was a lot of fun implementing my own agentic AI CLI host.

Built With

Share this project:

Updates