fix: add turn check debug logs + fallback to ctx.accountId
- Add detailed debug log for turn check showing agentId, resolvedAccountId, ctxAccountId, turnOrderLen - Add fallback: if resolveAccountId fails, use ctx.accountId directly
This commit is contained in:
@@ -623,7 +623,28 @@ export default {
|
|||||||
// This ensures only the current speaker can respond even for human messages.
|
// This ensures only the current speaker can respond even for human messages.
|
||||||
if (derived.channelId) {
|
if (derived.channelId) {
|
||||||
ensureTurnOrder(api, derived.channelId);
|
ensureTurnOrder(api, derived.channelId);
|
||||||
const accountId = resolveAccountId(api, ctx.agentId || "");
|
|
||||||
|
// Try resolveAccountId first, fall back to ctx.accountId if not found
|
||||||
|
let accountId = resolveAccountId(api, ctx.agentId || "");
|
||||||
|
|
||||||
|
// Debug log for turn check - log all available identifiers
|
||||||
|
if (shouldDebugLog(live, derived.channelId)) {
|
||||||
|
const turnDebug = getTurnDebugInfo(derived.channelId);
|
||||||
|
api.logger.info(
|
||||||
|
`whispergate: turn check preflight ` +
|
||||||
|
`agentId=${ctx.agentId ?? "undefined"} ` +
|
||||||
|
`resolvedAccountId=${accountId ?? "undefined"} ` +
|
||||||
|
`ctxAccountId=${ctx.accountId ?? "undefined"} ` +
|
||||||
|
`turnOrderLen=${turnDebug.turnOrder?.length ?? 0} ` +
|
||||||
|
`currentSpeaker=${turnDebug.currentSpeaker ?? "null"}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to ctx.accountId if resolveAccountId failed
|
||||||
|
if (!accountId && ctx.accountId) {
|
||||||
|
accountId = String(ctx.accountId);
|
||||||
|
}
|
||||||
|
|
||||||
if (accountId) {
|
if (accountId) {
|
||||||
const turnCheck = checkTurn(derived.channelId, accountId);
|
const turnCheck = checkTurn(derived.channelId, accountId);
|
||||||
if (!turnCheck.allowed) {
|
if (!turnCheck.allowed) {
|
||||||
|
|||||||
Reference in New Issue
Block a user