mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
* fix(agents): tell Codex subagent rows apart by task name instead of role A Codex subagent's task name only reached the sidebar when one early read of its rollout succeeded; otherwise every child fell back to its role, so two workers both read "worker". The child poll now re-reads an unnamed child's own rollout, the first-line read allows the existing 256 KiB line cap, and a child with no task name or nickname carries the tail of its id, as Codex's own agent list does. Labels keep the path below the root so nested children with the same leaf stay distinct. * fix(agents): retry an unnamed Codex child's own rollout without a parent transcript A relay restart can leave a child hook as the only evidence, sent before the child's rollout was readable. Keep that path as pending identity work and retry it through the existing transcript poll, which now stays scheduled while a child still owes its name. * fix(agents): carry the id tail to every child-row surface and bound identity retries - Full-mode sidebar rows and dashboard subagent cards use the same suffixed label as compact rows. - A role a host publishes as the name (Claude's subagent_type) no longer counts as a name. - A final identity miss no longer re-arms polling; retries take turns, eight children per poll. - Replace an error cast with a type guard. * fix(agents): keep every identity read inside the per-poll budget The parent-rollout poll now queues an unnamed child for the bounded, rotating identity retries instead of reading it directly, and full-mode rows keep the id tail for a child with no name or role. * fix(agents): keep plain names on task-only rosters and guard the queued rollout path A host that publishes only a task roster carries no role, so its names can't be told from roles and get no id tail. Update the sidebar lineage test for a role-only child's id tail. * fix(agents): tell role-named tasks apart on task-only rosters A host that publishes only a task roster sends Claude's subagent_type as the task name, so two such tasks read identically. A named agent task with no description now carries its id tail; an unnamed one keeps its kind label. * fix(agents): a task path found meanwhile wins over a queued header read Placeholder labels (e.g. unknown) count as unnamed when queueing, and a child the parent rollout named before its turn drops its pending read instead of being overwritten by the header's nickname.
94 lines
2.8 KiB
TypeScript
94 lines
2.8 KiB
TypeScript
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
|
|
import { createHookListenerState } from './agent-hook-listener/listener-state'
|
|
import { normalizeHookPayload } from './agent-hook-listener/normalization/normalize-hook-payload'
|
|
import { makePaneKey } from './workspace-layout/stable-pane-id'
|
|
|
|
const PANE_KEY = makePaneKey('tab-1', '11111111-1111-4111-8111-111111111111')
|
|
const CHILD_ID = '019fa65f-3144-7151-9c02-cff7a28f316f'
|
|
|
|
function jsonl(records: unknown[]): string {
|
|
return `${records.map((record) => JSON.stringify(record)).join('\n')}\n`
|
|
}
|
|
|
|
describe('Codex rollout subagent lifecycle', () => {
|
|
const dirs: string[] = []
|
|
|
|
afterEach(() => {
|
|
for (const dir of dirs) {
|
|
rmSync(dir, { recursive: true, force: true })
|
|
}
|
|
dirs.length = 0
|
|
})
|
|
|
|
it('surfaces a collaboration child without lifecycle hooks and retires it on task_complete', () => {
|
|
const dir = mkdtempSync(join(tmpdir(), 'codex-rollout-lifecycle-'))
|
|
dirs.push(dir)
|
|
const parentPath = join(dir, 'rollout-parent.jsonl')
|
|
const childPath = join(dir, `rollout-child-${CHILD_ID}.jsonl`)
|
|
writeFileSync(
|
|
parentPath,
|
|
jsonl([
|
|
{
|
|
type: 'event_msg',
|
|
payload: {
|
|
type: 'sub_agent_activity',
|
|
occurred_at_ms: 1234,
|
|
agent_thread_id: CHILD_ID,
|
|
agent_path: '/root/pr_review',
|
|
kind: 'started'
|
|
}
|
|
}
|
|
])
|
|
)
|
|
writeFileSync(childPath, jsonl([{ type: 'event_msg', payload: { type: 'task_started' } }]))
|
|
const state = createHookListenerState()
|
|
const event = (hookEventName: string): ReturnType<typeof normalizeHookPayload> =>
|
|
normalizeHookPayload(
|
|
state,
|
|
'codex',
|
|
{
|
|
paneKey: PANE_KEY,
|
|
payload: {
|
|
hook_event_name: hookEventName,
|
|
session_id: 'root-session',
|
|
transcript_path: parentPath,
|
|
tool_name: 'collaborationspawn_agent'
|
|
}
|
|
},
|
|
'production'
|
|
)
|
|
|
|
const spawned = event('PostToolUse')
|
|
expect(spawned?.payload).toMatchObject({
|
|
state: 'working',
|
|
subagents: [
|
|
{
|
|
id: CHILD_ID,
|
|
description: 'pr_review',
|
|
state: 'working',
|
|
startedAt: 1234
|
|
}
|
|
]
|
|
})
|
|
|
|
const leadStopped = event('Stop')
|
|
expect(leadStopped?.payload.state).toBe('working')
|
|
expect(leadStopped?.payload.subagents).toHaveLength(1)
|
|
|
|
writeFileSync(
|
|
childPath,
|
|
jsonl([
|
|
{ type: 'event_msg', payload: { type: 'task_started' } },
|
|
{ type: 'event_msg', payload: { type: 'task_complete' } }
|
|
])
|
|
)
|
|
const completed = event('Stop')
|
|
expect(completed?.payload.state).toBe('done')
|
|
expect(completed?.payload.subagents).toBeUndefined()
|
|
})
|
|
})
|