fix: allow concurrent and unrestricted Runtime sessions
Local embedded OpenCode serialized otherwise independent conversations, and GoodBuddy could stop long Runtime tasks after fixed tool, activity, model-call, or accumulated display-output limits. Different conversations can now run concurrently while requests in the same conversation stay ordered. Dynamic MCP tools remain isolated to the current request. OpenCode, Continue, managed ACP, and the Agent model gateway no longer stop native execution at GoodBuddy-defined call counts or prompt-wide output totals; display copies truncate and transport queues apply backpressure instead. Prompt-wide quota fields are removed from the current contracts. Per-call model settings, provider request timeouts, cancellation, and same-conversation ordering remain unchanged. Release note: 修复本机 OpenCode 不同会话互相等待的问题,并移除 GoodBuddy 对单次 Runtime 工具、活动和模型调用次数的人为上限;长输出现在只截断展示或施加传输背压,不再取消原生任务。
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
import type { RemoteRuntimeBundleManifest } from '../shared/remote-runtime-launch-contracts'
|
||||
import type { ControllerLease } from './controller-registry'
|
||||
import { AgentModelGatewayError } from './agent-model-gateway'
|
||||
import { EventJournalCapacityError } from './event-journal'
|
||||
import type { ProtocolMethodContext } from './protocol-server'
|
||||
import type {
|
||||
ModelBridgeBrokerDispatch,
|
||||
@@ -43,8 +44,16 @@ class MemoryAcpJournal implements RuntimeAcpJournal {
|
||||
}> = []
|
||||
mainAckSequence = '0'
|
||||
failAppend = false
|
||||
capacityBlocked = false
|
||||
|
||||
appendAcpFrame(input: (typeof this.frames)[number]): { created: boolean } {
|
||||
if (this.capacityBlocked) {
|
||||
throw new EventJournalCapacityError(
|
||||
'journal capacity',
|
||||
'stream',
|
||||
false
|
||||
)
|
||||
}
|
||||
if (this.failAppend) {
|
||||
throw new Error('journal capacity')
|
||||
}
|
||||
@@ -415,8 +424,6 @@ function harness(input: {
|
||||
capabilities: { imageInput: false },
|
||||
limits: {
|
||||
maximumOutputTokens: 4_096,
|
||||
maximumModelCalls: 100,
|
||||
maximumTotalOutputTokens: 409_600,
|
||||
requestTimeoutMilliseconds: 60_000
|
||||
}
|
||||
},
|
||||
@@ -541,6 +548,52 @@ describe('RuntimeAcpBackend', () => {
|
||||
expect(fixture.blobSink).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('allows more than 100 Agent-local model calls in one prompt', async () => {
|
||||
const dispatch = vi.fn(async () => ({
|
||||
response: {
|
||||
status: 200,
|
||||
headers: {},
|
||||
bodyBase64: Buffer.from('{}').toString('base64')
|
||||
},
|
||||
acknowledgeDelivery: vi.fn(async () => undefined),
|
||||
failDelivery: vi.fn()
|
||||
}))
|
||||
const fixture = harness({
|
||||
agentOwned: true,
|
||||
modelGateway: {
|
||||
dispatch,
|
||||
finalizePrompt: vi.fn()
|
||||
}
|
||||
})
|
||||
await open(fixture)
|
||||
await invoke(
|
||||
fixture,
|
||||
'runtime/preparePrompt',
|
||||
fixture.preparation()
|
||||
)
|
||||
|
||||
for (let index = 0; index < 101; index += 1) {
|
||||
const exchange = await fixture.bridgeDispatch!(
|
||||
{
|
||||
method: 'POST',
|
||||
path: '/v1/responses',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
bodyBase64: Buffer.from('{}').toString('base64')
|
||||
},
|
||||
{
|
||||
requestId: `provider-request-${index}`,
|
||||
signal: new AbortController().signal
|
||||
}
|
||||
)
|
||||
if (!('acknowledgeDelivery' in exchange)) {
|
||||
throw new Error('Expected an acknowledged model exchange')
|
||||
}
|
||||
await exchange.acknowledgeDelivery()
|
||||
}
|
||||
|
||||
expect(dispatch).toHaveBeenCalledTimes(101)
|
||||
})
|
||||
|
||||
it('runs open, prepare, ACP delivery, durable output, cursors, and close', async () => {
|
||||
const fixture = harness()
|
||||
const opened = await invoke(
|
||||
@@ -1162,7 +1215,7 @@ describe('RuntimeAcpBackend', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('stops the process when its output quota is exceeded', async () => {
|
||||
it('does not stop the process when cumulative output exceeds the display budget', async () => {
|
||||
const fixture = harness({ maximumOutputBytes: 3 })
|
||||
await open(fixture)
|
||||
await invoke(
|
||||
@@ -1172,9 +1225,30 @@ describe('RuntimeAcpBackend', () => {
|
||||
)
|
||||
await expect(
|
||||
fixture.process.emit('stdout', 'four')
|
||||
).rejects.toMatchObject({ code: 'output-quota' })
|
||||
expect(fixture.process.stops).toEqual(['output-quota'])
|
||||
).resolves.toBeUndefined()
|
||||
expect(fixture.process.stops).toEqual([])
|
||||
expect(fixture.outputFrames).toEqual(['four'])
|
||||
})
|
||||
|
||||
it('waits for durable journal capacity instead of stopping Runtime output', async () => {
|
||||
const fixture = harness()
|
||||
await open(fixture)
|
||||
await invoke(
|
||||
fixture,
|
||||
'runtime/preparePrompt',
|
||||
fixture.preparation()
|
||||
)
|
||||
fixture.journal.capacityBlocked = true
|
||||
const output = fixture.process.emit('stdout', 'later')
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 10))
|
||||
expect(fixture.process.stops).toEqual([])
|
||||
expect(fixture.outputFrames).toEqual([])
|
||||
|
||||
fixture.journal.capacityBlocked = false
|
||||
await output
|
||||
|
||||
expect(fixture.process.stops).toEqual([])
|
||||
expect(fixture.outputFrames).toEqual(['later'])
|
||||
})
|
||||
|
||||
it('stops with output quota when the detached durable journal is exhausted', async () => {
|
||||
|
||||
Reference in New Issue
Block a user