Build software and operations Agents

Build coding, repository, monitoring, diagnosis, remediation, and incident-response Agents with governed evidence and effects.

Before you begin

Expose repositories, sandboxes, telemetry, deployment systems, and incident tools as separate governed Resources. Give read and write operations different Policy actions. Decide whether the Agent may only propose a patch or mitigation, may execute it after approval, or may execute a narrow idempotent remediation automatically. Keep secrets behind Resource boundaries and treat repository and log content as untrusted.

Steps

  1. Gather bounded evidence through read-only Resource operations: files, search results, diagnostics, metrics, traces, or deployment state.
  2. Ask a turn to produce a plan or patch constrained by that evidence. Apply edits inside a sandbox or repository Resource, never through ambient filesystem authority.
  3. Run deterministic checks and feed their results into a review turn. Require approval before higher-risk deployment or remediation.
  4. Commit the patch reference, test evidence, incident decision, and exact applied outcome. Use subtasks for independent investigations, not for every file or log line.
ts
import { agent } from "@constal/sdk";

export default agent({
  id: "coding-agent", version: "1.0.0", model: "model",
  async onMessage(issue, ctx) {
    const context = await ctx.invoke(ctx.resources.repository!, "context.read", { issue, maxFiles: 20 });
    const proposal = await ctx.turn({
      system: "Propose the smallest correct patch. Do not claim tests passed.",
      objective: issue,
      context,
    });
    const patch = await ctx.invoke(ctx.resources.sandbox!, "patch.apply", { proposal: proposal.message.content }, {
      dedupeKey: `patch:${ctx.run.id}`,
    });
    const checks = await ctx.invoke(ctx.resources.sandbox!, "checks.run", { patch });
    const review = await ctx.turn({
      system: "Review the patch against the issue and actual check output.",
      objective: issue,
      context: { patch, checks },
    });
    await ctx.commit({ kind: "reviewed-patch", patch, checks, review: review.message.content });
    return { patch, checks, review: review.message.content };
  },
});

A monitoring Agent replaces repository context with metrics, traces, logs, and topology. An incident Agent may spawn bounded diagnostic subtasks and then await an operator before mitigation. A safe automatic remediator should expose a tiny idempotent operation with a probe, not general shell access disguised as a Tool.

Verify

Test malicious repository text, missing diagnostics, failing checks, stale deployment state, duplicate events, and uncertain writes. Confirm the Agent distinguishes proposal, attempted action, verified action, and committed outcome. The journal must identify each Resource, operation, Policy decision, and effect result. No prompt instruction should expand the Agent’s accepted authority.

Next steps

Read Resources and Tools, Identity, Policy, and authority, Analytics, and Multi-Agent and long-horizon systems.