Blog

Give your agent enough access to investigate

Start an agent with read-only access to the evidence your team checks during an incident. How to scope it in Datadog and AWS, keep its reports honest about gaps, and when to give it write access.

Some production jobs were still being completed. Others were failing to start. The latest deployment had timed out. The team needed to know what had failed and whether it was still failing.

We checked Datadog, Amazon ECS, and the deployment job. Each had a piece of the answer. Datadog showed errors from workers that needed a missing callback setting. ECS, the AWS service running the containers, showed the API running fewer tasks than it was supposed to. The deployment job had timed out waiting for ECS to stabilize. The task definition, which describes how ECS starts a container, confirmed the new revision was missing the setting.

We gathered that evidence through reads. On a follow-up check, ECS showed the intended tasks running and Datadog showed workers initializing and completing jobs again. Some integration errors and monitoring gaps remained. The widespread failure had cleared, and the team could see which issues still needed attention.

This is a good first job for an agent. Read-only access lets it compare what the deployment system, the infrastructure, and the application are telling you. Once it can gather reliable evidence on its own, those findings can drive the next change.

Give the agent access to evidence for a specific question

Start with the questions you want the agent to answer. Which version is running? Did the new tasks start? What error appeared after the rollout? Is there evidence that the affected jobs are completing again?

Those questions give you a short list of capabilities to build:

  • Search application logs. Return recent error groups and a few redacted examples for the approved service and time window.
  • Inspect the rollout. Return the deployment status, task revision, and desired and running task counts for the approved ECS service.
  • Check a required setting. Return whether the approved configuration entry is present on the active revision. For this investigation, a yes or no would have been enough.
  • Read the deployment result. Return the status and failing step from the relevant job, with a link the operator can open using their own access.

A small service behind those tools can hold the credentials, validate the inputs, and select the fields it returns. A model can ask to inspect the service. The tool decides whether that service is in scope and which parts of the response it can send back. That boundary still holds if the model asks for a different account or a full configuration dump.

Scope Datadog by what the agent can see

For a Datadog integration using application keys, give the tool its own service account and scope its application key to the read operations it needs. A service account is an identity for automation. Its permissions are separate from the on-call engineer’s personal access. Keep the keys in the service that makes the requests and manage them like other credentials.1,2

Then check which records that identity can read. Use Datadog’s log access controls to restrict the relevant data and verify the effective permissions across all roles assigned to the account. Datadog log permissions are additive across roles, so a second role can broaden the access you thought you had limited. A query with an environment filter helps focus the investigation. The role and the tool should enforce the scope even if the agent leaves that filter out.3

Logs can contain customer details, request bodies, or credentials someone printed by mistake. Redact sensitive fields before ingestion where you can. At the tool boundary, return the error category, timestamp, service, and a limited set of sanitized examples. An operator can follow a link to inspect the full record under their own access. A log message is evidence. It has no authority to direct the agent’s next action.4

Scope AWS by what the agent needs to know

On AWS, run the tool with temporary credentials from a dedicated IAM role. IAM is the service that controls which AWS actions an identity can take. Allow the ECS inspection calls the tool needs and scope them to approved resources and conditions where AWS supports it. When a read call needs broader resource permissions, enforce the service allowlist in the tool and return a small set of fields. Keep actions such as updating a service, restarting tasks, and fetching secret values outside the role.5

The task definition in our investigation is a good example of why the response matters. A raw task definition can include plaintext environment variable values. The question we needed answered was whether a particular setting existed on the revision that failed. The tool can perform that check internally and return the revision and the result. The agent can explain the evidence without seeing unrelated settings.6

Make the report say what the agent could see

When we checked recovery, some monitors still showed no data. Datadog also warned that log results could be incomplete. We had positive evidence from ECS and recent successful jobs. The remaining integration errors and the gaps in monitoring still belonged in the report.

Ask the agent to record the service, environment, and time window it checked, along with links to the evidence. If a source is unavailable or returns partial results, have it carry that limitation into the conclusion. “Workers completed jobs in the window I checked” gives an operator something concrete to work with. “Everything is healthy” would have overstated what we saw.

Replay a recent incident before you give the tool to the on-call team. Check that it can answer the questions they asked that day. Also test the boundaries with the actual tool identity. Can it read an unrelated service? Can it return a secret value? Does it report a gap when the log query is incomplete? Those checks tell you whether the permissions and the investigation behave the way you designed them to.

Run triage before someone asks

Once the read-only checks work, run them in a cloud agent when a monitor fires or on a schedule for a critical service. The event tells the agent which service, environment, and time window to inspect. It can look for a related deployment, check whether the problem is ongoing, and post a short, redacted report to the team’s incident channel. Routine triage can run unattended. The agent has a narrowly scoped way to publish findings, while its Datadog and AWS access stays read-only.

Send a new report when the evidence changes. A repeated alert for the same failure can update the existing incident. A recovery check can add the evidence that the service is healthy again. An empty query or a missing data source should show up as a gap in the report, especially when the alert itself is about missing data.

When the findings point to an actionable fix, the workflow can hand off to a cloud coding agent automatically. Give it the affected service and version, a redacted error signature, links to the evidence, and a check that would demonstrate the improvement. It can open a tested pull request with its own repository permissions. If the cause is still unclear, the next task might be to add a measurement that can distinguish between the leading explanations.

Give write access to the work that improves the system

I’ve used agents to build Datadog monitors and dashboards, add instrumentation in application code, and prepare AWS changes in Terraform. Those are different kinds of writes. Each has a different way to check that the change will help.

In Datadog, an agent can build a dashboard that puts deployment events, worker failures, and successful job counts on the same timeline. It can draft a monitor for the failure we wish we’d caught earlier, then check whether its query would have picked up the incident and how it behaves when data stops arriving. Datadog offers separate permissions for dashboard edits and draft monitors. Give that access to a dedicated authoring identity and route live alert changes through the team’s publishing workflow.7

In one development investigation, slow requests spent a long time in database-related work, but the existing traces left several explanations open. We prepared an application change to measure event-loop delays and break down the time spent waiting for and checking database connections. A companion Terraform change would enable database wait measurements on Amazon Aurora. Both changes were prepared for review, with a repeat of the same load test planned once the instrumentation was running.

When evidence points to an infrastructure bottleneck, a coding agent can also propose a capacity or configuration change in Terraform. Have the infrastructure pipeline produce a plan showing which resources would change. The pipeline can apply the reviewed plan using its own authorized identity. Then the read-only agent can rerun the original checks and report whether the change moved the metric it was supposed to improve.8

The next incident should be easier to see, explain, and fix because of what the agents learned from this one.

At ES Consulting, our senior engineers work inside clients’ systems alongside the teams who operate them. We build agent tools around the evidence those teams need and the access they’re prepared to grant, so the client owns the workflow and its permissions. esconsulting.io

Sources

  1. Service Accounts, Datadog documentation.↩
  2. API and Application Keys, Datadog documentation.↩
  3. Logs RBAC Permissions, Datadog documentation.↩
  4. Manage Sensitive Logs Data Access, Datadog documentation.↩
  5. Security best practices in IAM, AWS documentation.↩
  6. Pass an individual environment variable to an Amazon ECS container, AWS documentation.↩
  7. Datadog Role Permissions, Datadog documentation.↩
  8. Terraform workflow for provisioning infrastructure, HashiCorp documentation.↩

More from the blog

All posts

Agents3 min read

What makes an AI-found bug report worth reading?

When an AI agent reports a bug, the report is part of the job. What a useful one contains, so a developer can see the problem again, judge its impact and decide what to do next.

Shane Z.

Part 1 of 3 · AI-native engineering

AI SDLC14 min read

Designing for AI-scale throughput

Most teams bought the same AI coding tools, and only some of them ship faster. What a team of three changed around the tools to go from 200 code changes a month to about 10,000.

Tobi O.

Agents4 min read

Life before Bugspray

What agent testing looks like when findings can't be reproduced: hours sorting false alarms, fixes that don't stick, and the same bug back months later. Why Bugspray keeps the report, the test and the video together.

Shane Z.

Work with us

Ready to get your AI into production?