fix: serialize paginated session searches

This commit is contained in:
Hypatia May
2026-07-24 19:47:23 +08:00
parent 795af3174e
commit 66585635c8
16 changed files with 133 additions and 39 deletions
@@ -248,15 +248,13 @@ describe('registration and schemas', () => {
expect(sessionSchema?.parameters).not.toHaveProperty('properties.cwd')
expect(mounted.ctx.tools.get('session_search')?.timeoutMs).toBe(1234)
expect(mounted.ctx.tools.get('session_trace')?.timeoutMs).toBeUndefined()
const safeArgs: Record<string, unknown> = {
session_search: { query: 'q' },
session_event_search: { query: 'q' },
const parallelArgs: Record<string, unknown> = {
session_trace: {},
session_event_trace: { seq: 0 },
session_event_read: { seq: 0 },
}
for (const name of names) {
expect(mounted.ctx.tools.get(name)?.isConcurrencySafe?.(safeArgs[name])).toBe(true)
for (const [name, args] of Object.entries(parallelArgs)) {
expect(mounted.ctx.tools.get(name)?.isConcurrencySafe?.(args)).toBe(true)
}
expect(mounted.ctx.tools.get('session_search')?.output.render({}, 'rendered'))
.toEqual([{ type: 'text', text: 'rendered' }])
@@ -287,6 +285,27 @@ describe('registration and schemas', () => {
.not.toContain('tool:session-query')
})
it('keeps generation-bound searches exclusive while exact observations remain parallel', async () => {
const mounted = await mount()
const classifications = [
['session_search', { query: 'q' }, 'exclusive'],
['session_event_search', { query: 'q' }, 'exclusive'],
['session_trace', {}, 'parallel'],
['session_event_trace', { seq: 0 }, 'parallel'],
['session_event_read', { seq: 0 }, 'parallel'],
] as const
for (const [name, args, kind] of classifications) {
expect(mounted.ctx.tools.executionMode({
name,
arguments: args,
callId: CallId(`mode-${name}`),
signal: new AbortController().signal,
agent: fakeAgent(mounted.caller),
})).toEqual({ kind })
}
})
it('fails invalid direct config before registering anything', async () => {
const mounted = await mount()
for (const maxSearchResults of [0, 1.5, Number.NaN]) {