From c79ab38255210be0e5fd57efac08ec76ed54a490 Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Wed, 9 Sep 2026 07:52:13 +0000 Subject: [PATCH 1/2] fix(server): tell agents how to nest fenced code inside code blocks A code block whose body contains triple backticks was rendered broken in chat: the inner closing fence ended the outer block, and the rest spilled out as prose. That is correct CommonMark, so the fix is to tell every provider up front to use a longer fence in that case. Co-Authored-By: Claude Fable 5.1 --- apps/server/src/provider/RuntimeInstructions.test.ts | 6 ++++++ apps/server/src/provider/RuntimeInstructions.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/server/src/provider/RuntimeInstructions.test.ts b/apps/server/src/provider/RuntimeInstructions.test.ts index e73c50adfd6d..863a87cde6b2 100644 --- a/apps/server/src/provider/RuntimeInstructions.test.ts +++ b/apps/server/src/provider/RuntimeInstructions.test.ts @@ -25,4 +25,10 @@ describe("buildRuntimeInstructions", () => { expect(instructions).toContain("through the Cursor harness."); expect(instructions).not.toContain("reasoning effort"); }); + + it("tells the agent how to nest fenced code inside a code block", () => { + expect(buildRuntimeInstructions({ harness: "Claude Code" })).toContain( + "must be fenced with a longer fence (four backticks or a ~~~ fence)", + ); + }); }); diff --git a/apps/server/src/provider/RuntimeInstructions.ts b/apps/server/src/provider/RuntimeInstructions.ts index 5e72586062e5..68314fcf0ef5 100644 --- a/apps/server/src/provider/RuntimeInstructions.ts +++ b/apps/server/src/provider/RuntimeInstructions.ts @@ -13,7 +13,7 @@ export function buildRuntimeInstructions(runtime: { const effort = toSingleLine(runtime.reasoningEffort ?? ""); const modelInfo = model && model !== "auto" && model !== "default" ? `, as ${model}` : ""; const effortInfo = effort ? ` with ${effort} reasoning effort` : ""; - return `In case you're asked: you are running in T3 Code through the ${harness} harness${modelInfo}${effortInfo}. No need to mention this otherwise. You can embed images and videos in your response using Markdown with absolute file paths.\n\n${PULL_REQUEST_LINKING_INSTRUCTIONS}`; + return `In case you're asked: you are running in T3 Code through the ${harness} harness${modelInfo}${effortInfo}. No need to mention this otherwise. You can embed images and videos in your response using Markdown with absolute file paths. Responses render as CommonMark: a code block that itself contains triple backticks must be fenced with a longer fence (four backticks or a ~~~ fence), otherwise the inner closing fence ends the block early.\n\n${PULL_REQUEST_LINKING_INSTRUCTIONS}`; } function toSingleLine(value: string): string { From 71178d07d4add927386c6aefdb191af1692f9de1 Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Thu, 10 Sep 2026 10:55:05 +0000 Subject: [PATCH 2/2] refactor(server): shorten the nested fence guidance to one plain sentence Co-Authored-By: Claude Fable 5.1 --- apps/server/src/provider/RuntimeInstructions.test.ts | 2 +- apps/server/src/provider/RuntimeInstructions.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/server/src/provider/RuntimeInstructions.test.ts b/apps/server/src/provider/RuntimeInstructions.test.ts index 863a87cde6b2..88fc872401f8 100644 --- a/apps/server/src/provider/RuntimeInstructions.test.ts +++ b/apps/server/src/provider/RuntimeInstructions.test.ts @@ -28,7 +28,7 @@ describe("buildRuntimeInstructions", () => { it("tells the agent how to nest fenced code inside a code block", () => { expect(buildRuntimeInstructions({ harness: "Claude Code" })).toContain( - "must be fenced with a longer fence (four backticks or a ~~~ fence)", + "A code block that contains triple backticks needs a longer fence (four backticks or ~~~).", ); }); }); diff --git a/apps/server/src/provider/RuntimeInstructions.ts b/apps/server/src/provider/RuntimeInstructions.ts index 68314fcf0ef5..6c160fd983bb 100644 --- a/apps/server/src/provider/RuntimeInstructions.ts +++ b/apps/server/src/provider/RuntimeInstructions.ts @@ -13,7 +13,7 @@ export function buildRuntimeInstructions(runtime: { const effort = toSingleLine(runtime.reasoningEffort ?? ""); const modelInfo = model && model !== "auto" && model !== "default" ? `, as ${model}` : ""; const effortInfo = effort ? ` with ${effort} reasoning effort` : ""; - return `In case you're asked: you are running in T3 Code through the ${harness} harness${modelInfo}${effortInfo}. No need to mention this otherwise. You can embed images and videos in your response using Markdown with absolute file paths. Responses render as CommonMark: a code block that itself contains triple backticks must be fenced with a longer fence (four backticks or a ~~~ fence), otherwise the inner closing fence ends the block early.\n\n${PULL_REQUEST_LINKING_INSTRUCTIONS}`; + return `In case you're asked: you are running in T3 Code through the ${harness} harness${modelInfo}${effortInfo}. No need to mention this otherwise. You can embed images and videos in your response using Markdown with absolute file paths. A code block that contains triple backticks needs a longer fence (four backticks or ~~~).\n\n${PULL_REQUEST_LINKING_INSTRUCTIONS}`; } function toSingleLine(value: string): string {