mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 10:43:47 +00:00
fix(kimi): give subagent wire logs a session id scoped to their session
A subagent's wire log took its directory name (agent-1, ...) as the session id. Those names repeat across sessions, so subagents of different sessions merged into one session, and without a message_id their dedup keys collided and later sessions' calls were dropped. Prefix the parent session directory.
This commit is contained in:
parent
a5f806a659
commit
fa231c3eed
3 changed files with 25 additions and 1 deletions
|
|
@ -248,7 +248,11 @@ function createParser(source: SessionSource, shareDir: string, seenKeys: Set<str
|
|||
const tools = new Set<string>()
|
||||
const bashCommands = new Set<string>()
|
||||
let currentUserMessage = ''
|
||||
const sessionId = basename(dirname(source.path))
|
||||
// Subagent dirs (agent-1, ...) repeat across sessions; prefix the parent session.
|
||||
const dir = dirname(source.path)
|
||||
const sessionId = basename(dirname(dir)) === 'subagents'
|
||||
? `${basename(dirname(dirname(dir)))}/${basename(dir)}`
|
||||
: basename(dir)
|
||||
let index = 0
|
||||
|
||||
for await (const line of readSessionLines(source.path)) {
|
||||
|
|
|
|||
|
|
@ -632,6 +632,9 @@ export const PROVIDER_PARSE_VERSIONS: Record<string, string> = {
|
|||
// tool-sequence-v1: calls carry each tool call's path and shell command, so
|
||||
// optimize sees commits/PRs and retries per file. Costs are unchanged.
|
||||
kimicode: 'wire-usage-v1-est-cost-session-lineage-capture-v1-cwd-project-v1-tool-sequence-v1',
|
||||
// subagent-session-id-v1: subagent wire logs take `<session>/<subagent>` as
|
||||
// their session id, so cached subagents merged across sessions re-parse.
|
||||
kimi: 'subagent-session-id-v1',
|
||||
// archived-subtree-v1: KiloCode shares the SQLite parser and the same schema.
|
||||
// billing-routes-v2: its warm cache must move with both shared route fields.
|
||||
'kilo-code': 'worktree-project-grouping-v1-session-model-v1-archived-subtree-v1-billing-routes-v2-v2-legacy-union-v1-unknown-usage-v1-vertex-fallback-cost-v1',
|
||||
|
|
|
|||
|
|
@ -125,6 +125,23 @@ describe('Kimi provider', () => {
|
|||
expect(calls[0]!.costUSD).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
it('keeps same-named subagents of different sessions apart', async () => {
|
||||
const seen = new Set<string>()
|
||||
const calls: ParsedProviderCall[] = []
|
||||
for (const session of ['sess-A', 'sess-B']) {
|
||||
const wirePath = await writeSession('/Users/test/work/app', join(session, 'subagents', 'agent-1'), [
|
||||
record(1776162400, 'TurnBegin', { user_input: `go ${session}` }),
|
||||
record(1776162401, 'StatusUpdate', { token_usage: { input_other: 1000, output: 100 } }),
|
||||
])
|
||||
calls.push(...await collect(createKimiProvider(tmpDir), wirePath, seen))
|
||||
}
|
||||
|
||||
expect(calls.map(c => [c.sessionId, c.deduplicationKey])).toEqual([
|
||||
['sess-A/agent-1', 'kimi:sess-A/agent-1:0'],
|
||||
['sess-B/agent-1', 'kimi:sess-B/agent-1:0'],
|
||||
])
|
||||
})
|
||||
|
||||
it('prices kimi-for-coding by call date', async () => {
|
||||
const wirePath = await writeSession('/Users/test/work/app', 'sess-k28', [
|
||||
record(1789084799, 'StatusUpdate', {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue