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
| Key | Type | Default | Description |
|---|---|---|---|
name | string | the map key | Names 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_on | string | none | Names the node kind that the entry's instances live on, such as issue. See Data model. Set exactly one of lives_on and instances. |
instances | map of string to map | none | Maps each singleton instance's name to its fields, such as main: { region: eu }. |
where | expression | required with lives_on | Sets the condition on self that keeps an instance alive. |
receives | list of rule | none | Lists the rules for the events that reach live instances. See receives. |
mode | headless or interactive | required | Sets the session mode. |
environment | string | the agent's environment | Sets the environment key for the entry's runs. |
append_prompt | list of string | none | Lists document paths that Hydra adds in order after the agent's prompts. Each path must exist. |
secrets | list of secret reference | none | Lists secrets that Hydra adds to the agent's secrets. |
repo_permissions | list of grant | none | Lists grants that Hydra adds to the agent's repo_permissions for the entry's sessions. |
runtime | runtime block | none | Hydra merges this block over the agent's runtime. An input_batching block replaces the agent's input_batching block entirely. |
model | model policy | none | Sets a {mode, entries, strategy} policy that Hydra merges over the agent's policy. |
max_tries | integer | the agent's max_tries | Hydra uses this value as the entry's runtime.max_retries. The minimum value is 1. |
max_live | integer | no cap | Sets the maximum number of open sessions for the entry. The minimum value is 1. |
on_behalf_of | expression | org | Names who the sessions act for. |
participants | expression | whoever on_behalf_of names | Names who can message the sessions. |
key | list of expression | see key | Lists 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 asself.assignee - a fallback, such as
self.assignee.get_or_else(org) - a neighbor read with
match!, such asmatch!(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_ofcan be a user,participantsmust repeat it. []andNonelet in no user. Agents can still send to such a session, and it shows in no one's Inbox.- A list that holds
orglets 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.