Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

78 lines
3.1 KiB
TypeScript

import { pickLastOutputMessage } from './AIObservabilityTracesScene'
describe('pickLastOutputMessage', () => {
it('returns null for empty or unusable input', () => {
expect(pickLastOutputMessage(null)).toBeNull()
expect(pickLastOutputMessage([])).toBeNull()
})
it('skips a trailing tool call and picks the last user-facing assistant answer', () => {
const conversation = [
{ role: 'user', content: 'what is the weather?' },
{ role: 'assistant', content: 'It is 72F.' },
{
role: 'assistant',
content: '',
tool_calls: [{ id: 'c1', type: 'function', function: { name: 'get_weather', arguments: '{}' } }],
},
]
expect(pickLastOutputMessage(conversation)).toMatchObject({ role: 'assistant', content: 'It is 72F.' })
})
it('skips a trailing tool result and picks the last assistant answer', () => {
const conversation = [
{ role: 'assistant', content: 'Let me check.' },
{
role: 'assistant',
content: '',
tool_calls: [{ id: 'c1', type: 'function', function: { name: 'get_weather', arguments: '{}' } }],
},
{ role: 'tool', content: '72F', tool_call_id: 'c1' },
]
expect(pickLastOutputMessage(conversation)).toMatchObject({ role: 'assistant', content: 'Let me check.' })
})
it('keeps an assistant message that mixes real text with a tool call', () => {
const conversation = [
{ role: 'user', content: 'book a table' },
{
role: 'assistant',
content: 'Booking that now.',
tool_calls: [{ id: 'c1', type: 'function', function: { name: 'book', arguments: '{}' } }],
},
]
expect(pickLastOutputMessage(conversation)).toMatchObject({
role: 'assistant',
content: 'Booking that now.',
})
})
it('falls back to the tool call when the trace has nothing but tool traffic', () => {
const conversation = [
{ role: 'user', content: 'what is the weather?' },
{
role: 'assistant',
content: '',
tool_calls: [{ id: 'c1', type: 'function', function: { name: 'get_weather', arguments: '{}' } }],
},
]
const picked = pickLastOutputMessage(conversation)
expect(picked).not.toBeNull()
expect(picked?.tool_calls?.[0]?.function?.name).toBe('get_weather')
})
it('unwraps a { messages } state container before picking the output', () => {
const state = {
messages: [
{ role: 'assistant', content: 'final answer' },
{ role: 'tool', content: 'tool output', tool_call_id: 'c1' },
],
}
expect(pickLastOutputMessage(state)).toMatchObject({ role: 'assistant', content: 'final answer' })
})
it('rejects unknown state-wrapper shapes in strict mode', () => {
expect(pickLastOutputMessage({ current_step: 3 }, { strict: true })).toBeNull()
})
})