Documentation

Keep an agent informed about related work

A running agent receives only the events its receives rules name. Each rule names an event and the node it must relate to. Without rules, an agent that waits on other work never learns that the work is done.

  1. Open New session, name the agent, and say which changes it must hear about:

    Change the writer agent so it hears when a child issue of its issue completes or is cancelled, when a review is submitted on the issue's pull request, and when someone comments on the issue.

  2. Answer the session's questions until it changes the agent.

  3. Open Agents in the sidebar and pick the agent. Under Configuration, its runs_when entry now has receives rules like these:

    agents:
      writer:
        prompts:
          - /agents/writer/prompt.md
        runs_when:
          write:
            lives_on: issue
            where: self.status == "writing"
            mode: headless
            receives:
              - event: issue/updated
                match: (event.subject)-[child-of]->(self)
                where: event.subject.status in ["complete", "cancelled"] && event.old.exists(old => old.status != event.subject.status)
              - event: github/review/submitted
                match: (event.subject)-[github/for-issue]->(self)
              - event: issue/commented
                where: event.subject == self
    • event is the event type.
    • match is the relation between the event's node and the agent's node. The first rule matches an issue that is a child of the agent's issue. The second matches a pull request from the branch Hydra creates for the agent's issue.
    • where filters the events further. The first rule passes a child only when its status changes to complete or cancelled.
  4. Make one of the changes, such as a comment on the issue. Open the issue's session from its Sessions section. The chat shows the event, such as New comment, and the agent's turn that it started.

An agent receives events only while its where holds. The events reference lists the events, and the data model reference lists the relations a match can follow. The agent definition reference lists every key of a receives rule.