pi-better-background-tasks 0.8.0 → 0.9.0
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/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/shared-execution-policy.ts +19 -0
- package/src/tools.ts +1 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,8 +5,10 @@ import { clearBackgroundTasksNavigatorSession, ensureBackgroundTasksNavigator, e
|
|
|
5
5
|
import { resumeScheduledWork, suspendScheduledWork } from "./runtime.js";
|
|
6
6
|
import { observeForegroundSandboxPolicy } from "./sandbox.js";
|
|
7
7
|
import { registerTools } from "./tools.js";
|
|
8
|
+
import { appendExecutionPolicy } from "./shared-execution-policy.js";
|
|
8
9
|
|
|
9
10
|
export default function backgroundTasksExtension(pi: ExtensionAPI): void {
|
|
11
|
+
pi.on("before_agent_start", (event) => ({ systemPrompt: appendExecutionPolicy(event.systemPrompt) }));
|
|
10
12
|
registerBackgroundTasksGoalProvider(pi);
|
|
11
13
|
ensureBackgroundTasksNavigatorProvider(pi);
|
|
12
14
|
// Subscribed at load so a sandbox extension that publishes later is heard, and
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Generated from packages/pi-better-harness/extensions/execution-policy.ts. Do not edit directly.
|
|
2
|
+
/** Harness-wide scheduling guidance, vendored so standalone extensions share it. */
|
|
3
|
+
const EXECUTION_POLICY = [
|
|
4
|
+
"Harness execution policy: concurrency is separate from subagent delegation.",
|
|
5
|
+
"Before multi-unit work, identify ready, authorized, independent units, actual prerequisites, shared mutable resources, and capacity or availability constraints. Represent independently verifiable deliverables (such as each host migration) separately in the plan; do not hide them in one serial rollout step or create dependencies merely from list order.",
|
|
6
|
+
"Start all ready, authorized, non-conflicting units concurrently within known resource limits before waiting for any one to finish. Reassess ready work after launches and results; continue unblocked foreground work instead of polling running tasks. Do not equate one background launch with scheduling all ready work.",
|
|
7
|
+
"Serialize only for a concrete dependency, conflicting writes or ownership, resource or concurrency limit, documented rollout gate, or explicit availability requirement. Record the reason in the plan or explain it to the user. Do not invent a canary or host-by-host availability requirement.",
|
|
8
|
+
"If concurrency raises an unresolved material operational trade-off (for example, draining all hosts could leave no available runners), ask the user once before the affected operations. Continue independent preparation meanwhile. Existing authorization, safety checks, workflow prerequisites, and human-approved rollout constraints remain binding; urgency does not waive them.",
|
|
9
|
+
"Choose the execution mechanism after deciding what can run together: foreground tools for small, tightly coupled, or interactive work; subagents for bounded independent reasoning or implementation when the active delegation mode permits; background tasks for independent long-running commands or waits. Manual delegation forbids proactive subagents, not concurrent foreground tools or background commands. Use available batch or parallel tool interfaces where appropriate and inspect every launch receipt for failures or skipped work.",
|
|
10
|
+
"A unit waiting or failing does not block other ready independent units unless the evidence shows a shared blocker. Preserve each unit's guards and rollback boundary. Before completing verification, the plan, or the goal, inspect and integrate every relevant terminal result or failure; launch is not completion.",
|
|
11
|
+
].join("\n");
|
|
12
|
+
|
|
13
|
+
export function appendExecutionPolicy(systemPrompt: string): string {
|
|
14
|
+
// Inspect the prompt, not module-global state: vendored copies have separate
|
|
15
|
+
// module identities, and every fresh turn or reload needs the policy again.
|
|
16
|
+
return systemPrompt.includes(EXECUTION_POLICY)
|
|
17
|
+
? systemPrompt
|
|
18
|
+
: `${systemPrompt}\n\n${EXECUTION_POLICY}`;
|
|
19
|
+
}
|
package/src/tools.ts
CHANGED
|
@@ -184,6 +184,7 @@ const StatusActionParams = Type.Object({
|
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
const BACKGROUND_ORCHESTRATION_GUIDELINES = [
|
|
187
|
+
"Follow the Harness execution policy when scheduling independent background operations; subagent delegation mode does not require background commands to run serially.",
|
|
187
188
|
"Use background tasks for genuinely long-running processes or repeated checks. Run short commands in the foreground.",
|
|
188
189
|
"When a structured plan is active, keep it as the coordinator ledger: launch relevant background work early, continue unblocked foreground work without polling, and update the plan after inspecting each terminal result or failure.",
|
|
189
190
|
"Do not treat launch as completion of the parent milestone; relevant background work must be terminal, inspected, and integrated before verification or completion.",
|