agents-relay 2.0.248 → 2.0.249

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.
@@ -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.249",
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 frontmatter `skills` suggests Worker skills; `model` and `reasoning` suggest a Router preference. None are mandatory.
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