@ynhcj/xiaoyi-channel 0.0.215-next → 0.0.216-next
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/provider.js +25 -11
- package/package.json +1 -1
package/dist/src/provider.js
CHANGED
|
@@ -242,6 +242,10 @@ const HEADER_SESSION_ID = "x-session-id";
|
|
|
242
242
|
const HEADER_INTERACTION_ID = "x-interaction-id";
|
|
243
243
|
/** Internal key for passing fallback uid prefix from prepareExtraParams to wrapStreamFn. */
|
|
244
244
|
const FALLBACK_PREFIX_KEY = "_xiaoyi_fallback_prefix";
|
|
245
|
+
// Module-level cache of the most recent trace context.
|
|
246
|
+
// resolveDynamicModel reads these so the LLM compaction path (which bypasses
|
|
247
|
+
// wrapStreamFn) still gets x-hag-trace-id on model.headers.
|
|
248
|
+
let globalTraceContext = null;
|
|
245
249
|
const SELF_EVOLUTION_PROMPT_BEGIN = "<self_evolution_prompt>";
|
|
246
250
|
const SELF_EVOLUTION_PROMPT_END = "</self_evolution_prompt>";
|
|
247
251
|
const SELF_EVOLUTION_ENABLED_PROMPT_SECTION = `
|
|
@@ -454,8 +458,19 @@ export const xiaoyiProvider = {
|
|
|
454
458
|
contextWindow: 256_000,
|
|
455
459
|
maxTokens: 8192,
|
|
456
460
|
...(ctx.providerConfig?.headers && typeof ctx.providerConfig.headers === "object"
|
|
457
|
-
? { headers:
|
|
458
|
-
|
|
461
|
+
? { headers: {
|
|
462
|
+
...ctx.providerConfig.headers,
|
|
463
|
+
...(globalTraceContext ? {
|
|
464
|
+
[HEADER_TRACE_ID]: globalTraceContext.traceId,
|
|
465
|
+
[HEADER_SESSION_ID]: globalTraceContext.sessionId,
|
|
466
|
+
[HEADER_INTERACTION_ID]: globalTraceContext.interactionId,
|
|
467
|
+
} : {}),
|
|
468
|
+
} }
|
|
469
|
+
: (globalTraceContext ? { headers: {
|
|
470
|
+
[HEADER_TRACE_ID]: globalTraceContext.traceId,
|
|
471
|
+
[HEADER_SESSION_ID]: globalTraceContext.sessionId,
|
|
472
|
+
[HEADER_INTERACTION_ID]: globalTraceContext.interactionId,
|
|
473
|
+
} } : {})),
|
|
459
474
|
};
|
|
460
475
|
},
|
|
461
476
|
/**
|
|
@@ -606,15 +621,14 @@ export const xiaoyiProvider = {
|
|
|
606
621
|
logger.log(`[ALS-PROOF] provider headers source=uid-fallback (ALS miss)`);
|
|
607
622
|
}
|
|
608
623
|
}
|
|
609
|
-
//
|
|
610
|
-
//
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
model.headers[HEADER_INTERACTION_ID] = dynamicHeaders[HEADER_INTERACTION_ID];
|
|
624
|
+
// Cache trace context globally so resolveDynamicModel can inject
|
|
625
|
+
// x-hag-trace-id into model.headers for the LLM compaction path.
|
|
626
|
+
if (dynamicHeaders[HEADER_TRACE_ID]) {
|
|
627
|
+
globalTraceContext = {
|
|
628
|
+
traceId: dynamicHeaders[HEADER_TRACE_ID],
|
|
629
|
+
sessionId: dynamicHeaders[HEADER_SESSION_ID] ?? dynamicHeaders[HEADER_TRACE_ID],
|
|
630
|
+
interactionId: dynamicHeaders[HEADER_INTERACTION_ID] ?? dynamicHeaders[HEADER_TRACE_ID],
|
|
631
|
+
};
|
|
618
632
|
}
|
|
619
633
|
// 记录输入
|
|
620
634
|
logger.log(`[xiaoyiprovider] input messages count: ${context.messages?.length ?? 0}`);
|