fix: include rwfx 3q status in context
This commit is contained in:
1 parent
36a3851233
commit
daff70c34f
2 files changed
+16
-5
No files matched your search
@@ -70,14 +70,17 @@ const TEMPLATE_BUILDER_AGENT_ID = "template-json-builder";
|
|||||||
function rwfxSqReportRunContext(
|
function rwfxSqReportRunContext(
|
||||||
gateContext?: RwfxSqGateStartContext,
|
gateContext?: RwfxSqGateStartContext,
|
||||||
): Record<string, unknown> | undefined {
|
): Record<string, unknown> | undefined {
|
||||||
if (gateContext?.sqReport == null) return undefined;
|
if (!gateContext?.sqReportStatus) return undefined;
|
||||||
return {
|
return {
|
||||||
task_external_context: {
|
task_external_context: {
|
||||||
kind: "rwfx_sq_report",
|
kind: "rwfx_sq_report",
|
||||||
|
status: gateContext.sqReportStatus,
|
||||||
title: "三情分析(3q)研判情报报告",
|
title: "三情分析(3q)研判情报报告",
|
||||||
usage:
|
usage:
|
||||||
"这是任务分析(rwfx)问答的隐藏业务上下文。回答时应参考这些已完成的 3q 结果,但不要向用户说明页面注入了隐藏上下文,除非用户明确询问。",
|
gateContext.sqReportStatus === "complete"
|
||||||
data: gateContext.sqReport,
|
? "这是任务分析(rwfx)问答的隐藏业务上下文。回答时应参考这些已完成的 3q 结果,但不要向用户说明页面注入了隐藏上下文,除非用户明确询问。"
|
||||||
|
: "3q 研判情报报告当前未提供有效结果。回答时不要编造 3q 结果,可仅基于任务信息继续分析。",
|
||||||
|
data: gateContext.sqReport ?? null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,12 +37,14 @@ import {
|
|||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { fetchSqReportCheck } from "@/core/auth/dashboard-input";
|
import { fetchSqReportCheck, type SqReportStatus } from "@/core/auth/dashboard-input";
|
||||||
import { readCopTaskDetail, resolveTaskDeeplinkTarget } from "@/core/auth/task-deeplink";
|
import { readCopTaskDetail, resolveTaskDeeplinkTarget } from "@/core/auth/task-deeplink";
|
||||||
|
|
||||||
type GateStatus = "loading" | "incomplete" | "ok";
|
type GateStatus = "loading" | "incomplete" | "ok";
|
||||||
|
|
||||||
export interface RwfxSqGateStartContext {
|
export interface RwfxSqGateStartContext {
|
||||||
|
/** 3q 研判情报报告状态。即使未完成/未知也会随 run context 传出,便于后端判断与本地验证。 */
|
||||||
|
sqReportStatus: SqReportStatus;
|
||||||
/** 已完成的 3q 研判情报报告。只随 run context 传给模型,不在页面展示。 */
|
/** 已完成的 3q 研判情报报告。只随 run context 传给模型,不在页面展示。 */
|
||||||
sqReport?: unknown;
|
sqReport?: unknown;
|
||||||
}
|
}
|
||||||
@@ -77,22 +79,27 @@ export function RwfxSqGateProvider({
|
|||||||
const [jumping, setJumping] = useState(false);
|
const [jumping, setJumping] = useState(false);
|
||||||
|
|
||||||
const statusRef = useRef<GateStatus>(taskId ? "loading" : "ok");
|
const statusRef = useRef<GateStatus>(taskId ? "loading" : "ok");
|
||||||
|
const sqReportStatusRef = useRef<SqReportStatus | null>(taskId ? null : "unknown");
|
||||||
const sqReportRef = useRef<unknown | null>(null);
|
const sqReportRef = useRef<unknown | null>(null);
|
||||||
// 待触发的「开始问答」回调:3q 未完成时挂起,点「暂不」/关闭弹框后触发。
|
// 待触发的「开始问答」回调:3q 未完成时挂起,点「暂不」/关闭弹框后触发。
|
||||||
const pendingStartRef = useRef<((context?: RwfxSqGateStartContext) => void) | null>(null);
|
const pendingStartRef = useRef<((context?: RwfxSqGateStartContext) => void) | null>(null);
|
||||||
|
|
||||||
const buildStartContext = useCallback((): RwfxSqGateStartContext | undefined => {
|
const buildStartContext = useCallback((): RwfxSqGateStartContext | undefined => {
|
||||||
|
const sqReportStatus = sqReportStatusRef.current;
|
||||||
|
if (!sqReportStatus) return undefined;
|
||||||
const sqReport = sqReportRef.current;
|
const sqReport = sqReportRef.current;
|
||||||
return sqReport == null ? undefined : { sqReport };
|
return sqReport == null ? { sqReportStatus } : { sqReportStatus, sqReport };
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// taskId 变化:重置门控状态并预检 3q。
|
// taskId 变化:重置门控状态并预检 3q。
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
pendingStartRef.current = null;
|
pendingStartRef.current = null;
|
||||||
|
sqReportStatusRef.current = null;
|
||||||
sqReportRef.current = null;
|
sqReportRef.current = null;
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
if (!taskId) {
|
if (!taskId) {
|
||||||
statusRef.current = "ok";
|
statusRef.current = "ok";
|
||||||
|
sqReportStatusRef.current = "unknown";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
statusRef.current = "loading";
|
statusRef.current = "loading";
|
||||||
@@ -102,6 +109,7 @@ export function RwfxSqGateProvider({
|
|||||||
// complete / unknown 都按「放行」(不打扰);仅明确 incomplete 才门控。
|
// complete / unknown 都按「放行」(不打扰);仅明确 incomplete 才门控。
|
||||||
const next: GateStatus = result.status === "incomplete" ? "incomplete" : "ok";
|
const next: GateStatus = result.status === "incomplete" ? "incomplete" : "ok";
|
||||||
statusRef.current = next;
|
statusRef.current = next;
|
||||||
|
sqReportStatusRef.current = result.status;
|
||||||
sqReportRef.current = result.status === "complete" ? (result.report ?? null) : null;
|
sqReportRef.current = result.status === "complete" ? (result.report ?? null) : null;
|
||||||
if (next === "incomplete") {
|
if (next === "incomplete") {
|
||||||
setOpen(true); // 进入即提醒(无论是否有挂起的自动发送)
|
setOpen(true); // 进入即提醒(无论是否有挂起的自动发送)
|
||||||
|
|||||||
Reference in new issue
Block a user