Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: delegation note and plan-only requests

ogsamrat4cf92eca6d69
diff --git a/apps/server/src/engine-restraint-notes.e2e.test.ts b/apps/server/src/engine-restraint-notes.e2e.test.ts
index 80849855..9bd67227 100644
--- a/apps/server/src/engine-restraint-notes.e2e.test.ts
+++ b/apps/server/src/engine-restraint-notes.e2e.test.ts
@@ -6,6 +6,7 @@ import { join, resolve } from "node:path";
import { createManagedOpencodeServer, type ManagedOpencodeServer } from "./managed-opencode.js";
import { omnirushSwarmPluginPath } from "./omnirush-extensions-plugin-path.js";
import { OMNIRUSH_AGENT_PROMPT } from "./omnirush-agent-prompt.js";
+import { applyProviderLockAnswer, resetProviderLock } from "./provider-lock.js";
import { OMNIRUSH_TASK_TOOL_NOTE, omnirushSubagentNote } from "./omnirush-swarm.js";
/**
@@ -85,6 +86,8 @@ describeMaybe("delegation rules on the bundled engine (mock provider)", () => {
};
beforeAll(async () => {
+ // The engine serves only the app's own provider while locked; this test serves a mock one.
+ applyProviderLockAnswer({ providers: { locked: false } });
work = mkdtempSync(join(tmpdir(), "restraint-ws-"));
data = mkdtempSync(join(tmpdir(), "restraint-data-"));
provider = Bun.serve({
@@ -136,6 +139,7 @@ describeMaybe("delegation rules on the bundled engine (mock provider)", () => {
}, 120_000);
afterAll(async () => {
+ resetProviderLock();
await engine?.close();
provider?.stop(true);
rmSync(work, { recursive: true, force: true });
diff --git a/apps/server/src/omnirush-agent-prompt.ts b/apps/server/src/omnirush-agent-prompt.ts
index 5e48023a..569dbfaf 100644
--- a/apps/server/src/omnirush-agent-prompt.ts
+++ b/apps/server/src/omnirush-agent-prompt.ts
@@ -37,7 +37,8 @@ Hard rule: never copy private memory into repo files. Store only redacted summar
## Autonomy and persistence
- Treat a request to change, fix, build or check something as an instruction to do it now. Carry the task through in this turn: investigate, make the change, verify it, then report. Do not stop at a plan, an analysis or a partial fix, and do not ask "should I continue?".
-- Do reversible local work (reading, editing files in the workspace, running builds and tests) without asking for confirmation. Ask only when a missing choice would change the result or before an action that is destructive or leaves this machine.
+- Do reversible local work (reading, editing files in the workspace that are under version control or that you created, running builds and tests) without asking for confirmation. Ask only when a missing choice would change the result, or before an action that is destructive, or that sends, posts, pushes, deploys or pays outside this machine.
+- When the user asks only for an explanation, a review or a plan, answer and do not change files.
- When something is ambiguous, pick the most reasonable reading that fits the code and the request, state the assumption in your final answer, and keep going.
- If an approach fails, find out why before trying again: read the error, re-read the code, and change the approach.
@@ -57,6 +58,7 @@ Hard rule: never copy private memory into repo files. Store only redacted summar
- Prefer the dedicated read, grep and glob tools for looking at the project, and keep shell output short (filter or page long output instead of printing it all).
- Use the todo list for tasks with several distinct steps, and keep it current.
- If steps repeat, capture them as a skill following the \`Skill creation:\` instruction in this prompt.
+
## Sub-agents
Do the work yourself by default: one bug, one feature, one refactor, a review or a test run is one task for you, even when it takes many tool calls. A sub-agent starts without your context and its result has to be checked again, so delegating a single coherent task makes the result worse and slower. Use sub-agents only when the user asks for them, or when a large task splits into parts that are truly independent (for example several unrelated bugs in different areas) and each part needs a lot of reading.
diff --git a/apps/server/src/omnirush-runtime-config.test.ts b/apps/server/src/omnirush-runtime-config.test.ts
index d6c98f17..0620b454 100644
--- a/apps/server/src/omnirush-runtime-config.test.ts
+++ b/apps/server/src/omnirush-runtime-config.test.ts
@@ -367,6 +367,9 @@ describe("omnirush runtime config file", () => {
expect(prompt).toContain("Do the work yourself by default");
expect(prompt).toContain("## Autonomy and persistence");
expect(prompt).toContain("Verify before you finish.");
+ expect(prompt).toContain("never report an unrun check as passed");
+ expect(prompt).toContain("## Final answer");
+ expect(prompt).toContain("When the user asks only for an explanation, a review or a plan, answer and do not change files.");
expect(prompt).toContain("make exactly that many task-tool calls, no more and no fewer, and start them all in one message");
expect(prompt).toContain("Never paste the user's whole message, or the user's instructions about sub-agents, into a sub-agent's prompt");
expect(prompt).toContain("Never replace an explicit delegation request with a simulated multi-role answer");
diff --git a/apps/server/src/omnirush-swarm.ts b/apps/server/src/omnirush-swarm.ts
index dd72a235..f865d4f0 100644
--- a/apps/server/src/omnirush-swarm.ts
+++ b/apps/server/src/omnirush-swarm.ts
@@ -217,7 +217,7 @@ export function omnirushSwarmSubagentNote(depth: number): string {
* (every agent that has the tool, main or sub-agent). The engine's own text
* asks for detailed prompts and parallel launches; this bounds both.
*/
-export const OMNIRUSH_TASK_TOOL_NOTE = "Delegation: in the main session, delegate only implementation work. For a feature, bug fix, refactor or other code change beyond a few tool calls, split the implementation into independent parts and start 2-4 sub-agents in one message so they run in parallel. Do investigations, reviews, tests, docs, explanations and quick questions yourself unless the user explicitly asks for sub-agents. When the user names a number of agents, start exactly that many, all in one message. Each prompt covers only its own part and is self-contained: never paste the user's whole message or the user's instructions about sub-agents into it. A sub-agent starts its own sub-agents only when its task explicitly tells it to implement a part.";
+export const OMNIRUSH_TASK_TOOL_NOTE = "Delegation: in the main session, do the work yourself by default: a bug fix, feature, refactor, review or test run is one task, even when it takes many tool calls. Start sub-agents only when the user asks for them, or when a large task splits into truly independent parts that each need a lot of reading. When the user names a number of agents, start exactly that many, all in one message. Each prompt covers only its own part and is self-contained: never paste the user's whole message or the user's instructions about sub-agents into it. A sub-agent starts its own sub-agents only when its task explicitly tells it to implement a part.";
export const OMNIRUSH_SWARM_STATUSES = ["todo", "running", "done", "blocked"] as const;
export type SwarmTaskStatus = (typeof OMNIRUSH_SWARM_STATUSES)[number];
diff --git a/apps/server/src/opencode-plugins/omnirush-swarm.test.ts b/apps/server/src/opencode-plugins/omnirush-swarm.test.ts
index 7a1bb204..904185fb 100644
--- a/apps/server/src/opencode-plugins/omnirush-swarm.test.ts
+++ b/apps/server/src/opencode-plugins/omnirush-swarm.test.ts
@@ -156,7 +156,9 @@ describe("omnirush swarm plugin", () => {
await hooks["tool.definition"]({ toolID: "task" }, task);
expect(task.description).toBe(`Launch a new agent.\n\n${OMNIRUSH_TASK_TOOL_NOTE}`);
expect(OMNIRUSH_TASK_TOOL_NOTE).toContain("start exactly that many, all in one message");
- expect(OMNIRUSH_TASK_TOOL_NOTE).toContain("in the main session, delegate only implementation work");
+ expect(OMNIRUSH_TASK_TOOL_NOTE).toContain("in the main session, do the work yourself by default");
+ expect(OMNIRUSH_TASK_TOOL_NOTE).not.toContain("2-4 sub-agents");
+ expect(OMNIRUSH_TASK_TOOL_NOTE).not.toContain("beyond a few tool calls");
expect(OMNIRUSH_TASK_TOOL_NOTE).toContain("A sub-agent starts its own sub-agents only when its task explicitly tells it to implement a part.");
expect(OMNIRUSH_TASK_TOOL_NOTE).toContain("never paste the user's whole message");
// Sub-agents see this tool text too: it must not invite them to split their task.