Documentation

Agents and triggers

An agent is a prompt and a list of runs_when entries.

Ask for an agent in New session, and the session writes its entries. The agent's page shows them under Configuration.

One instance per matching node

This entry runs the swe agent on each issue in the in-progress status:

agents:
  swe:
    prompts: [/agents/swe/prompt.md]
    runs_when:
      implement:
        lives_on: issue
        where: self.status == "in-progress"
        mode: headless
        receives:
          - event: issue/updated
            match: (event.subject)-[child-of]->(self)
            where: event.subject.status in ["complete", "cancelled"]

lives_on names a node kind, such as issue or github/pr. The entry has one instance per node of that kind, and self is that node. Each instance has its own session.

An entry can list fixed instances instead of lives_on. Each one is a singleton with no node. Use one for work such as a weekly report.

where starts and ends an instance

where is a condition on self, written in the expression language.

  • When where becomes true, Hydra starts an instance and its session.
  • When where becomes false, Hydra ends the instance. The session closes after a grace period, so a run that changed the node can finish its turn.
  • When where becomes true again, Hydra starts a new instance with a new session.

In the example, an issue that moves to in-progress starts a session, and a move to review ends the instance.

Other keys control instances:

  • key: values that start a new instance when they change, even while where holds.
  • max_tries: how many times Hydra retries a failing run.
  • max_live: the most sessions the entry can have open at once.

receives rules

Each rule names an event type, such as issue/updated. A rule can filter events with a graph pattern in match and a condition in where. The rule in the example delivers an event when a child issue of self reaches complete or cancelled.

  • A rule that does not mention self must set broadcast: true. Its events go to every instance.
  • A rule can set cron instead of event to fire on a schedule.

Events go only to live instances.

The agent definition reference lists every key. The events reference lists every event type.

Sessions explains on_behalf_of, who a session acts for, and participants, who may message it.