mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-21 16:17:38 +00:00
fix(sessions): keep the 0.9.27 step shape
This commit is contained in:
parent
c72fbbe8fa
commit
1542cd1897
3 changed files with 8 additions and 9 deletions
|
|
@ -796,7 +796,7 @@ export type WhyStep =
|
|||
cachedPct?: number | null; toolCalls?: number; answer?: boolean
|
||||
}
|
||||
| {
|
||||
kind: 'tool'; start: number; end: number; name: string; label: string; isError?: boolean; error?: WhyError; helperCost?: number; detail?: WhyDetail | null
|
||||
kind: 'tool'; start: number; end: number; name: string; label: string; isError: boolean; error?: WhyError; helperCost?: number; detail: WhyDetail | null
|
||||
parent?: number; parallel?: { index: number; of: number }; resultChars?: number
|
||||
}
|
||||
export type WhyTurn = {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export type WhyStep =
|
|||
cachedPct: number | null; toolCalls: number; answer?: true
|
||||
}
|
||||
| {
|
||||
kind: 'tool'; start: number; end: number; name: string; label: string; isError?: true; error?: WhyError; helperCost?: number; detail?: WhyDetail
|
||||
kind: 'tool'; start: number; end: number; name: string; label: string; isError: boolean; error?: WhyError; helperCost?: number; detail: WhyDetail | null
|
||||
parent: number; parallel?: { index: number; of: number }; resultChars: number
|
||||
}
|
||||
export type WhyTurn = {
|
||||
|
|
@ -526,14 +526,14 @@ export async function buildSessionWhy(filePath: string): Promise<SessionWhy> {
|
|||
const helper = helperByTool.get(tu.id)
|
||||
if (helper) seen.push(helper)
|
||||
const doneTs = (tu.name === 'Agent' || tu.name === 'Task' ? r.handBacks.get(tu.id)?.ts : undefined) ?? res?.ts ?? tu.ts
|
||||
let detail: WhyDetail | undefined = toolDetail(tu.name, tu.input, res)
|
||||
let detail: WhyDetail | null = toolDetail(tu.name, tu.input, res)
|
||||
const size = JSON.stringify(detail).length
|
||||
// ponytail: one global budget keeps the payload under the app's 16MB pipe cap; per-turn loading if real sessions hit it.
|
||||
if (size > budget) { detail = undefined; detailsOmitted = true } else budget -= size
|
||||
if (size > budget) { detail = null; detailsOmitted = true } else budget -= size
|
||||
if (detail && helper) detail.helper = publicHelper(helper)
|
||||
const step: WhyStep = {
|
||||
kind: 'tool', start: tu.ts - start, end: doneTs - start, name: tu.name, label: redact(toolLabel(tu.name, tu.input)),
|
||||
...(res?.isError ? { isError: true, error: errorCause(res.text) } : {}), ...(helper ? { helperCost: helper.cost } : {}), ...(detail ? { detail } : {}),
|
||||
isError: res?.isError === true, ...(res?.isError ? { error: errorCause(res.text) } : {}), ...(helper ? { helperCost: helper.cost } : {}), detail,
|
||||
parent: -1, ...(toolUses.length > 1 ? { parallel: { index: j + 1, of: toolUses.length } } : {}), resultChars: res?.text.length ?? 0,
|
||||
}
|
||||
if (res) stepResult.set(step, res)
|
||||
|
|
|
|||
|
|
@ -315,11 +315,10 @@ describe('session cost diagnosis: request fields', () => {
|
|||
describe('session cost diagnosis: payload budget', () => {
|
||||
const size = (w: SessionWhy) => Buffer.byteLength(JSON.stringify(w))
|
||||
|
||||
it('leaves a payload under budget alone and omits default step fields', () => {
|
||||
it('leaves a payload under budget alone and keeps the released tool step shape', () => {
|
||||
expect(fitWhyJson(structuredClone(why))).toEqual(why)
|
||||
const steps = why.turns.flatMap(t => [...t.steps, ...t.helpers.flatMap(h => h.steps)])
|
||||
expect(steps.some(s => s.kind === 'tool' && 'isError' in s && !s.isError)).toBe(false)
|
||||
expect(steps.some(s => s.kind === 'tool' && 'detail' in s && !s.detail)).toBe(false)
|
||||
const tools = why.turns.flatMap(t => [...t.steps, ...t.helpers.flatMap(h => h.steps)]).filter(s => s.kind === 'tool')
|
||||
expect(tools.every(s => typeof s.isError === 'boolean' && 'detail' in s)).toBe(true)
|
||||
})
|
||||
|
||||
it('drops whole step lists, cheapest helper first, then prompts, keeping totals and findings', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue