Skip to content

1. Setting Up

Create the project and configure capabilities for the self-healing agent.


We're going to build a self-healing agent — an agent that monitors a service for errors, diagnoses the root cause with an LLM, and creates a GitHub issue with a suggested fix. This exercises every part of Qosm: HTTP requests, model calls, structured output, error handling, and multi-file modules.

Create the project

  1. Go to your workspace
  2. Click New Agent
  3. Name it self_healer
  4. Click Create

Configure capabilities

We need three capabilities:

1. A model for diagnosis

  • Click + next to "model"
  • Name: diagnose_model
  • API type: Anthropic
  • API key: your key
  • Model: claude-haiku-4-5-20251001 (fast and cheap for this use case)

2. HTTP GET for monitoring

  • Click + next to "http_get"
  • Name: service_get
  • Allowed domain: api.example.com (replace with your actual service)

3. HTTP POST for GitHub

  • Click + next to "http_post"
  • Name: github_post
  • Allowed domain: api.github.com
  • Authentication: Bearer token with your GitHub PAT

What the environment looks like

With these capabilities enabled, the workspace generates this environment for your code:

effect LLM.Call;
extern diagnose_model : String -> Result<'a, QosmError> ! {LLM.Call};

effect Http.Get;
extern service_get : {url: String, headers: Array<{key: String, value: String}>}
  -> Result<String, QosmError> ! {Http.Get};

effect Http.Post;
extern github_post : {url: String, body: String}
  -> Result<String, QosmError> ! {Http.Post};

These three functions are everything the agent can do. It can't access the filesystem, can't call arbitrary URLs, can't see your API keys. Let's start writing code.

Next: Monitoring →