Documentation

Build your first automation

In this tutorial you ask Hydra for an agent that runs on every new pull request in a repository. The agent reads the pull request and posts a summary as a review comment. You read the agent's definition and watch it run.

Finish Get started first.

Ask for the agent

  1. Click New session.

  2. In the What do you want to work on? box, type this request, with your repository's name in place of acme/shop:

    Create an agent that summarizes each new pull request on acme/shop and posts the summary as a review comment.

  3. Press Enter.

The agent in the session writes the new agent's definition and its prompt, then adds the agent to your organization. It names the new agent in the transcript.

Read the agent's definition

  1. Click Agents in the sidebar.

  2. Open the new agent.

  3. Read the YAML in the Configuration section. The part that decides when the agent runs looks like this:

    agents:
      pr-summarizer:
        prompts:
          - /agents/pr-summarizer/prompt.md
        repo_permissions:
          - repo: acme/shop
            github: write
        runs_when:
          summarize:
            lives_on: github/pr
            where: >-
              self.repo == "acme/shop" && self.state == "open"
              && !self.draft
            mode: headless
            receives:
              - event: github/pr/updated
                where: >-
                  event.subject.id == self.id
                  && event.old.exists(old =>
                    old.head_sha != event.subject.head_sha)
    • lives_on: github/pr: the agent has one instance for each GitHub pull request.
    • where: the condition that keeps an instance alive. When an open pull request on acme/shop that is not a draft appears, Hydra starts a session for it. When the pull request closes or merges, the instance ends.
    • receives: the events that reach a live session. Here a push of new commits reaches the session, so the agent can update its summary.
    • prompts: the document that tells the agent what to do.
    • repo_permissions: lets the agent's sessions write to the repository on GitHub. Posting a review comment needs it.
  4. Click the prompt's path in the YAML. The document opens. Read the instructions the session wrote for the agent.

Your agent's names and conditions may differ. Agent definition lists every key.

Watch the agent run

  1. On GitHub, open a pull request on acme/shop with any small change.
  2. In Hydra, click Active now in the sidebar. A session of your agent appears, working on your pull request.
  3. Open the session to follow the agent as it reads the pull request.
  4. When the session ends, open the pull request on GitHub. The agent's summary appears as a review comment.

Next steps