Let Send-now steer a queued message while an earlier steer is unechoed (#43293)

This commit is contained in:
Brennan Benson
2026-11-16 16:11:05 -08:00
committed by GitHub
parent 199e7aa480
commit 469d44b9ec
2 changed files with 24 additions and 12 deletions
@@ -134,20 +134,19 @@ export function sendQueuedStructuredAgentMessage(
if (row.body.command && work.working()) {
return invalid("A command can't be sent while the agent is working.")
}
// An earlier unechoed send never blocks: delivery orders handovers behind it and its opening turn.
if (
(work.activeTurnId() !== null || work.queueState().owedEnteredSubmissions.length > 0) &&
(work.activeTurnId() === null ||
work.queueState().owedEnteredSubmissions.length > 0 ||
!canSteerStructuredQueuedMessage(
{
record,
work,
child: context.sessions.get(ctx.sessionId)?.child,
stopping: await context.readStopping(ctx.sessionId),
adapter: context.deps.adapter
},
row
))
!canSteerStructuredQueuedMessage(
{
record,
work,
child: context.sessions.get(ctx.sessionId)?.child,
stopping: await context.readStopping(ctx.sessionId),
adapter: context.deps.adapter
},
row
)
) {
return {
ok: false,
@@ -72,3 +72,16 @@ it('a steer send waiting on approval joins the running turn when approval clears
await eventually(async () => expect((await rig.handoff(steer.id))?.handedOverAt).toBeDefined())
expect(await rig.handoff(queueOnly.id)).toBeUndefined()
})
it('Send-now steers a second card while the first steer is still unechoed', async () => {
const opener = await rig.workingSend()
await rig.settleAccepted(opener, 'opening')
await openRigTurnFor(rig, opener)
const first = rig.send('first card', 'queue-if-active')
const second = rig.send('second card', 'queue-if-active')
await Promise.all([first.result, second.result])
expect(await rig.sendNow(first.id)).toMatchObject({ ok: true })
await eventually(async () => expect((await rig.handoff(first.id))?.handedOverAt).toBeDefined())
expect(await rig.sendNow(second.id)).toMatchObject({ ok: true })
await eventually(async () => expect((await rig.handoff(second.id))?.handedOverAt).toBeDefined())
})