@nylorun/harness 0.34.0-beta → 0.35.0-beta

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.35.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - 59796a5: An agent that keeps a plan is reminded to move it. When a turn set its plan with `update_plan` and has made 8 more tool calls without calling it again, while the plan still has an open step, the next model call ends with one line naming the step the plan says is current and asking the model to call `update_plan` if that step is done or another has started. It comes again after every 8 more calls. The reminder is read from the transcript alone, so a replay sends the same prompt, and it is never written into the transcript. Models that set their plan once and never move it left callers watching step 1 until the end.
8
+
9
+ ## 0.34.1-beta
10
+
11
+ ### Patch Changes
12
+
13
+ - Pin core to the tested release.
14
+ - Updated dependencies [1d3a5c5]
15
+ - @nylorun/core@0.38.0-beta
16
+
3
17
  ## 0.34.0-beta
4
18
 
5
19
  ### Minor Changes
@@ -0,0 +1,17 @@
1
+ import type { ModelRequest } from "@nylorun/core/define";
2
+ /**
3
+ * How many tool calls a turn makes after its last `update_plan` before the model is reminded of
4
+ * its plan, and again after as many more.
5
+ */
6
+ export declare const PLAN_REMINDER_CALLS = 8;
7
+ /**
8
+ * The reminder to keep the plan (`update_plan`, `progress/v1`), or `undefined`. A model often sets
9
+ * its plan when it starts and never moves it, so the caller watches step 1 run until the end. When
10
+ * the turn in progress set a plan that still has an open step, and made `PLAN_REMINDER_CALLS` more
11
+ * tool calls since (another reminder after as many more), the call ends with one line naming the
12
+ * step the plan says is current.
13
+ *
14
+ * Read from the request alone, so the same transcript gives the same prompt, and never written
15
+ * into the transcript. Nothing when the turn has no `update_plan` tool or has set no plan.
16
+ */
17
+ export declare function planReminder(request: ModelRequest): string | undefined;
@@ -0,0 +1,63 @@
1
+ import { UPDATE_PLAN_TOOL } from "@nylorun/core/engine";
2
+ /**
3
+ * How many tool calls a turn makes after its last `update_plan` before the model is reminded of
4
+ * its plan, and again after as many more.
5
+ */
6
+ export const PLAN_REMINDER_CALLS = 8;
7
+ /**
8
+ * The reminder to keep the plan (`update_plan`, `progress/v1`), or `undefined`. A model often sets
9
+ * its plan when it starts and never moves it, so the caller watches step 1 run until the end. When
10
+ * the turn in progress set a plan that still has an open step, and made `PLAN_REMINDER_CALLS` more
11
+ * tool calls since (another reminder after as many more), the call ends with one line naming the
12
+ * step the plan says is current.
13
+ *
14
+ * Read from the request alone, so the same transcript gives the same prompt, and never written
15
+ * into the transcript. Nothing when the turn has no `update_plan` tool or has set no plan.
16
+ */
17
+ export function planReminder(request) {
18
+ if (!request.configuration.tools.some((tool) => tool.name === UPDATE_PLAN_TOOL))
19
+ return undefined;
20
+ let plan;
21
+ let since = 0;
22
+ let before = 0;
23
+ for (const entry of request.transcript) {
24
+ if (entry.turnId !== request.turnId || entry.kind !== "candidate")
25
+ continue;
26
+ before = since;
27
+ for (const block of entry.candidate.output) {
28
+ if (block.type !== "tool-call")
29
+ continue;
30
+ if (block.name === UPDATE_PLAN_TOOL) {
31
+ plan = block.args;
32
+ since = 0;
33
+ before = 0;
34
+ }
35
+ else if (plan !== undefined)
36
+ since += 1;
37
+ }
38
+ }
39
+ if (plan === undefined || since < PLAN_REMINDER_CALLS)
40
+ return undefined;
41
+ if (Math.floor(since / PLAN_REMINDER_CALLS) === Math.floor(before / PLAN_REMINDER_CALLS))
42
+ return undefined;
43
+ const step = currentStep(plan);
44
+ if (!step)
45
+ return undefined;
46
+ return `Your plan (${UPDATE_PLAN_TOOL}) still shows "${step.label}" as ${step.state}, and you have made ${since} tool calls since you last set it. The person follows the plan while you work: if that step is done or another has started, call ${UPDATE_PLAN_TOOL} now with the whole plan. If it is still going, carry on.`;
47
+ }
48
+ /** The step a plan says is current: the first active or blocked one, else the first pending one. */
49
+ function currentStep(plan) {
50
+ const steps = plan?.steps;
51
+ if (!Array.isArray(steps))
52
+ return undefined;
53
+ const open = steps.flatMap((raw) => {
54
+ const step = (raw ?? {});
55
+ return typeof step.label === "string" &&
56
+ step.label.trim() !== "" &&
57
+ typeof step.state === "string"
58
+ ? [{ label: step.label.trim(), state: step.state }]
59
+ : [];
60
+ });
61
+ return (open.find((step) => step.state === "active" || step.state === "blocked") ??
62
+ open.find((step) => step.state === "pending"));
63
+ }
@@ -7,7 +7,8 @@ import { type LiveFile } from "./files.js";
7
7
  * the context, in one user message: each file's line, then what `files` (`representFiles`)
8
8
  * made of it, a media part, a `<file>` block or a note. Without `files`, each goes as its media
9
9
  * part. Their content reaches the model only in their own turn. `readable` false for an agent
10
- * without `read_artifact` (ADR-100): no reference line offers it.
10
+ * without `read_artifact` (ADR-100): no reference line offers it. Last, when the turn's plan has
11
+ * fallen behind, one line reminds the model to keep it (`planReminder`).
11
12
  */
12
13
  export declare function projectModelCall(request: ModelRequest, files?: ReadonlyMap<string, readonly PromptContentPart[]>, readable?: boolean): ModelCall;
13
14
  /**
@@ -1,6 +1,7 @@
1
1
  import { copyJson, freezeGraph } from "@nylorun/core/define";
2
2
  import { outputSchemaInstruction } from "@nylorun/core/engine";
3
3
  import { summaryPrompt } from "../compaction/index.js";
4
+ import { planReminder } from "./plan-reminder.js";
4
5
  import { FILES_MESSAGE_HEADER, fileKeyOf, mediaReferenceLine, } from "./files.js";
5
6
  /**
6
7
  * The model call for `request`. Every file in the transcript is its reference line (protocol 12),
@@ -9,7 +10,8 @@ import { FILES_MESSAGE_HEADER, fileKeyOf, mediaReferenceLine, } from "./files.js
9
10
  * the context, in one user message: each file's line, then what `files` (`representFiles`)
10
11
  * made of it, a media part, a `<file>` block or a note. Without `files`, each goes as its media
11
12
  * part. Their content reaches the model only in their own turn. `readable` false for an agent
12
- * without `read_artifact` (ADR-100): no reference line offers it.
13
+ * without `read_artifact` (ADR-100): no reference line offers it. Last, when the turn's plan has
14
+ * fallen behind, one line reminds the model to keep it (`planReminder`).
13
15
  */
14
16
  export function projectModelCall(request, files, readable = true) {
15
17
  return freezeGraph({
@@ -19,6 +21,7 @@ export function projectModelCall(request, files, readable = true) {
19
21
  ...request.transcript.flatMap((entry) => projectEntry(entry, request.turnId, readable)),
20
22
  ...projectContext(request.context),
21
23
  ...projectFiles(liveFilesOf(request, readable), files),
24
+ ...projectPlanReminder(request),
22
25
  ]),
23
26
  tools: Object.freeze(request.configuration.tools.map((tool) => Object.freeze({
24
27
  name: tool.name,
@@ -76,6 +79,13 @@ function projectInstructions(instructions, outputSchema) {
76
79
  export function schemaInstruction(schema) {
77
80
  return outputSchemaInstruction(schema);
78
81
  }
82
+ /** The reminder to keep the plan, last, when the turn's plan has fallen behind (`planReminder`). */
83
+ function projectPlanReminder(request) {
84
+ const reminder = planReminder(request);
85
+ return reminder === undefined
86
+ ? []
87
+ : [freezeItem({ kind: "context", role: "user", content: [textPart(reminder)] })];
88
+ }
79
89
  function projectContext(context) {
80
90
  if (context.items.length === 0)
81
91
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/harness",
3
- "version": "0.34.0-beta",
3
+ "version": "0.35.0-beta",
4
4
  "description": "Nylorun's TypeScript agent execution engine. See github.com/nylorun/agents.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -77,7 +77,7 @@
77
77
  "zod": "^4.6.7"
78
78
  },
79
79
  "dependencies": {
80
- "@nylorun/core": "0.37.0-beta"
80
+ "@nylorun/core": "0.38.0-beta"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "zod": "^4.6.7"