fix: preserve workbench message whitespace
This commit is contained in:
@@ -1109,6 +1109,12 @@ function promptTextValue(value) {
|
||||
return extracted;
|
||||
}
|
||||
|
||||
function messageAuthorityTextValue(value) {
|
||||
const extracted = promptTextRaw(value).replace(/\r\n?/gu, "\n");
|
||||
if (!extracted.trim() || extracted.trim() === "[object Object]") return "";
|
||||
return extracted;
|
||||
}
|
||||
|
||||
function promptTextRaw(value) {
|
||||
if (value === undefined || value === null) return "";
|
||||
if (typeof value === "string") return value;
|
||||
@@ -1136,7 +1142,7 @@ function adapterError(code, message, details = {}) {
|
||||
}
|
||||
|
||||
function buildAgentRunCommandInput({ params, traceId, backendProfile, sessionId }) {
|
||||
const prompt = promptTextValue(params.message ?? params.prompt ?? "");
|
||||
const prompt = messageAuthorityTextValue(params.message ?? params.prompt ?? "");
|
||||
const promptEvidence = agentRunPromptMetadataFromText(prompt, traceId, "agentrun-command-payload", { fullText: true });
|
||||
const threadId = safeOpaqueId(params.threadId);
|
||||
return {
|
||||
@@ -1163,7 +1169,7 @@ function buildAgentRunCommandInput({ params, traceId, backendProfile, sessionId
|
||||
}
|
||||
|
||||
function buildAgentRunSteerCommandInput({ params, traceId, steerTraceId, mapped }) {
|
||||
const prompt = promptTextValue(params.message ?? params.prompt ?? params.text ?? "");
|
||||
const prompt = messageAuthorityTextValue(params.message ?? params.prompt ?? params.text ?? "");
|
||||
const promptEvidence = agentRunPromptMetadataFromText(prompt, steerTraceId, "agentrun-steer-command-payload", { fullText: true });
|
||||
return {
|
||||
type: "steer",
|
||||
@@ -1602,7 +1608,7 @@ function agentRunToolCalls(result = {}, status = "completed") {
|
||||
|
||||
function agentRunReplyText(result = {}) {
|
||||
for (const value of [result?.reply, result?.assistantMessage, result?.finalResponse, result?.content, result?.text, result?.message]) {
|
||||
const text = promptTextValue(value);
|
||||
const text = messageAuthorityTextValue(value);
|
||||
if (text) return text;
|
||||
}
|
||||
return "";
|
||||
@@ -1735,7 +1741,7 @@ function agentRunResultToCodeAgentPayload({ base, result, traceStore, traceId, a
|
||||
}
|
||||
|
||||
function agentRunCompletedFinalResponse({ base, result, traceId, now, replyText = null }) {
|
||||
const textValue = promptTextValue(replyText) || agentRunReplyText(result);
|
||||
const textValue = messageAuthorityTextValue(replyText) || agentRunReplyText(result);
|
||||
return {
|
||||
text: textValue,
|
||||
textChars: textValue.length,
|
||||
|
||||
Reference in New Issue
Block a user