diff --git a/packages/paperclip-runner/src/drivers/acpx/runtime-host.test.ts b/packages/paperclip-runner/src/drivers/acpx/runtime-host.test.ts index 2db1cb51c64..f6b637a4f16 100644 --- a/packages/paperclip-runner/src/drivers/acpx/runtime-host.test.ts +++ b/packages/paperclip-runner/src/drivers/acpx/runtime-host.test.ts @@ -309,11 +309,18 @@ describe("ACPX runtime host", () => { { ...options, runtimeContext: context }, dependencies, ); - const message = JSON.stringify({ + let message = JSON.stringify({ schema: "paperclip.native-model-envelope.v2", task: { description: "Use /assigned", prompt: "A new direct user request" }, interactionResponses: index ? [{ response: { status: "accepted" } }] : [], }); + if (index === 1) { + // The provider command is internal overhead, not part of the caller's + // 1 MiB allowance. Keep the exact envelope even at that boundary. + message += " ".repeat(1024 * 1024 - Buffer.byteLength(message)); + expect(() => host.startTurn({ text: `${message} `, requestId: "oversized" })) + .toThrow("turn text exceeds its bounded size"); + } host.startTurn({ text: message, requestId: `skill-turn-${index}` }); expect(providerStartTurn).toHaveBeenLastCalledWith({ text: `/assigned ${message}`, requestId: `skill-turn-${index}`, diff --git a/packages/paperclip-runner/src/drivers/acpx/runtime-host.ts b/packages/paperclip-runner/src/drivers/acpx/runtime-host.ts index a400499f0db..efc09052a5b 100644 --- a/packages/paperclip-runner/src/drivers/acpx/runtime-host.ts +++ b/packages/paperclip-runner/src/drivers/acpx/runtime-host.ts @@ -649,9 +649,12 @@ export class AcpxRuntimeHost { throw new Error("ACPX runtime host already has an active turn"); } const requestId = boundedRequestId(input.requestId); - const text = boundedTurnText(claudeNativeSkillPrompt( + // Bound caller input before adding the provider's assigned-skill command. + // The command is internal framing; it must not consume the envelope's + // allowance or cause an otherwise valid envelope to be truncated/rejected. + const text = claudeNativeSkillPrompt( boundedTurnText(input.text), this.#claudeSkillNames, - )); + ); const turn = this.#runtime.startTurn({ text, requestId,