Documentation

runs_when

An agent's runs_when is a map from entry name to entry, or a list of entries that each set name.

An entry has one instance per node of its lives_on kind where where holds, or one instance per name under instances. Each instance runs a session.

Entry keys

KeyTypeDefaultDescription
namestringthe map keyNames the entry. The name must match [a-z0-9][a-z0-9-]*, have at most 64 characters, and be unique within the agent. The name adhoc is reserved.
lives_onstringnoneNames the node kind that the entry's instances live on, such as issue. See Data model. Set exactly one of lives_on and instances.
instancesmap of string to mapnoneMaps each singleton instance's name to its fields, such as main: { region: eu }.
whereexpressionrequired with lives_onSets the condition on self that keeps an instance alive.
receiveslist of rulenoneLists the rules for the events that reach live instances. See receives.
modeheadless or interactiverequiredSets the session mode.
environmentstringthe agent's environmentSets the environment key for the entry's runs.
append_promptlist of stringnoneLists document paths that Hydra adds in order after the agent's prompts. Each path must exist.
secretslist of secret referencenoneLists secrets that Hydra adds to the agent's secrets.
repo_permissionslist of grantnoneLists grants that Hydra adds to the agent's repo_permissions for the entry's sessions.
runtimeruntime blocknoneHydra merges this block over the agent's runtime. An input_batching block replaces the agent's input_batching block entirely.
modelmodel policynoneSets a {mode, entries, strategy} policy that Hydra merges over the agent's policy.
max_triesintegerthe agent's max_triesHydra uses this value as the entry's runtime.max_retries. The minimum value is 1.
max_liveintegerno capSets the maximum number of open sessions for the entry. The minimum value is 1.
on_behalf_ofexpressionorgNames who the sessions act for.
participantsexpressionwhoever on_behalf_of namesNames who can message the sessions.
keylist of expressionsee keyLists values that restart an instance when they change. Valid only in an entry that sets lives_on.

Expressions use the expression language.

boards:
  web:
    description: Work on the web app.
    statuses: [backlog, in-progress, review, done]

agents:
  reviewer:
    prompts: [/agents/reviewer/prompt.md]
    runs_when:
      review:
        lives_on: issue
        where: self.status == "review"
        mode: interactive
        append_prompt: [/boards/web/prompt.md]
        on_behalf_of: self.assignee.get_or_else(org)
        max_live: 5
        max_tries: 2

lives_on and where

When where starts to hold for a node, the server starts a session. When it stops holding, the server ends the instance.

An instance on a node receives every event whose subject is that node, and both ends of a relation/* event.

instances

self reads a singleton's name and its string, boolean and number fields, such as self.region == "eu". The expression language gives their types. A cron rule in receives starts each singleton that is not live and whose where holds.

agents:
  digest:
    prompts: [/agents/digest/prompt.md]
    runs_when:
      daily:
        instances:
          main: { team: web }
        mode: interactive
        receives:
          - cron: '0 9 * * 1-5'
            timezone: Europe/London
            name: weekday-digest
            message: Post the daily digest.

on_behalf_of

The value is an expression on self that gives a principal:

  • org
  • a member, such as user!("alice")
  • a user field of self, such as self.assignee
  • a fallback, such as self.assignee.get_or_else(org)
  • a neighbor read with match!, such as match!(i => (i:issue)-[has-document]->(self)).head_option.flat_map(i => i.assignee).get_or_else(org)

A singleton's on_behalf_of cannot read a neighbor, and no singleton field is a Principal. A None value, as from an unassigned self.assignee, fails the start. A bare username such as alice is an error. Write user!("alice").

participants

The value takes the same forms as on_behalf_of, or a list of principals such as [user!("alice"), user!("bob")]. A list may read neighbors, such as match!(i => (i:issue)-[has-document]->(self)).flat_map(i => i.assignee).

  • When on_behalf_of can be a user, participants must repeat it.
  • [] and None let in no user. Agents can still send to such a session, and it shows in no one's Inbox.
  • A list that holds org lets in the organization.

key

The server records the values of key when an instance starts. When one changes, it ends the instance, which stops its running work, and starts a new one. A key that reads a neighbor with match! changes when a field it reads on the neighbor changes, or when the edge it follows is added or removed.

The default holds one self.<field> for each field that on_behalf_of or participants reads, and one entry for each neighbor field they read with match!. A change of a default key value keeps the instance and its session. The server updates the session's participants in place, or soft-resets it when on_behalf_of reads the field.

A list replaces the default. [] sets no key.