Skip to content

Latest commit

 

History

History
173 lines (107 loc) · 4.02 KB

File metadata and controls

173 lines (107 loc) · 4.02 KB

Build and Deploy a Render Ops Agent

In this workshop, you deploy a small Render stack and build an agent that inspects it.

You will use:

  • A Render web service for the agent.
  • A second Render web service as the target.
  • Render Postgres for memory.
  • The Render API for services, deploys, logs, and metrics.
  • Anthropic's Messages API for the agent loop.

1. Clone the repo

Clone the workshop repo and switch to the starter branch:

git clone https://github.com/render-examples/render-ops-agent-workshop.git
cd render-ops-agent-workshop
git switch starter

Install dependencies:

npm install

Verify the project builds:

npm run check

Checkpoint: the build passes and the test suite passes.

2. Deploy the Blueprint

Create a Blueprint from this repo in the Render Dashboard.

The Blueprint creates:

  • ops-agent
  • ops-target
  • ops-agent-db

After Render creates the resources, set these secret values on ops-agent:

  • RENDER_API_KEY
  • ANTHROPIC_API_KEY

Render wires DATABASE_URL from ops-agent-db.

Checkpoint: both web services show a healthy deploy, and ops-agent has a successful pre-deploy migration.

3. Run the first agent

Use the deployed ops-agent URL:

curl -X POST https://YOUR-OPS-AGENT.onrender.com/run

At this point, the agent can list services. It should see ops-agent and ops-target.

Checkpoint: the response mentions the services in your Render account.

4. Add Render tools

Open the tool files in agent/tools/.

The room path wires these tools:

  • list_services
  • fetch_deploys
  • fetch_logs
  • fetch_metrics

Each tool has three parts:

  • A name the model can call.
  • A JSON schema for input.
  • A function that fetches read-only Render data.

Run the tests:

npm test -- test/render-tools.test.ts test/tool-registry.test.ts

Deploy again after the tools are wired.

Checkpoint: the agent can inspect ops-target deploys, logs, or metrics instead of only listing service names.

5. Add Postgres memory

Open migrations/001_memory.sql and agent/memory.ts.

The memory layer stores:

  • runs: one row per agent execution.
  • findings: one row per stable finding fingerprint.

Render runs migrations with preDeployCommand:

preDeployCommand: npm run db:migrate

Run the memory tests:

npm test -- test/memory.test.ts test/run-agent.test.ts

Deploy again after memory is wired.

Checkpoint: a second run should recognize recent findings instead of treating everything as brand-new.

6. Use the TUI

Set AGENT_URL in .env to your deployed ops-agent URL:

AGENT_URL=https://YOUR-OPS-AGENT.onrender.com

Run the Ink terminal client:

npm run tui

Ask it to inspect your services.

Checkpoint: the TUI prints the agent run lifecycle and final summary.

Troubleshooting

If /run fails, check:

  • RENDER_API_KEY is set on ops-agent.
  • ANTHROPIC_API_KEY is set on ops-agent.
  • DATABASE_URL exists on ops-agent.
  • The preDeployCommand completed.
  • The Render API wrapper is still blocking non-GET requests.

If the model hits max turns, narrow tool output before increasing MAX_TURNS.

Take-home appendix

Move analysis into a Workflow

Keep ops-agent as the control plane. Move the heavier analysis step into a Render Workflow task so the analysis can run with Workflow retries and observability.

The high-level flow:

  1. ops-agent creates a runs row.
  2. ops-agent starts a Workflow task.
  3. The Workflow task gathers data and runs analysis.
  4. ops-agent stores the result and findings in Postgres.

Workflows do not yet have Blueprint support, so this path uses Dashboard setup.

Add cron scheduling

After Workflow-backed analysis works, add a cron job that calls ops-agent on a schedule.

The cron job should stay small. It only wakes up ops-agent; ops-agent handles auth, memory, and Workflow orchestration.

Use it on real services

Point the agent at services you run outside the workshop. You can also explore the Render Diagnostic Agent for a browser-based daily workflow.