mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix(codex): ignore subagents in transcript fallback
This commit is contained in:
@@ -3,6 +3,7 @@ import { randomUUID } from 'node:crypto'
|
||||
import { basename, dirname, join, relative } from 'node:path'
|
||||
import { homedir } from 'node:os'
|
||||
import { AGENT_MESSAGE_PAYLOAD_TYPE } from '@hapi/protocol'
|
||||
import { isCodexSubagentSource } from '@/codex/utils/codexSessionMetadata'
|
||||
|
||||
const DEFAULT_CODEX_SESSION_SCAN_LIMIT = 200
|
||||
|
||||
@@ -78,11 +79,6 @@ function shouldIgnoreSyntheticUserMessage(text: string): boolean {
|
||||
return normalized.startsWith('# AGENTS.md instructions') || normalized.startsWith('<environment_context>')
|
||||
}
|
||||
|
||||
function isSubagentSource(value: unknown): boolean {
|
||||
const record = asRecord(value)
|
||||
return Boolean(record && Object.prototype.hasOwnProperty.call(record, 'subagent'))
|
||||
}
|
||||
|
||||
function inferSessionIdFromFileName(filePath: string): string | null {
|
||||
return /([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})/.exec(filePath)?.[1] ?? null
|
||||
}
|
||||
@@ -338,7 +334,7 @@ function parseCodexLocalSession(
|
||||
if (!record) continue
|
||||
if (record.type === 'session_meta') {
|
||||
const payload = asRecord(record.payload)
|
||||
if (isSubagentSource(payload?.source)) return null
|
||||
if (isCodexSubagentSource(payload?.source)) return null
|
||||
if (!sessionId && typeof payload?.id === 'string') sessionId = payload.id
|
||||
if (!cwd && typeof payload?.cwd === 'string') cwd = payload.cwd
|
||||
if (!originator && typeof payload?.originator === 'string') originator = payload.originator
|
||||
|
||||
Reference in New Issue
Block a user