Skip to content

The open-source app everyone uses to manage agents at work

Stop duplicating wake context in adapter environments (#13891)

Devin Foley4b8ec588f309
diff --git a/doc/DEVELOPING.md b/doc/DEVELOPING.md
index 2fc0f508f0..c5fec8a253 100644
--- a/doc/DEVELOPING.md
+++ b/doc/DEVELOPING.md
@@ -989,6 +989,25 @@ In Vite middleware mode, Paperclip gives HMR a dedicated HTTP server bound to th
When a workspace service runs Paperclip for browser OAuth QA, configure its `expose.urlTemplate` with the canonical URL the browser can reach. Paperclip preserves explicit `PAPERCLIP_PUBLIC_URL` or `BETTER_AUTH_URL` settings; otherwise it uses a valid exposed HTTPS origin (or loopback HTTP) as the managed runtime fallback for Better Auth and `/api/tools/oauth/callback`. Internal service names such as `http://paperclip-dev:<port>` are rejected unless that hostname is genuinely the browser route. Use a unique origin per isolated worktree. See [Execution Workspaces And Runtime Services](../docs/guides/board-operator/execution-workspaces-and-runtime-services.md#browser-reachable-origins-for-oauth-qa) for configuration and verification.
+## Wake Context Delivery
+
+Built-in adapters deliver wake context through the run prompt, including structured
+execution-continuation data. They do not export `PAPERCLIP_WAKE_PAYLOAD_JSON`. A
+large JSON environment entry can prevent the agent process from starting with
+`E2BIG`, even when the same context fits in the prompt transport. Configured values
+for this retired variable are ignored. Scalar runtime variables such as
+`PAPERCLIP_TASK_ID` and `PAPERCLIP_WAKE_REASON` remain available.
+
+Custom instructions that read the retired variable must use the wake payload in
+the prompt instead. This transport change adds no history limits or truncation;
+existing comment windows and resume-delta rendering still apply. Gateway request
+bodies and Hermes prompt-template JSON variables remain supported.
+
+This removes the duplicate environment entry, not every possible `E2BIG` cause.
+Legacy CLI paths that put prompts in command-line arguments (Gemini, Grok, Kimi,
+Pi, and Hermes) still have argument-size limits. ACP turns, SDK requests, and
+CLI paths that use stdin avoid that separate limit for the wake prompt.
+
## Paperclip Runner Adapter Conversion
The experimental Paperclip Runner offers native Codex, OpenCode, and **ACPX
diff --git a/packages/adapter-utils/src/acpx-engine/execute.test.ts b/packages/adapter-utils/src/acpx-engine/execute.test.ts
index 0b52c22e17..98a2007fd3 100644
--- a/packages/adapter-utils/src/acpx-engine/execute.test.ts
+++ b/packages/adapter-utils/src/acpx-engine/execute.test.ts
@@ -133,6 +133,7 @@ function createLocalSandboxRunner(
function buildRuntime(
onSetConfigOption?: (input: { key: string; value: string }) => void,
onEnsureSession?: (input: Record<string, unknown>) => void,
+ onStartTurn?: (input: Record<string, unknown>) => void,
) {
return {
ensureSession: async (input: Record<string, unknown>) => {
@@ -143,13 +144,16 @@ function buildRuntime(
runtimeSessionName: "runtime-session",
});
},
- startTurn: () => ({
- events: (async function* () {
- yield { type: "done", stopReason: "end_turn" };
- })(),
- result: Promise.resolve({ status: "completed", stopReason: "end_turn" }),
- cancel: async () => {},
- }),
+ startTurn: (input: Record<string, unknown>) => {
+ onStartTurn?.(input);
+ return {
+ events: (async function* () {
+ yield { type: "done", stopReason: "end_turn" };
+ })(),
+ result: Promise.resolve({ status: "completed", stopReason: "end_turn" }),
+ cancel: async () => {},
+ };
+ },
setConfigOption: async (input: { key: string; value: string }) => {
onSetConfigOption?.(input);
},
@@ -173,6 +177,7 @@ async function runExecutor(
const runtimeOptions: Record<string, unknown>[] = [];
const configOptions: Array<{ key: string; value: string }> = [];
const sessionInputs: Record<string, unknown>[] = [];
+ const turnInputs: Record<string, unknown>[] = [];
const meta: Record<string, unknown>[] = [];
const logs: Array<{ stream: string; text: string }> = [];
const events: Array<{ eventType: string; payload?: Record<string, unknown> }> = [];
@@ -185,6 +190,7 @@ async function runExecutor(
return buildRuntime(
({ key, value }) => configOptions.push({ key, value }),
(input) => sessionInputs.push(input),
+ (input) => turnInputs.push(input),
) as never;
},
});
@@ -215,7 +221,7 @@ async function runExecutor(
} as never);
expect(result.exitCode).toBe(0);
- return { logs, meta, events, runtimeOptions, configOptions, sessionInputs, result };
+ return { logs, meta, events, runtimeOptions, configOptions, sessionInputs, turnInputs, result };
}
// Under `vi.useFakeTimers()`, setup before `ensureSession` still performs real
@@ -603,7 +609,9 @@ describe("shared ACPX engine runtime behavior", () => {
expect(prompt).toContain("Paperclip runtime note:");
expect(prompt).toContain("PAPERCLIP_AGENT_ID");
expect(prompt).toContain("PAPERCLIP_API_KEY");
- expect(prompt).toContain("PAPERCLIP_WAKE_PAYLOAD_JSON");
+ expect(prompt).not.toContain("PAPERCLIP_WAKE_PAYLOAD_JSON");
+ expect(prompt).toContain("## Paperclip Wake Payload");
+ expect(prompt).toContain("TEST-1");
expect(prompt).toContain("Paperclip API access note:");
expect(prompt).toContain('PAPERCLIP_API_BASE="${PAPERCLIP_API_URL%/}"; PAPERCLIP_API_BASE="${PAPERCLIP_API_BASE%/api}"');
expect(prompt).toContain("$PAPERCLIP_API_BASE/api/agents/me");
@@ -616,6 +624,57 @@ describe("shared ACPX engine runtime behavior", () => {
expect(promptMetrics?.runtimeNoteChars).toBeGreaterThan(0);
});
+ it("keeps large continuation history in ACP turns and preserves resume deltas", async () => {
+ const root = await makeTempRoot();
+ const config = {
+ agent: "claude", cwd: root, stateDir: path.join(root, "state"), mode: "persistent",
+ env: { PAPERCLIP_WAKE_PAYLOAD_JSON: "stale configured wake" },
+ };
+ const messages = Array.from({ length: 50 }, (_, index) => ({
+ id: `message-${index}`, authorType: "user", authorId: "user-1",
+ body: `Message ${index}: ${"context ".repeat(500)} End ${index}.`,
+ createdAt: "2020-01-01T00:00:00.000Z", updatedAt: "2020-01-01T00:00:00.000Z",
+ deleted: false, sourceTrust: { kind: "authenticated_user" },
+ }));
+ const completedActions = Array.from({ length: 50 }, (_, index) => ({
+ runId: "prior-run", receiptId: `receipt-${index}`, operationId: `operation-${index}`,
+ result: { text: `Completed action ${index}` },
+ }));
+ const continuation = {
+ version: 1, companyId: "company-1", issueId: "issue-1",
+ trigger: { reason: "issue_commented", interactionId: null, sourceRunId: null },
+ originCommentIds: [messages[49]!.id], objective: "Preserve all context", messages,
+ interactionOutcomes: [], unresolvedInteractionIds: [], completedWork: null,
+ completedActions, coverage: { kind: "full_task_history", throughCommentId: messages[49]!.id, summaryThroughCommentId: null },
+ };
+ expect(Buffer.byteLength(JSON.stringify(continuation))).toBeGreaterThan(128 * 1024);
+ const context = { taskId: "issue-1", paperclipWake: {
+ reason: "issue_commented", issue: { id: "issue-1" }, executionContinuation: continuation,
+ } };
+ const fresh = await runExecutor(config, { context });
+ const changedMessage = { ...messages[49]!, body: "Updated direction: preserve approval gates." };
+ const resumed = await runExecutor(config, {
+ runtime: { sessionParams: fresh.result.sessionParams },
+ context: { ...context, paperclipWake: { ...context.paperclipWake, executionContinuation: {
+ ...continuation, resumeDelta: { baseRunId: "run-1", messages: [changedMessage] },
+ } } },
+ });
+ expect(resumed.sessionInputs[0]?.resumeSessionId).toBe(fresh.result.sessionId);
+ for (const run of [fresh, resumed]) {
+ const sessionOptions = run.sessionInputs[0]?.sessionOptions as Record<string, unknown>;
+ expect(sessionOptions.env).not.toHaveProperty("PAPERCLIP_WAKE_PAYLOAD_JSON");
+ const prompt = String(run.turnInputs[0]?.text);
+ expect(prompt).not.toContain("stale configured wake");
+ for (const action of completedActions) expect(prompt).toContain(JSON.stringify(action));
+ }
+ const freshPrompt = String(fresh.turnInputs[0]?.text);
+ for (const message of messages) expect(freshPrompt).toContain(JSON.stringify(message));
+ const resumedPrompt = String(resumed.turnInputs[0]?.text);
+ expect(resumedPrompt).toContain(JSON.stringify(changedMessage));
+ expect(resumedPrompt).not.toContain(messages[0]!.body);
+ expect(resumedPrompt).toContain('"kind":"task_history_delta"');
+ });
+
it.each([
["claude", false], ["codex", false], ["claude", true], ["codex", true],
] as const)("keeps %s ACP conversation policy on fresh, resumed, and reset turns (custom=%s)", async (agent, custom) => {
diff --git a/packages/adapter-utils/src/acpx-engine/execute.ts b/packages/adapter-utils/src/acpx-engine/execute.ts
index 509a8dfb16..cacae0af7e 100644
--- a/packages/adapter-utils/src/acpx-engine/execute.ts
+++ b/packages/adapter-utils/src/acpx-engine/execute.ts
@@ -72,7 +72,6 @@ import {
removeMaintainerOnlySkillSymlinks,
rewriteWorkspaceCwdEnvVarsForExecution,
shapePaperclipWorkspaceEnvForExecution,
- stringifyPaperclipWakePayload,
type PaperclipSkillEntry,
} from "@paperclipai/adapter-utils/server-utils";
import { shellQuote } from "@paperclipai/adapter-utils/ssh";
@@ -1928,7 +1927,6 @@ async function buildRuntime(input: {
const linkedIssueIds = Array.isArray(context.issueIds)
? context.issueIds.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
: [];
- const wakePayloadJson = stringifyPaperclipWakePayload(context.paperclipWake);
const issueWorkMode = readPaperclipIssueWorkModeFromContext(context);
if (wakeTaskId) env.PAPERCLIP_TASK_ID = wakeTaskId;
if (issueWorkMode) env.PAPERCLIP_ISSUE_WORK_MODE = issueWorkMode;
@@ -1937,7 +1935,6 @@ async function buildRuntime(input: {
if (approvalId) env.PAPERCLIP_APPROVAL_ID = approvalId;
if (approvalStatus) env.PAPERCLIP_APPROVAL_STATUS = approvalStatus;
if (linkedIssueIds.length > 0) env.PAPERCLIP_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
- if (wakePayloadJson) env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
applyPaperclipWorkspaceEnv(env, {
workspaceCwd: shapedWorkspaceEnv.workspaceCwd,
workspaceSource,
diff --git a/packages/adapter-utils/src/server-utils.test.ts b/packages/adapter-utils/src/server-utils.test.ts
index b694c871be..85d28d1d43 100644
--- a/packages/adapter-utils/src/server-utils.test.ts
+++ b/packages/adapter-utils/src/server-utils.test.ts
@@ -3717,6 +3717,16 @@ describe("refreshPaperclipWorkspaceEnvForExecution", () => {
expect(env.PAPERCLIP_CLOUD_PROVIDER_TOKEN).toBe("cloud-token");
});
+ it("does not restore the retired wake JSON variable from config", () => {
+ const env: Record<string, string> = {};
+ refreshPaperclipWorkspaceEnvForExecution({
+ env,
+ envConfig: { PAPERCLIP_WAKE_PAYLOAD_JSON: "stale wake" },
+ workspaceCwd: null,
+ });
+ expect(env).not.toHaveProperty("PAPERCLIP_WAKE_PAYLOAD_JSON");
+ });
+
it("never accepts PAPERCLIP_API_KEY from config env", () => {
const env: Record<string, string> = {};
diff --git a/packages/adapter-utils/src/server-utils.ts b/packages/adapter-utils/src/server-utils.ts
index e45d008f8f..5a50f818a5 100644
--- a/packages/adapter-utils/src/server-utils.ts
+++ b/packages/adapter-utils/src/server-utils.ts
@@ -162,10 +162,12 @@ export function isPaperclipRuntimeEnvKey(key: string): boolean {
// PAPERCLIP_API_KEY is never accepted from adapter/user config env: the
// harness-minted run token is the only source of Paperclip API identity.
+// PAPERCLIP_WAKE_PAYLOAD_JSON is retired: wake context travels in the prompt,
+// and a configured copy can exceed OS process-launch limits.
// Other PAPERCLIP_*-named config keys are allowed as long as Paperclip has
// not assigned the same key for the run (runtime vars always win).
export function isForbiddenConfigEnvKey(key: string): boolean {
- return key === "PAPERCLIP_API_KEY";
+ return key === "PAPERCLIP_API_KEY" || key === "PAPERCLIP_WAKE_PAYLOAD_JSON";
}
const PAPERCLIP_SKILL_ROOT_RELATIVE_CANDIDATES = [
"../../skills",
@@ -1919,7 +1921,7 @@ export function stringifyPaperclipWakePayload(
value: unknown,
options: {
// For prompt-embedded copies of the payload on lanes where another prompt
- // section already carries the issue description; the env-var copy should
+ // section already carries the issue description. Other serialized copies
// stay complete.
omitIssueDescription?: boolean;
} = {},
diff --git a/packages/adapters/claude-local/src/server/execute.ts b/packages/adapters/claude-local/src/server/execute.ts
index c9387b6e07..8d8291fad6 100644
--- a/packages/adapters/claude-local/src/server/execute.ts
+++ b/packages/adapters/claude-local/src/server/execute.ts
@@ -48,7 +48,6 @@ import {
selectPaperclipTaskMarkdown,
rewriteWorkspaceCwdEnvVarsForExecution,
shapePaperclipWorkspaceEnvForExecution,
- stringifyPaperclipWakePayload,
DEFAULT_PAPERCLIP_AGENT_PROMPT_TEMPLATE,
DEFAULT_PAPERCLIP_CONVERSATION_PROMPT_TEMPLATE,
} from "@paperclipai/adapter-utils/server-utils";
@@ -241,7 +240,6 @@ async function buildClaudeRuntimeConfig(input: ClaudeExecutionInput): Promise<Cl
const linkedIssueIds = Array.isArray(context.issueIds)
? context.issueIds.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
: [];
- const wakePayloadJson = stringifyPaperclipWakePayload(context.paperclipWake);
const issueWorkMode = readPaperclipIssueWorkModeFromContext(context);
if (wakeTaskId) {
@@ -265,9 +263,6 @@ async function buildClaudeRuntimeConfig(input: ClaudeExecutionInput): Promise<Cl
if (linkedIssueIds.length > 0) {
env.PAPERCLIP_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
}
- if (wakePayloadJson) {
- env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
- }
applyPaperclipWorkspaceEnv(env, {
workspaceCwd: shapedWorkspaceEnv.workspaceCwd,
workspaceSource,
diff --git a/packages/adapters/codex-local/src/server/execute.ts b/packages/adapters/codex-local/src/server/execute.ts
index 72ac42e5eb..8e8e4954e8 100644
--- a/packages/adapters/codex-local/src/server/execute.ts
+++ b/packages/adapters/codex-local/src/server/execute.ts
@@ -47,7 +47,6 @@ import {
renderPaperclipWakePrompt,
selectPaperclipTaskMarkdown,
isPaperclipRecoveryWakePayload,
- stringifyPaperclipWakePayload,
DEFAULT_PAPERCLIP_AGENT_PROMPT_TEMPLATE,
DEFAULT_PAPERCLIP_CONVERSATION_PROMPT_TEMPLATE,
joinPromptSections,
@@ -915,7 +914,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
const linkedIssueIds = Array.isArray(context.issueIds)
? context.issueIds.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
: [];
- const wakePayloadJson = stringifyPaperclipWakePayload(context.paperclipWake);
const issueWorkMode = readPaperclipIssueWorkModeFromContext(context);
if (wakeTaskId) {
env.PAPERCLIP_TASK_ID = wakeTaskId;
@@ -938,9 +936,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (linkedIssueIds.length > 0) {
env.PAPERCLIP_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
}
- if (wakePayloadJson) {
- env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
- }
refreshPaperclipWorkspaceEnvForExecution({
env,
envConfig,
diff --git a/packages/adapters/cursor-cloud/src/server/execute.test.ts b/packages/adapters/cursor-cloud/src/server/execute.test.ts
index 4798477b21..708c60749a 100644
--- a/packages/adapters/cursor-cloud/src/server/execute.test.ts
+++ b/packages/adapters/cursor-cloud/src/server/execute.test.ts
@@ -168,6 +168,22 @@ describe("cursor_cloud execute", () => {
expect(prompt).not.toContain("Create child issues");
});
+ it("delivers a large wake through the SDK prompt without a configured JSON env copy", async () => {
+ const sdkAgent = createMockSdkAgent();
+ createMock.mockResolvedValue(sdkAgent);
+ const ctx = createContext();
+ const description = "start " + "context ".repeat(25_000) + " end";
+ ctx.config.env = { CURSOR_API_KEY: "cursor-secret", PAPERCLIP_WAKE_PAYLOAD_JSON: description };
+ ctx.context.paperclipWake = {
+ reason: "issue_assigned",
+ issue: { id: "issue-1", description },
+ };
+ const result = await execute(ctx);
+ expect(result.exitCode).toBe(0);
+ expect(createMock.mock.calls[0]?.[0]?.cloud?.envVars).not.toHaveProperty("PAPERCLIP_WAKE_PAYLOAD_JSON");
+ expect(sdkAgent.send.mock.calls[0]?.[0]).toContain(description);
+ });
+
it("creates a fresh Cursor agent and injects Paperclip env without CURSOR_API_KEY", async () => {
const run = createMockRun({
agentId: "agent-fresh",
diff --git a/packages/adapters/cursor-cloud/src/server/execute.ts b/packages/adapters/cursor-cloud/src/server/execute.ts
index f9dad07806..f662101bda 100644
--- a/packages/adapters/cursor-cloud/src/server/execute.ts
+++ b/packages/adapters/cursor-cloud/src/server/execute.ts
@@ -25,7 +25,6 @@ import {
selectInitialCommunicationGuidance,
isPaperclipRecoveryWakePayload,
renderTemplate,
- stringifyPaperclipWakePayload,
} from "@paperclipai/adapter-utils/server-utils";
type CursorCloudSession = {
@@ -116,6 +115,8 @@ function buildWakeEnv(ctx: AdapterExecutionContext, configEnv: Record<string, st
// PAPERCLIP_API_KEY is never accepted from config — the harness-minted run
// token is the only source of Paperclip API identity.
delete env.PAPERCLIP_API_KEY;
+ // Wake context travels in the prompt; a configured copy can exceed spawn limits.
+ delete env.PAPERCLIP_WAKE_PAYLOAD_JSON;
const wakeTaskId = trimNullable(context.taskId) ?? trimNullable(context.issueId);
const wakeReason = trimNullable(context.wakeReason);
@@ -125,7 +126,6 @@ function buildWakeEnv(ctx: AdapterExecutionContext, configEnv: Record<string, st
const linkedIssueIds = Array.isArray(context.issueIds)
? context.issueIds.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
: [];
- const wakePayloadJson = stringifyPaperclipWakePayload(context.paperclipWake);
const issueWorkMode = readPaperclipIssueWorkModeFromContext(context);
if (wakeTaskId) env.PAPERCLIP_TASK_ID = wakeTaskId;
@@ -134,7 +134,6 @@ function buildWakeEnv(ctx: AdapterExecutionContext, configEnv: Record<string, st
if (approvalId) env.PAPERCLIP_APPROVAL_ID = approvalId;
if (approvalStatus) env.PAPERCLIP_APPROVAL_STATUS = approvalStatus;
if (linkedIssueIds.length > 0) env.PAPERCLIP_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
- if (wakePayloadJson) env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
if (issueWorkMode) env.PAPERCLIP_ISSUE_WORK_MODE = issueWorkMode;
if (authToken) {
env.PAPERCLIP_API_KEY = authToken;
diff --git a/packages/adapters/cursor-local/src/server/execute.ts b/packages/adapters/cursor-local/src/server/execute.ts
index 9469c87a6e..872d3779c7 100644
--- a/packages/adapters/cursor-local/src/server/execute.ts
+++ b/packages/adapters/cursor-local/src/server/execute.ts
@@ -47,7 +47,6 @@ import {
selectPaperclipTaskMarkdown,
selectInitialCommunicationGuidance,
isPaperclipRecoveryWakePayload,
- stringifyPaperclipWakePayload,
DEFAULT_PAPERCLIP_AGENT_PROMPT_TEMPLATE,
DEFAULT_PAPERCLIP_CONVERSATION_PROMPT_TEMPLATE,
joinPromptSections,
@@ -275,7 +274,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
const linkedIssueIds = Array.isArray(context.issueIds)
? context.issueIds.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
: [];
- const wakePayloadJson = stringifyPaperclipWakePayload(context.paperclipWake);
const issueWorkMode = readPaperclipIssueWorkModeFromContext(context);
if (wakeTaskId) {
env.PAPERCLIP_TASK_ID = wakeTaskId;
@@ -298,9 +296,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (linkedIssueIds.length > 0) {
env.PAPERCLIP_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
}
- if (wakePayloadJson) {
- env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
- }
refreshPaperclipWorkspaceEnvForExecution({
env,
envConfig,
diff --git a/packages/adapters/gemini-local/src/server/execute.ts b/packages/adapters/gemini-local/src/server/execute.ts
index c90fe08716..901fa10c1a 100644
--- a/packages/adapters/gemini-local/src/server/execute.ts
+++ b/packages/adapters/gemini-local/src/server/execute.ts
@@ -50,7 +50,6 @@ import {
selectPaperclipTaskMarkdown,
selectInitialCommunicationGuidance,
isPaperclipRecoveryWakePayload,
- stringifyPaperclipWakePayload,
DEFAULT_PAPERCLIP_AGENT_PROMPT_TEMPLATE,
DEFAULT_PAPERCLIP_CONVERSATION_PROMPT_TEMPLATE,
runChildProcess,
@@ -299,7 +298,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
const linkedIssueIds = Array.isArray(context.issueIds)
? context.issueIds.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
: [];
- const wakePayloadJson = stringifyPaperclipWakePayload(context.paperclipWake);
const issueWorkMode = readPaperclipIssueWorkModeFromContext(context);
if (wakeTaskId) env.PAPERCLIP_TASK_ID = wakeTaskId;
if (issueWorkMode) env.PAPERCLIP_ISSUE_WORK_MODE = issueWorkMode;
@@ -308,7 +306,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (approvalId) env.PAPERCLIP_APPROVAL_ID = approvalId;
if (approvalStatus) env.PAPERCLIP_APPROVAL_STATUS = approvalStatus;
if (linkedIssueIds.length > 0) env.PAPERCLIP_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
- if (wakePayloadJson) env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
refreshPaperclipWorkspaceEnvForExecution({
env,
envConfig,
diff --git a/packages/adapters/grok-local/src/server/execute.ts b/packages/adapters/grok-local/src/server/execute.ts
index 0fbc388e14..4cd9934750 100644
--- a/packages/adapters/grok-local/src/server/execute.ts
+++ b/packages/adapters/grok-local/src/server/execute.ts
@@ -38,7 +38,6 @@ import {
selectInitialCommunicationGuidance,
isPaperclipRecoveryWakePayload,
resolveLegacyPaperclipDesiredSkillNames,
- stringifyPaperclipWakePayload,
refreshPaperclipWorkspaceEnvForExecution,
DEFAULT_PAPERCLIP_AGENT_PROMPT_TEMPLATE,
DEFAULT_PAPERCLIP_CONVERSATION_PROMPT_TEMPLATE,
@@ -286,7 +285,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
const linkedIssueIds = Array.isArray(context.issueIds)
? context.issueIds.filter((value: unknown): value is string => typeof value === "string" && value.trim().length > 0)
: [];
- const wakePayloadJson = stringifyPaperclipWakePayload(context.paperclipWake);
const issueWorkMode = readPaperclipIssueWorkModeFromContext(context);
if (wakeTaskId) env.PAPERCLIP_TASK_ID = wakeTaskId;
if (issueWorkMode) env.PAPERCLIP_ISSUE_WORK_MODE = issueWorkMode;
@@ -295,7 +293,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (approvalId) env.PAPERCLIP_APPROVAL_ID = approvalId;
if (approvalStatus) env.PAPERCLIP_APPROVAL_STATUS = approvalStatus;
if (linkedIssueIds.length > 0) env.PAPERCLIP_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
- if (wakePayloadJson) env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
refreshPaperclipWorkspaceEnvForExecution({
env,
envConfig,
diff --git a/packages/adapters/hermes/src/server/execute.onspawn.test.ts b/packages/adapters/hermes/src/server/execute.onspawn.test.ts
index a919ddd236..1adf450a50 100644
--- a/packages/adapters/hermes/src/server/execute.onspawn.test.ts
+++ b/packages/adapters/hermes/src/server/execute.onspawn.test.ts
@@ -104,6 +104,15 @@ describe("hermes-local adapter onSpawn forwarding", () => {
expect(opts.onSpawn).toBe(onSpawn);
});
+ it("keeps wake data in the prompt and drops configured JSON env copies", async () => {
+ const { ctx } = makeCtx({ env: { PAPERCLIP_WAKE_PAYLOAD_JSON: "stale configured wake" } });
+ const wake = { reason: "issue_assigned", issue: { id: "issue-1", description: "Current task brief" } };
+ await execute({ ...ctx, context: { ...ctx.context, paperclipWake: wake } } as any);
+ const call = vi.mocked(serverUtils.runChildProcess).mock.calls.at(-1)!;
+ expect(call[3].env).not.toHaveProperty("PAPERCLIP_WAKE_PAYLOAD_JSON");
+ expect(call[2]).toContainEqual(expect.stringContaining("Current task brief"));
+ });
+
it("runChildProcess opts type includes onSpawn", () => {
// Type-level assertion: if onSpawn were removed from the type,
// this file would fail to compile. The runtime test above catches
diff --git a/packages/adapters/hermes/src/server/execute.ts b/packages/adapters/hermes/src/server/execute.ts
index ea54e574e5..3cf6818e1e 100644
--- a/packages/adapters/hermes/src/server/execute.ts
+++ b/packages/adapters/hermes/src/server/execute.ts
@@ -499,6 +499,8 @@ export async function execute(
// PAPERCLIP_API_KEY is never accepted from config — the harness-minted run
// token is the only source of Paperclip API identity.
delete env.PAPERCLIP_API_KEY;
+ // Wake context travels in the prompt; drop both inherited and configured copies.
+ delete env.PAPERCLIP_WAKE_PAYLOAD_JSON;
if ((ctx as any).authToken) env.PAPERCLIP_API_KEY = (ctx as any).authToken;
// BUG FIX: Read task context from ctx.context (wake context), not ctx.config (adapter config)
@@ -509,8 +511,6 @@ export async function execute(
if (envWakeReason) env.PAPERCLIP_WAKE_REASON = envWakeReason;
const envCommentId = cfgString(ctxContext.commentId) || cfgString(ctxContext.wakeCommentId) || cfgString(ctx.config?.commentId);
if (envCommentId) env.PAPERCLIP_WAKE_COMMENT_ID = envCommentId;
- const wakePayloadJson = stringifyPaperclipWakePayload(ctxContext.paperclipWake);
- if (wakePayloadJson) env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
// ── Resolve working directory ──────────────────────────────────────────
const cwd =
diff --git a/packages/adapters/kimi-local/src/server/execute.ts b/packages/adapters/kimi-local/src/server/execute.ts
index 0435cd3dd7..732f4ca0a2 100644
--- a/packages/adapters/kimi-local/src/server/execute.ts
+++ b/packages/adapters/kimi-local/src/server/execute.ts
@@ -42,7 +42,6 @@ import {
selectPaperclipTaskMarkdown,
selectInitialCommunicationGuidance,
isPaperclipRecoveryWakePayload,
- stringifyPaperclipWakePayload,
DEFAULT_PAPERCLIP_AGENT_PROMPT_TEMPLATE,
DEFAULT_PAPERCLIP_CONVERSATION_PROMPT_TEMPLATE,
} from "@paperclipai/adapter-utils/server-utils";
@@ -272,7 +271,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
const linkedIssueIds = Array.isArray(context.issueIds)
? context.issueIds.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
: [];
- const wakePayloadJson = stringifyPaperclipWakePayload(context.paperclipWake);
const issueWorkMode = readPaperclipIssueWorkModeFromContext(context);
if (wakeTaskId) env.PAPERCLIP_TASK_ID = wakeTaskId;
if (issueWorkMode) env.PAPERCLIP_ISSUE_WORK_MODE = issueWorkMode;
@@ -281,7 +279,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (approvalId) env.PAPERCLIP_APPROVAL_ID = approvalId;
if (approvalStatus) env.PAPERCLIP_APPROVAL_STATUS = approvalStatus;
if (linkedIssueIds.length > 0) env.PAPERCLIP_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
- if (wakePayloadJson) env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
refreshPaperclipWorkspaceEnvForExecution({
env,
envConfig,
diff --git a/packages/adapters/opencode-local/src/server/execute.ts b/packages/adapters/opencode-local/src/server/execute.ts
index 76f33afa4d..7ce3ab0b36 100644
--- a/packages/adapters/opencode-local/src/server/execute.ts
+++ b/packages/adapters/opencode-local/src/server/execute.ts
@@ -43,7 +43,6 @@ import {
selectPaperclipTaskMarkdown,
selectInitialCommunicationGuidance,
isPaperclipRecoveryWakePayload,
- stringifyPaperclipWakePayload,
DEFAULT_PAPERCLIP_AGENT_PROMPT_TEMPLATE,
DEFAULT_PAPERCLIP_CONVERSATION_PROMPT_TEMPLATE,
runChildProcess,
@@ -298,7 +297,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
const linkedIssueIds = Array.isArray(context.issueIds)
? context.issueIds.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
: [];
- const wakePayloadJson = stringifyPaperclipWakePayload(context.paperclipWake);
const issueWorkMode = readPaperclipIssueWorkModeFromContext(context);
if (wakeTaskId) env.PAPERCLIP_TASK_ID = wakeTaskId;
if (issueWorkMode) env.PAPERCLIP_ISSUE_WORK_MODE = issueWorkMode;
@@ -307,7 +305,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (approvalId) env.PAPERCLIP_APPROVAL_ID = approvalId;
if (approvalStatus) env.PAPERCLIP_APPROVAL_STATUS = approvalStatus;
if (linkedIssueIds.length > 0) env.PAPERCLIP_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
- if (wakePayloadJson) env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
refreshPaperclipWorkspaceEnvForExecution({
env,
envConfig,
diff --git a/packages/adapters/pi-local/src/server/execute.ts b/packages/adapters/pi-local/src/server/execute.ts
index 4787d44995..54f3fede44 100644
--- a/packages/adapters/pi-local/src/server/execute.ts
+++ b/packages/adapters/pi-local/src/server/execute.ts
@@ -48,7 +48,6 @@ import {
selectPaperclipTaskMarkdown,
selectInitialCommunicationGuidance,
isPaperclipRecoveryWakePayload,
- stringifyPaperclipWakePayload,
DEFAULT_PAPERCLIP_AGENT_PROMPT_TEMPLATE,
DEFAULT_PAPERCLIP_CONVERSATION_PROMPT_TEMPLATE,
runChildProcess,
@@ -303,7 +302,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
const linkedIssueIds = Array.isArray(context.issueIds)
? context.issueIds.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
: [];
- const wakePayloadJson = stringifyPaperclipWakePayload(context.paperclipWake);
const issueWorkMode = readPaperclipIssueWorkModeFromContext(context);
if (wakeTaskId) env.PAPERCLIP_TASK_ID = wakeTaskId;
@@ -313,7 +311,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (approvalId) env.PAPERCLIP_APPROVAL_ID = approvalId;
if (approvalStatus) env.PAPERCLIP_APPROVAL_STATUS = approvalStatus;
if (linkedIssueIds.length > 0) env.PAPERCLIP_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
- if (wakePayloadJson) env.PAPERCLIP_WAKE_PAYLOAD_JSON = wakePayloadJson;
refreshPaperclipWorkspaceEnvForExecution({
env,
envConfig,
diff --git a/packages/paperclip-runner/docs/design/standalone-thin-paperclip-adapter.md b/packages/paperclip-runner/docs/design/standalone-thin-paperclip-adapter.md
index 82f3a43432..c0354eb2a6 100644
--- a/packages/paperclip-runner/docs/design/standalone-thin-paperclip-adapter.md
+++ b/packages/paperclip-runner/docs/design/standalone-thin-paperclip-adapter.md
@@ -315,8 +315,8 @@ The runner, package driver, and model/harness never receive:
- the local agent JWT, `PAPERCLIP_API_KEY`, a board session, or a board API key;
- managed MCP gateway credentials, runner-lease/bootstrap credentials, or
credential-broker secret material;
-- `PAPERCLIP_WAKE_PAYLOAD_JSON`, rendered Paperclip wake text, Paperclip skill
- instructions, the Paperclip API manual, or run-scoped skill material;
+- rendered Paperclip wake text, Paperclip skill instructions, the Paperclip API
+ manual, or run-scoped skill material;
- raw `process.env`, agent/project/routine env maps, `runtimeConfig.env`, or the
legacy adapter's generic execution context;
- authority to choose a company, issue, agent, policy, approval, or status;
diff --git a/server/src/__tests__/codex-local-execute.test.ts b/server/src/__tests__/codex-local-execute.test.ts
index 9f2d25e013..b276e755f3 100644
--- a/server/src/__tests__/codex-local-execute.test.ts
+++ b/server/src/__tests__/codex-local-execute.test.ts
@@ -538,7 +538,7 @@ describe("codex execute", () => {
}
});
- it("injects structured Paperclip wake payloads into env and prompt", async () => {
+ it.each([false, true])("delivers oversized wake context through stdin (sandbox=%s)", async (sandbox) => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), "paperclip-codex-execute-wake-"));
const workspace = path.join(root, "workspace");
const commandPath = path.join(root, "codex");
@@ -546,6 +546,8 @@ describe("codex execute", () => {
await fs.mkdir(workspace, { recursive: true });
await writeFakeCodexCommand(commandPath);
+ const description = "begin " + "full wake context ".repeat(16_384) + " end";
+ expect(Buffer.byteLength(description)).toBeGreaterThan(128 * 1024);
const previousHome = process.env.HOME;
process.env.HOME = root;
await seedSharedCodexAuth(root);
@@ -572,6 +574,7 @@ describe("codex execute", () => {
cwd: workspace,
env: {
PAPERCLIP_TEST_CAPTURE_PATH: capturePath,
+ PAPERCLIP_WAKE_PAYLOAD_JSON: description,
},
promptTemplate: "Follow the paperclip heartbeat.",
},
@@ -585,7 +588,8 @@ describe("codex execute", () => {
issue: {
id: "issue-1",
identifier: "PAP-874",
- title: "chat-speed issues",
+ title: "Wake context test",
+ description,
status: "in_progress",
priority: "medium",
},
@@ -618,6 +622,16 @@ describe("codex execute", () => {
fallbackFetchNeeded: false,
},
},
+ executionTarget: sandbox ? {
+ kind: "remote",
+ transport: "sandbox",
+ providerKey: "test",
+ environmentId: "env-1",
+ leaseId: "lease-1",
+ remoteCwd: workspace,
+ timeoutMs: 30_000,
+ runner: createLocalSandboxRunner(),
+ } : undefined,
authToken: "run-jwt-token",
onLog: async () => {},
});
@@ -626,13 +640,10 @@ describe("codex execute", () => {
expect(result.errorMessage).toBeNull();
const capture = JSON.parse(await fs.readFile(capturePath, "utf8")) as CapturePayload;
- expect(capture.paperclipEnvKeys).toContain("PAPERCLIP_WAKE_PAYLOAD_JSON");
- expect(capture.paperclipWakePayloadJson).not.toBeNull();
- expect(JSON.parse(capture.paperclipWakePayloadJson ?? "{}")).toMatchObject({
- reason: "issue_commented",
- latestCommentId: "comment-2",
- commentIds: ["comment-1", "comment-2"],
- });
+ expect(capture.paperclipEnvKeys).not.toContain("PAPERCLIP_WAKE_PAYLOAD_JSON");
+ expect(capture.paperclipWakePayloadJson).toBeNull();
+ expect(capture.prompt).toContain(description);
+ expect(capture.prompt).toContain("- reason: issue_commented");
expect(capture.prompt).toContain("## Paperclip Wake Payload");
expect(capture.prompt).toContain("Use this wake to continue the task, applying new user direction and preserving its approval gates.");
expect(capture.prompt).toContain("Do not switch to another issue until you have handled this wake.");
@@ -1216,19 +1227,8 @@ process.exit(1);
expect(result.errorMessage).toBeNull();
const capture = JSON.parse(await fs.readFile(capturePath, "utf8")) as CapturePayload;
- expect(capture.paperclipEnvKeys).toContain("PAPERCLIP_WAKE_PAYLOAD_JSON");
- expect(capture.paperclipWakePayloadJson).not.toBeNull();
- expect(JSON.parse(capture.paperclipWakePayloadJson ?? "{}")).toMatchObject({
- reason: "issue_assigned",
- issue: {
- identifier: "PAP-1201",
- title: "Fix gallery opening for inline images",
- status: "in_progress",
- priority: "medium",
- },
- checkedOutByHarness: true,
- commentIds: [],
- });
+ expect(capture.paperclipEnvKeys).not.toContain("PAPERCLIP_WAKE_PAYLOAD_JSON");
+ expect(capture.paperclipWakePayloadJson).toBeNull();
expect(capture.prompt).toContain("## Paperclip Wake Payload");
expect(capture.prompt).toContain("Do not switch to another issue until you have handled this wake.");
expect(capture.prompt).toContain("- issue: PAP-1201 Fix gallery opening for inline images");
diff --git a/skills/paperclip/SKILL.md b/skills/paperclip/SKILL.md
index 0c7ceab69f..f6186e2aa8 100644
--- a/skills/paperclip/SKILL.md
+++ b/skills/paperclip/SKILL.md
@@ -19,7 +19,7 @@ In Paperclip, **task** and **issue** refer to the same work item. The UI may use
Env vars auto-injected: `PAPERCLIP_AGENT_ID`, `PAPERCLIP_COMPANY_ID`, `PAPERCLIP_API_URL`, `PAPERCLIP_RUN_ID`. Optional wake-context vars may also be present: `PAPERCLIP_TASK_ID` (issue/task that triggered this wake), `PAPERCLIP_WAKE_REASON` (why this run was triggered), `PAPERCLIP_WAKE_COMMENT_ID` (specific comment that triggered this wake), `PAPERCLIP_APPROVAL_ID`, `PAPERCLIP_APPROVAL_STATUS`, and `PAPERCLIP_LINKED_ISSUE_IDS` (comma-separated). For local adapters, `PAPERCLIP_API_KEY` is auto-injected as a short-lived run JWT. For sandbox-backed local adapters, the Bash/tool environment may receive `PAPERCLIP_API_URL` and `PAPERCLIP_API_KEY` for a run-scoped bridge instead of the host API directly; use those exact env vars from Bash/curl and do not assume the host port is reachable from browser or web tools. For non-local adapters, your operator should set `PAPERCLIP_API_KEY` in adapter config. All requests use `Authorization: Bearer $PAPERCLIP_API_KEY`. All endpoints are under `/api`. Use JSON except for multipart attachment uploads and binary content downloads. Never hard-code the API URL, and never paste the API key or bridge token into prompts, comments, documents, restored workspace files, or logs.
-Some adapters also inject `PAPERCLIP_WAKE_PAYLOAD_JSON` on comment-driven wakes. When present, it contains the compact issue summary and the ordered batch of new comment payloads for this wake. Use it first. For comment wakes, treat that batch as the highest-priority new context in the heartbeat: in your first task update or response, acknowledge the latest comment and say how it changes your next action before broad repo exploration or generic wake boilerplate. Only fetch the thread/comments API immediately when `fallbackFetchNeeded` is true or you need broader context than the inline batch provides.
+Adapters deliver the wake payload in the run prompt. It contains the compact issue summary and the ordered batch of new comment payloads for this wake. Read that prompt section first. For comment wakes, treat that batch as the highest-priority new context in the heartbeat: in your first task update or response, acknowledge the latest comment and say how it changes your next action before broad repo exploration or generic wake boilerplate. Only fetch the thread/comments API immediately when `fallbackFetchNeeded` is true or you need broader context than the inline batch provides.
Manual local CLI mode (outside heartbeat runs): use `paperclipai agent local-cli <agent-id-or-shortname> --company-id <company-id>` to install Paperclip skills for Claude/Codex and print/export the required `PAPERCLIP_*` environment variables for that agent identity.
@@ -127,7 +127,7 @@ If already checked out by you, returns normally. If owned by another agent: `409
**Step 6 — Understand context.** Prefer `GET /api/issues/{issueId}/heartbeat-context` first. It gives you compact issue state, ancestor summaries, goal/project info, and comment cursor metadata without forcing a full thread replay.
-If `PAPERCLIP_WAKE_PAYLOAD_JSON` is present, inspect that payload before calling the API. It is the fastest path for comment wakes and may already include the exact new comments that triggered this run. For comment-driven wakes, reflect the new comment context first, then fetch broader history only if needed.
+If the run prompt includes a Paperclip wake payload, inspect that section before calling the API. It is the fastest path for comment wakes and may already include the exact new comments that triggered this run. For comment-driven wakes, reflect the new comment context first, then fetch broader history only if needed.
Use comments incrementally: