mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
fix(orchestration): refuse reply --on on both sides of a conversation between servers
The side that opened the conversation still took --on when it named the right server; the reply usage says --on is accepted only to refuse it.
This commit is contained in:
@@ -181,6 +181,10 @@ describe('agent mail between paired Orca servers', () => {
|
||||
thread_id: onB!.id
|
||||
})
|
||||
|
||||
await expect(
|
||||
mutation(a, 'orchestration.reply', { id: back!.id, body: 'x', from: 'term_a', on: 'devB' })
|
||||
).resolves.toMatchObject({ ok: false, error: { code: 'request_mismatch' } })
|
||||
|
||||
// The opener can keep answering, and the reply reaches the same agent again.
|
||||
await expect(
|
||||
mutation(a, 'orchestration.reply', { id: back!.id, body: 'Thanks.', from: 'term_a' })
|
||||
|
||||
@@ -41,14 +41,15 @@ export async function replyOverPeerMail(args: {
|
||||
const threadId = original.thread_id ?? original.id
|
||||
const senderLabel = peerMailSenderLabel(runtime, replier)
|
||||
|
||||
if (params.on !== undefined) {
|
||||
throw new OrchestrationError(
|
||||
'request_mismatch',
|
||||
`${original.id} came from ${original.from_handle}; its reply goes back there by itself. Drop --on. No reply was sent.`,
|
||||
NOTHING_SENT
|
||||
)
|
||||
}
|
||||
|
||||
if (conversation.role === 'peer') {
|
||||
if (params.on !== undefined) {
|
||||
throw new OrchestrationError(
|
||||
'request_mismatch',
|
||||
`${original.id} came from ${original.from_handle}; its reply goes back there by itself. Drop --on. No reply was sent.`,
|
||||
NOTHING_SENT
|
||||
)
|
||||
}
|
||||
db.enqueueFederationRelay({
|
||||
dispatchId: conversation.conversation_id,
|
||||
direction: 'to_home',
|
||||
@@ -72,16 +73,6 @@ export async function replyOverPeerMail(args: {
|
||||
}
|
||||
|
||||
const environmentId = conversation.environment_id ?? ''
|
||||
if (params.on !== undefined) {
|
||||
const named = runtime.resolveOrchestrationWorkerServer(params.on)
|
||||
if (named.environmentId !== environmentId) {
|
||||
throw new OrchestrationError(
|
||||
'request_mismatch',
|
||||
`${original.id} came from server ${original.from_handle}, not ${named.name}. Drop --on; the reply goes back there by itself. No reply was sent.`,
|
||||
NOTHING_SENT
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!route.remote_party) {
|
||||
throw new OrchestrationError(
|
||||
'request_mismatch',
|
||||
|
||||
Reference in New Issue
Block a user