fix: remove avoidable model runtime limits

Preserve long histories and parsed attachments, expose paged process and Subagent output, isolate MCP discovery failures, and expand browser snapshots and knowledge result selection. Remove fixed Harness output and updated remote Runtime duration limits.

Keep released Agent profile and v1 bridge compatibility while enabling larger framed exchanges and optional limits for updated peers. Document remote coverage requirements and real-model boundary validation.

Release note: Long model tasks can retain more context and continue reading complete tool output; remote execution preserves compatibility with released Agents. Updated remote limits require an updated Agent and Runtime bundle.
This commit is contained in:
mesalogo
2026-09-10 03:01:21 +08:00
parent 80b0b18712
commit b01a856bae
62 changed files with 1285 additions and 465 deletions
@@ -1,5 +1,5 @@
import { randomUUID } from 'node:crypto'
import { describe, expect, it, vi } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { RuntimeModelUsageEvent } from '../agent/runtime'
import {
DIRECT_MODEL_SUBAGENT_ERROR_MAX_BYTES,
@@ -16,6 +16,11 @@ type RequestContext = {
authorizationSnapshot: string
}
const services: DirectModelSubagentService<RequestContext>[] = []
afterEach(async () => {
await Promise.all(services.splice(0).map((service) => service.dispose()))
})
const parent: DirectModelSubagentParent<RequestContext> = {
requestId: 'parent-request',
projectId: 'project',
@@ -41,6 +46,7 @@ function createHarness(
runChild,
releaseConversation
})
services.push(service)
const run = (
overrides: Partial<Parameters<typeof service.run>[0]> = {}
) =>
@@ -176,6 +182,19 @@ describe('DirectModelSubagentService', () => {
DIRECT_MODEL_SUBAGENT_OUTPUT_MAX_BYTES
)
expect(harness.events.at(-1)?.outputTruncated).toBe(true)
const reference = result.outputReference!
let fullOutput = result.output
let cursor = reference.nextCursor
while (cursor < reference.totalBytes) {
const page = await harness.service.readOutput('owner', reference.handle, cursor)
expect(page.nextCursor).toBeGreaterThan(cursor)
fullOutput += page.content
cursor = page.nextCursor
}
expect(fullOutput).toBe('你'.repeat(100_000) + 'late output')
expect(harness.events.at(-1)?.outputReference).toEqual(reference)
await harness.service.releaseOwner('owner')
await expect(harness.service.readOutput('owner', reference.handle)).rejects.toThrow()
harness.scheduler.dispose()
})
@@ -210,6 +229,25 @@ describe('DirectModelSubagentService', () => {
harness.scheduler.dispose()
})
it.each(['failed', 'cancelled'] as const)('retains all partial output after a %s run until disposal', async (status) => {
const controller = new AbortController()
const text = 'x'.repeat(DIRECT_MODEL_SUBAGENT_OUTPUT_MAX_BYTES) + 'tail'
const harness = createHarness(async (input) => {
input.onOutput(text)
if (status === 'cancelled') controller.abort(new Error('cancelled'))
throw new Error('failed')
})
const result = await harness.run({ signal: controller.signal })
expect(result.status).toBe(status)
const reference = result.outputReference!
await expect(harness.service.readOutput('owner', reference.handle, reference.nextCursor)).resolves.toMatchObject({
content: 'tail', eof: true
})
await harness.service.dispose()
await expect(harness.service.readOutput('owner', reference.handle)).rejects.toThrow()
harness.scheduler.dispose()
})
it('emits queued before the shared scheduler admits a run', async () => {
const scheduler = new SubagentScheduler({
concurrency: 1,