agents-relay 2.0.248 → 2.0.250

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,6 +5,8 @@ Agents Relay is a TypeScript runtime for durable asynchronous agent Jobs driven
5
5
  V2 uses a read-only local SQLite Job Registry for discovery. The immutable jobId selects the Job Store even when prNumber is zero; lifecycle transitions are atomic across processes. GitHub is **audit-only**: its PR/head/publish events are persisted for reporting, never consulted to start, stop, or complete local Workflows. Local Git delivery and its confirmed merge receipt—not a remote PR MERGED fact—gate Graph completion. Job creation and local Task operations require no GitHub authentication or PR.
6
6
 
7
7
 
8
+ Agent frontmatter hints (`skills`, `model`, `reasoning`) are described in [Agent Definition Contract](skills/agents-relay/contracts/agent-contract.md). They are advisory only and do not alter Skill resolution or Router constraints.
9
+
8
10
  The canonical V2 architecture contract is
9
11
  [DESIGN-PRINCIPLES.md](DESIGN-PRINCIPLES.md). README sections below describe
10
12
  the runtime; they do not replace that contract.
@@ -137,6 +137,7 @@ export async function buildRelayWorkPrompt(input) {
137
137
  `Task: ${input.taskId}`,
138
138
  `Execution: ${input.executionId}`,
139
139
  '', '## User Assignment',
140
+ ...(input.suggestedSkills?.length ? [`Suggested skills (optional, use only when relevant and available): ${input.suggestedSkills.join(', ')}`] : []),
140
141
  ...(input.taskTitle?.trim() ? [`Assigned ${input.agentName === 'planner' ? 'Plan' : 'Task'} title (locator): ${JSON.stringify(input.taskTitle)}`] : []),
141
142
  ...(input.agentName === 'planner' ? [
142
143
  'Read the full authoritative Plan Context through the matching Relay CLI. Apply the actual Plan, not merely its context lookup.',
@@ -138,6 +138,9 @@ async function agentFiles(root, source, skills) {
138
138
  description: fields.description || undefined,
139
139
  capabilities: listValue(fields.capabilities),
140
140
  runtime: fields.runtime || listValue(fields.runtimes)[0] || undefined,
141
+ suggestedSkills: listValue(fields.skills),
142
+ preferredModel: fields.model || undefined,
143
+ preferredReasoning: fields.reasoning || undefined,
141
144
  trustDomains: listValue(fields.trustDomains ?? fields.trust_domains ?? fields.trust),
142
145
  delegation: listValue(fields.delegation),
143
146
  restrictions: listValue(fields.restrictions ?? fields.boundaries),
@@ -203,6 +206,9 @@ export async function resolveExecutionContext(projectPath, role, options = {}) {
203
206
  description: fields.description,
204
207
  capabilities: listValue(fields.capabilities),
205
208
  runtime: fields.runtime || listValue(fields.runtimes)[0] || undefined,
209
+ suggestedSkills: listValue(fields.skills),
210
+ preferredModel: fields.model || undefined,
211
+ preferredReasoning: fields.reasoning || undefined,
206
212
  trustDomains: listValue(fields.trustDomains ?? fields.trust_domains ?? fields.trust),
207
213
  delegation: listValue(fields.delegation),
208
214
  restrictions: listValue(fields.restrictions ?? fields.boundaries),
@@ -235,6 +241,18 @@ export async function resolveExecutionContext(projectPath, role, options = {}) {
235
241
  delegation: { mode: 'relay-child-task', parentTaskIdRequired: role === 'nested-worker' },
236
242
  };
237
243
  }
244
+ /** Resolve just the selected Agent's optional model advice without scanning
245
+ * every Agent/Skill in the project before routing. This is a read-only lookup. */
246
+ export async function resolveAgentModelPreference(projectPath, agentName, options = {}) {
247
+ const workspaceRoot = await resolveWorkspaceRoot(options.workspaceRoot);
248
+ const globalRoot = configuredGlobalRoot(options.globalRoot);
249
+ const configuredSharedRoot = options.sharedRoot !== undefined ? options.sharedRoot : process.env.AGENTS_RELAY_SHARED_ROOT;
250
+ const sharedRoot = configuredSharedRoot ? resolve(configuredSharedRoot) : null;
251
+ const agent = await resolveAgentMarkdown(agentName, BUNDLED_AGENTS_ROOT, projectPath, sharedRoot, agentSourceLayers(projectPath, { workspaceRoot, globalRoot, sharedRoot }));
252
+ const model = agent.metadata.model || undefined;
253
+ const reasoning = agent.metadata.reasoning || undefined;
254
+ return model || reasoning ? { model, reasoning } : undefined;
255
+ }
238
256
  export async function resolveAgentContract(context, agentName) {
239
257
  const agent = context.agents.find(candidate => candidate.name === agentName);
240
258
  if (!agent)
@@ -2,7 +2,7 @@ import { makeExecutionDecisionAudit, recentExecutionRouteResults } from './decis
2
2
  import { discoverModelCandidates } from './model-routing.js';
3
3
  import { loadExecutionRouterRules, loadRoutingPolicy, policyAllows } from './routing-policy.js';
4
4
  import { DEFAULT_CHATGPT_PREFERRED_CONCURRENCY } from './worker-routing.js';
5
- import { appendRoutingInstruction } from './router-rules.js';
5
+ import { appendRoutingInstruction, appendAgentModelPreference } from './router-rules.js';
6
6
  export function executionTaskShape(taskFacts = {}) {
7
7
  const nestedTask = taskFacts.task && typeof taskFacts.task === 'object' ? taskFacts.task : undefined;
8
8
  const raw = taskFacts.storySize ?? nestedTask?.storySize;
@@ -324,7 +324,7 @@ export async function routeExecution(workers, requirements, options = {}) {
324
324
  },
325
325
  recent_route_results: recentRouteResults,
326
326
  }));
327
- const question = appendRoutingInstruction('User routing instructions have highest priority over default preferences, task size, runtime and resource signals. Candidate order is arbitrary and conveys no priority, ranking or preference. Do not favor earlier choices. Select an offered route that obeys the user instructions.\nUser routing instructions:\n' + routingInstruction, 'Use recent_route_results (up to the last 10 confirmed execution outcomes) to weigh route reliability, including success, failure and the recorded reason. Distinguish provider/runtime faults from task-specific failures and cancellations; historical failures are evidence, not automatic hard exclusions. For vision, image generation, visual review, and final review tasks, prefer ChatGPT Worker when available and within capacity; for coding, CLI and filesystem tasks, prefer Codex. These are soft preferences subordinate to user rules. Choose exactly one listed route; do not invent routes.');
327
+ const question = appendAgentModelPreference(appendRoutingInstruction('User routing instructions have highest priority over default preferences, task size, runtime and resource signals. Candidate order is arbitrary and conveys no priority, ranking or preference. Do not favor earlier choices. Select an offered route that obeys the user instructions.\nUser routing instructions:\n' + routingInstruction, 'Use recent_route_results (up to the last 10 confirmed execution outcomes) to weigh route reliability, including success, failure and the recorded reason. Distinguish provider/runtime faults from task-specific failures and cancellations; historical failures are evidence, not automatic hard exclusions. For vision, image generation, visual review, and final review tasks, prefer ChatGPT Worker when available and within capacity; for coding, CLI and filesystem tasks, prefer Codex. These are soft preferences subordinate to user rules. Choose exactly one listed route; do not invent routes.'), options.modelPreference);
328
328
  let selected = fallback;
329
329
  let evidence = { mode: options.decisionMode ?? 'off', fallback: true };
330
330
  const decisionStages = [];
@@ -37,6 +37,7 @@ export async function managedWorkerInput(job, task, context, mode = 'production'
37
37
  const eventProtocol = eventSkill ? join(dirname(eventSkill.path), 'references/protocol.md') : undefined;
38
38
  return buildRelayWorkPrompt({
39
39
  agentName,
40
+ suggestedSkills: selected.agent.suggestedSkills,
40
41
  agentContent: agent,
41
42
  adapter,
42
43
  contracts: [
package/dist/planner.js CHANGED
@@ -503,7 +503,7 @@ export async function buildPlannerExecutionPrompt(context, agentFile = DEFAULT_P
503
503
  if (!context.planExecution)
504
504
  throw new Error('Planner execution is missing its durable Plan and execution identity');
505
505
  const ctx = context.executionContext, selected = ctx ? await resolveAgentMarkdown('planner', BUNDLED_AGENTS_ROOT, ctx.project.path, ctx.project.sharedRoot, agentSourceLayers(ctx.project.path, ctx.project)) : undefined;
506
- return buildRelayWorkPrompt({ agentName: 'planner', agentContent: selected?.content ?? await readFile(agentFile, 'utf8'), adapter,
506
+ return buildRelayWorkPrompt({ agentName: 'planner', agentContent: selected?.content ?? await readFile(agentFile, 'utf8'), suggestedSkills: ctx?.agents.find(agent => agent.name === 'planner')?.suggestedSkills, adapter,
507
507
  contracts: [join(dirname(fileURLToPath(import.meta.url)), '..', 'skills/agents-relay/contracts/task-job-contract.md'),
508
508
  join(dirname(fileURLToPath(import.meta.url)), '..', 'skills/agents-relay/contracts/blocker-job-recovery.md'),
509
509
  ...(ctx?.skills.find(skill => skill.name === 'ponytail')?.path ? [ctx.skills.find(skill => skill.name === 'ponytail').path] : [])],
@@ -1,4 +1,23 @@
1
- import { resolveExecutionContext } from './execution-context.js';
1
+ import { resolveExecutionContext, resolveAgentModelPreference } from './execution-context.js';
2
+ /**
3
+ * Agent model guidance is advisory. A missing/malformed Agent or unavailable
4
+ * context must never turn a previously routable Task into a routing failure.
5
+ */
6
+ export async function agentModelPreferenceForJob(options, job, agentName, task) {
7
+ if (!agentName)
8
+ return undefined;
9
+ try {
10
+ // Do not call projectPathForJob here: production providers may create a
11
+ // worktree or mutate Job state when that execution locator is evaluated.
12
+ const projectPath = options.agentPreferenceContextPathForJob
13
+ ? await options.agentPreferenceContextPathForJob(job, task)
14
+ : task?.routing?.cwd;
15
+ return projectPath ? await resolveAgentModelPreference(projectPath, agentName, options.executionContextRoots ?? {}) : undefined;
16
+ }
17
+ catch {
18
+ return undefined;
19
+ }
20
+ }
2
21
  export async function resolveTaskContext(store, options, job, task, role, projectPathOverride) {
3
22
  const projectPath = projectPathOverride ?? (options.projectPathForJob ? await options.projectPathForJob(job) : task.routing?.cwd ?? process.cwd());
4
23
  return resolveExecutionContext(projectPath, role, {
@@ -21,6 +21,7 @@ import { reviewGenerationMatches } from './review-generation-fence.js';
21
21
  import { targetedRequestsForReview, targetedRequestsCoverReview } from './review-revision-model.js';
22
22
  import { reviewFindingFingerprint } from './review-revision-policy.js';
23
23
  import { codexNoStartFallbackRoute, quarantineUnavailableCodexFallback } from './chatgpt-platform-fallback.js';
24
+ import { agentModelPreferenceForJob } from './reconciler-context.js';
24
25
  export class ReconcilerReviewBase extends ReconcilerRuntimeBase {
25
26
  async currentHeadSha(job) {
26
27
  // Tests may replace the external Git effect entirely; in that case its
@@ -108,7 +109,7 @@ export class ReconcilerReviewBase extends ReconcilerRuntimeBase {
108
109
  const now = new Date().toISOString();
109
110
  const reviewGateTasks = implementationTasks(job);
110
111
  const reviewThread = resolveReviewerThreadDestination(job, this.options.reviewer?.threadId);
111
- const reviewerRouting = await this.selectReviewer(reviewGateTasks, reviewThread ? chatgptThreadRequirements(this.options.reviewer?.requirements) : undefined);
112
+ const reviewerRouting = await this.selectReviewer(reviewGateTasks, reviewThread ? chatgptThreadRequirements(this.options.reviewer?.requirements) : undefined, job);
112
113
  const chatgptThreadDelivery = prepareReviewerThreadDelivery(job, {
113
114
  id, agentName: FINAL_REVIEW_AGENT, reviewHeadSha: headSha, routing: reviewerRouting.candidate.routing,
114
115
  }, this.options.reviewer?.threadId);
@@ -190,7 +191,7 @@ export class ReconcilerReviewBase extends ReconcilerRuntimeBase {
190
191
  const ready = refreshTaskDependencies(await this.store.load(job.id));
191
192
  await this.store.saveJob(ready);
192
193
  }
193
- async selectReviewer(implementationTasks, requirementsOverride) {
194
+ async selectReviewer(implementationTasks, requirementsOverride, job) {
194
195
  const configured = this.options.reviewer;
195
196
  const registered = await this.store.listAgents();
196
197
  const usage = this.options.usageSnapshotProvider ? await this.options.usageSnapshotProvider() : undefined;
@@ -230,6 +231,7 @@ export class ReconcilerReviewBase extends ReconcilerRuntimeBase {
230
231
  decisionEngine: this.options.decisionEngine,
231
232
  decisionMode: this.options.decisionMode,
232
233
  taskFacts,
234
+ modelPreference: job ? await agentModelPreferenceForJob(this.options, job, FINAL_REVIEW_AGENT) : undefined,
233
235
  usage,
234
236
  registered,
235
237
  chatgptRunning: runtimeSummary?.chatgptRunning ?? 0,
@@ -294,6 +296,7 @@ export class ReconcilerReviewBase extends ReconcilerRuntimeBase {
294
296
  decisionEngine: this.options.decisionEngine,
295
297
  decisionMode: this.options.decisionMode,
296
298
  taskFacts: { ...taskFacts, recovery: task.recoveryContext ?? null, recovery_parent_failed_route: excludedRoutes[0] ?? null },
299
+ modelPreference: await agentModelPreferenceForJob(this.options, job, task.agentName ?? 'implementation', task),
297
300
  usage,
298
301
  registered,
299
302
  chatgptRunning: runtimeSummary?.chatgptRunning ?? 0,
package/dist/relayd.js CHANGED
@@ -156,7 +156,7 @@ export async function runDaemon(argv) {
156
156
  return limitHistory ? dashboardManagedJobs(visible) : visible;
157
157
  };
158
158
  cachedOverviews = await inventoryFromLocal();
159
- const makeReconciler = (store, maxConcurrent) => new Reconciler(store, { noGitHub, owner: `relayd-${process.pid}`, maxConcurrent, leaseMs: Number(value(argv, '--lease-ms', '300000')), adapters: [new CodexAdapter(value(argv, '--codex', 'codex')), new ChatGptAdapter(), new ZAdapter()], continuations: [new CodexThreadContinuation(value(argv, '--codex', 'codex')), new CommandContinuation(), new WebhookContinuation()], planner: runtimePlanner(argv), usageSnapshotProvider: () => usageRegistry.snapshot(), runtimeSummaryProvider: () => ({ chatgptRunning: summarizeRuntime(cachedOverviews.map(item => item.job)).workers.chatgpt }), decisionEngine: executionDecisionEngine(), decisionMode: decisionMode(), decisionAuditStore, eventBus: bus, escalationNotifier: escalationNotifierFromEnvironment(), reviewer: runtimeReviewer(argv), executionContextRoots: { workspaceRoot }, projectPathForJob: async (job, task) => {
159
+ const makeReconciler = (store, maxConcurrent) => new Reconciler(store, { noGitHub, owner: `relayd-${process.pid}`, maxConcurrent, leaseMs: Number(value(argv, '--lease-ms', '300000')), adapters: [new CodexAdapter(value(argv, '--codex', 'codex')), new ChatGptAdapter(), new ZAdapter()], continuations: [new CodexThreadContinuation(value(argv, '--codex', 'codex')), new CommandContinuation(), new WebhookContinuation()], planner: runtimePlanner(argv), usageSnapshotProvider: () => usageRegistry.snapshot(), runtimeSummaryProvider: () => ({ chatgptRunning: summarizeRuntime(cachedOverviews.map(item => item.job)).workers.chatgpt }), decisionEngine: executionDecisionEngine(), decisionMode: decisionMode(), decisionAuditStore, eventBus: bus, escalationNotifier: escalationNotifierFromEnvironment(), reviewer: runtimeReviewer(argv), executionContextRoots: { workspaceRoot }, agentPreferenceContextPathForJob: async (job) => resolveRepositoryProjectPath(repositoryPaths.get(job.repository) ?? await resolveManagedProjectPath(job.repository, explicitProjectPath, workspaceRoot), job.projectPath), projectPathForJob: async (job, task) => {
160
160
  const canonical = repositoryPaths.get(job.repository) ?? await resolveManagedProjectPath(job.repository, explicitProjectPath, workspaceRoot);
161
161
  if (!(task ? taskRequiresManagedWorktree(job, task) : Boolean(job.localMerge?.sourceRef)))
162
162
  return resolveRepositoryProjectPath(canonical, job.projectPath);
@@ -66,6 +66,17 @@ export function appendRoutingInstruction(question, instruction) {
66
66
  return question;
67
67
  return question + '\n\n' + instruction;
68
68
  }
69
+ /** Optional Agent metadata belongs to Router advice, not candidate discovery. */
70
+ export function appendAgentModelPreference(question, preference) {
71
+ if (!preference?.model && !preference?.reasoning)
72
+ return question;
73
+ return appendRoutingInstruction(question, [
74
+ 'Agent model preference (advisory only; lower priority than user routing instructions and all hard constraints):',
75
+ ...(preference.model ? [`Prefer model: ${preference.model}`] : []),
76
+ ...(preference.reasoning ? [`Prefer reasoning: ${preference.reasoning}`] : []),
77
+ 'Choose only among the existing eligible routes. Do not invent or enable a route to satisfy this preference.',
78
+ ].join('\n'));
79
+ }
69
80
  export function parseRouterRules(text) {
70
81
  const choices = [];
71
82
  const seen = new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.248",
3
+ "version": "2.0.250",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,6 +31,8 @@ Read `contracts/task-job-contract.md` before authoring or changing Jobs or Tasks
31
31
 
32
32
  Usually let `job create --initial-plan` establish the first Planner round; use `plan` for an existing create-only Job. Direct `task create` is for deliberately orchestrator-authored work. Tasks describe verifiable outcomes, **not shell commands**. Declare exactly one durable result (`task_pr` or `file`), meaningful dependencies, and `storySize`; Relay chooses worker/model routes unless the task truly needs a specific capability.
33
33
 
34
+ Agent `skills` suggests Worker skills; `model`/`reasoning` suggest Router preferences. Neither is mandatory (see `contracts/agent-contract.md`).
35
+
34
36
  An assigned **execution Prompt** pins a specific Skill version and supplies Role, Bootstrap, Contracts, Contexts, and Task/Plan identity. Preserve these references. Resolve the matching CLI as `../../dist/cli.js` relative to the pinned Skill directory; do **not** substitute an unrelated globally installed CLI. Before acting, load the exact execution-bound context:
35
37
 
36
38
  ```sh
@@ -0,0 +1,64 @@
1
+ # Agents Relay Agent Definition Contract
2
+
3
+ This is the canonical contract for optional Agent frontmatter hints and their
4
+ effect on execution. It applies to project, shared, and Relay-built-in Agents,
5
+ including merged Agents. Agent role instructions, Task content, and Graph-owned
6
+ workflow/lifecycle behavior remain unchanged.
7
+
8
+ ## Optional frontmatter
9
+
10
+ Use simple top-level YAML scalar fields and inline comma-separated lists.
11
+ These fields are **advisory**, never requirements:
12
+
13
+ ```yaml
14
+ ---
15
+ name: vlog-editor
16
+ extends: shared/vlog-editor
17
+ skills: [markcut, shotcraft]
18
+ model: openai/gpt-6
19
+ reasoning: high
20
+ ---
21
+ ```
22
+
23
+ | Field | Consumer | Semantics |
24
+ | --- | --- | --- |
25
+ | `skills` | Worker User Assignment (including Planner) | Optional skill suggestions, e.g. `Suggested skills ...: markcut, shotcraft`. Only use relevant, available skills. |
26
+ | `model` | Unified Execution Router decision prompt | Preferred provider/model name, e.g. `openai/gpt-6`, for advisory ranking only. |
27
+ | `reasoning` | Unified Execution Router decision prompt | Preferred reasoning effort, e.g. `high`, for advisory ranking only. |
28
+
29
+ A field may be omitted. `reasoning` can be specified without `model`.
30
+ These optional hints do not auto-install/discover/select/require skills, do not
31
+ make a Task depend on a skill, do not create or enable model candidates, and do
32
+ not override the Task's explicit routing constraints, available routes, resource
33
+ or runtime gates, user routing instructions, or deterministic fallback.
34
+ Unknown/unavailable suggestions are not execution errors.
35
+
36
+ ## Resolution and precedence
37
+
38
+ The effective Agent inherits frontmatter metadata using the existing Agent
39
+ resolution and `extends` merge rules; a more specific override wins.
40
+ The selected Agent's `skills` hint appears in the Worker/Planner **user
41
+ prompt**, not as an enforced bootstrap/contract requirement. The selected
42
+ Agent's `model` and `reasoning` hints go to the Router **decision prompt**,
43
+ not to the Worker prompt.
44
+
45
+ User-authored Router `[routing-instruction]` guidance has priority over Agent
46
+ preferences, and authoritative hard constraints still apply before selection.
47
+ Only configured/default or explicitly listed `[choices]` routes are eligible;
48
+ the Agent hint does not widen that choice set. Existing Router selection,
49
+ fallback, review, and lifecycle behavior stays the same.
50
+
51
+ When a field is missing, Relay does not add the corresponding hint. If no safe,
52
+ read-only Agent path can be resolved for routing, Relay skips the optional
53
+ Router advice rather than preparing a Task worktree or blocking a valid route.
54
+ The frontmatter is not durable Job/Task state and does not change CLI or
55
+ SQLite schemas.
56
+
57
+ ## Related contracts
58
+
59
+ - [Task / Job Contract](task-job-contract.md) remains authoritative for durable
60
+ Task/Job inputs, dependencies, and lifecycle facts.
61
+ - [Prompt Builder](../../../docs/agent-prompt-builder.md) documents the actual
62
+ Worker User Assignment and the merged Agent snapshot.
63
+ - [Execution Router](../../../docs/worker-model-routers.md) documents choice
64
+ discovery, hard gates, decision priorities, and fallback.
@@ -17,6 +17,10 @@ When creating a new Job from an active discussion, the orchestrator must consoli
17
17
 
18
18
  Use `job create` with standalone objective Markdown. Existing PRs are not imported as Jobs. Use Relay CLI for subsequent Job reads and updates; do not infer Job state or objective from GitHub.
19
19
 
20
+ ## Agent definitions and advisory frontmatter
21
+
22
+ Agent frontmatter `skills`, `model`, and `reasoning` are optional **hints**, not Task requirements. See the canonical [Agent Definition Contract](agent-contract.md) for syntax, inheritance, the separate Worker/Router prompt consumers, and the unchanged hard-gate/Skill resolution semantics. Task producers must not turn those hints into durable Task routing constraints or required Skills.
23
+
20
24
  ## Task producers
21
25
 
22
26
  Any task producer — orchestrator, planner, or nested task-producing agent — must follow this contract.