mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-04 04:29:01 +01:00
fix(runner): preserve error envelopes only for ACPX delivery
Keep Codex JSON errors compatible with recovered API receipts while forwarding the bounded failure envelope needed by ACPX providers. Reproduced the CI regression red and verified the focused transport tests green. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
0e2e413cd5
commit
ed8bf0cd17
2 files changed
+28
-22
No files matched your search
@@ -4042,7 +4042,7 @@ export function unwrapToolResponse(response: Record<string, unknown>, preserveEn
|
||||
const value = record(items[0]).text;
|
||||
let result: unknown = response;
|
||||
try {
|
||||
if (!preserveEnvelope && response.success !== false && typeof value === "string") result = JSON.parse(value);
|
||||
if (!preserveEnvelope && typeof value === "string") result = JSON.parse(value);
|
||||
} catch {
|
||||
result = response;
|
||||
}
|
||||
@@ -7796,28 +7796,29 @@ class DurablePrpCodexTransport implements CodexAppServerTransport {
|
||||
return staleTerminalCallResult(call.operationId, settled.unseen, settled.pending);
|
||||
}
|
||||
}
|
||||
const response = await this.#handler({
|
||||
id: call.callId,
|
||||
method: "item/tool/call",
|
||||
params: {
|
||||
threadId,
|
||||
turnId: this.#turnId,
|
||||
callId: call.callId,
|
||||
tool: call.operationId,
|
||||
arguments: call.input,
|
||||
},
|
||||
...(call.sourceEventId && call.sourceEventType
|
||||
? {
|
||||
paperclipTrace: {
|
||||
sourceEventId: call.sourceEventId,
|
||||
sourceEventType: call.sourceEventType,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
const outcome = unwrapToolResponse(
|
||||
await this.#handler({
|
||||
id: call.callId,
|
||||
method: "item/tool/call",
|
||||
params: {
|
||||
threadId,
|
||||
turnId: this.#turnId,
|
||||
callId: call.callId,
|
||||
tool: call.operationId,
|
||||
arguments: call.input,
|
||||
},
|
||||
...(call.sourceEventId && call.sourceEventType
|
||||
? {
|
||||
paperclipTrace: {
|
||||
sourceEventId: call.sourceEventId,
|
||||
sourceEventType: call.sourceEventType,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
}),
|
||||
response,
|
||||
this.options.provider === "acpx" &&
|
||||
(call.operationId === "paperclip_finish" || call.operationId === "paperclip_block"),
|
||||
(response.success === false || call.operationId === "paperclip_finish" || call.operationId === "paperclip_block"),
|
||||
);
|
||||
return this.#bindSemanticToolOutcome(call, outcome);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@ describe("runnerd semantic tool response", () => {
|
||||
|
||||
it.each(["Call connections_search and use the saved draft ID.", '{"error":"Specify exact toolNames"}'])("preserves the provider-facing error envelope: %s", text => {
|
||||
const response = { success: false, contentItems: [{ type: "inputText", text }] };
|
||||
expect(unwrapToolResponse(response)).toEqual({ __paperclipSemanticToolOutcome: true, isError: true, result: response });
|
||||
expect(unwrapToolResponse(response, true)).toEqual({ __paperclipSemanticToolOutcome: true, isError: true, result: response });
|
||||
});
|
||||
|
||||
it("keeps the Codex JSON error result compatible with recovered receipts", () => {
|
||||
const response = { success: false, contentItems: [{ type: "inputText", text: '{"error":"saved failure"}' }] };
|
||||
expect(unwrapToolResponse(response)).toMatchObject({ isError: true, result: { error: "saved failure" } });
|
||||
});
|
||||
|
||||
it("still unwraps successful JSON results", () => {
|
||||
|
||||
Reference in new issue
Block a user