feat: 实现纯 Kafka 页面刷新重放交接
This commit is contained in:
@@ -1086,6 +1086,7 @@ function buildAgentRunCommandInput({ params, traceId, backendProfile, sessionId,
|
||||
...agentRunPromptEventFields(promptEvidence),
|
||||
...(promptEvidence?.prompt ? { promptMetadata: promptEvidence.prompt } : {}),
|
||||
traceId,
|
||||
userMessageId: agentRunUserMessageId(params, traceId),
|
||||
projectId: firstNonEmpty(params.projectId) || null,
|
||||
conversationId: safeConversationId(params.conversationId) || null,
|
||||
sessionId: sessionId ?? scopedAgentRunSessionIdForParams(params, traceId),
|
||||
@@ -1114,6 +1115,7 @@ function buildAgentRunSteerCommandInput({ params, traceId, steerTraceId, mapped
|
||||
...agentRunPromptEventFields(promptEvidence),
|
||||
...(promptEvidence?.prompt ? { promptMetadata: promptEvidence.prompt } : {}),
|
||||
traceId: steerTraceId,
|
||||
userMessageId: agentRunUserMessageId(params, steerTraceId),
|
||||
targetTraceId: traceId,
|
||||
targetCommandId: mapped.agentRun.commandId,
|
||||
conversationId: safeConversationId(mapped.conversationId ?? params.conversationId) || null,
|
||||
@@ -1138,6 +1140,14 @@ function buildAgentRunDurableDispatchInput({ env, traceId, backendProfile }) {
|
||||
};
|
||||
}
|
||||
|
||||
function agentRunUserMessageId(params, traceId) {
|
||||
const explicit = firstNonEmpty(params?.userMessageId, params?.messageId);
|
||||
if (/^msg_[A-Za-z0-9_.:-]+$/u.test(explicit ?? "")) return explicit;
|
||||
const suffix = safeTraceId(traceId)?.replace(/^trc_/u, "").replace(/[^A-Za-z0-9_.:-]/gu, "_").slice(0, 48);
|
||||
if (!suffix) throw adapterError("agentrun_user_message_id_missing", "AgentRun command requires a deterministic HWLAB userMessageId");
|
||||
return `msg_${suffix}_user`;
|
||||
}
|
||||
|
||||
function assertAgentRunDurableTransientEnv(entries) {
|
||||
const seen = new Set();
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
@@ -1493,7 +1503,7 @@ function isReusableAgentRunMapping(mapping, backendProfile) {
|
||||
mapping.adapter === ADAPTER_ID &&
|
||||
mapping.reuseEligible !== false &&
|
||||
mapping.runId &&
|
||||
mapping.jobName &&
|
||||
(mapping.durableDispatch === true || mapping.jobName) &&
|
||||
(!mapping.backendProfile || mapping.backendProfile === backendProfile)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user