mirror of
https://github.com/stablyai/orca.git
synced 2026-10-22 16:03:47 +00:00
fix(native-chat): rotate settled handoff operations
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { AgentSessionWireRefusalCode } from './agent-session-wire'
|
||||
import { agentSessionRefusalOperationState } from './agent-session-refusal-retry'
|
||||
|
||||
const HANDOFF_SETTLED_CODES = [
|
||||
'structured_agent_session_unsupported',
|
||||
'agent_session_checkpoint_stale',
|
||||
'agent_session_conflict',
|
||||
'agent_session_operation_conflict'
|
||||
] as const satisfies readonly AgentSessionWireRefusalCode[]
|
||||
|
||||
describe('agentSessionRefusalOperationState', () => {
|
||||
it.each(HANDOFF_SETTLED_CODES)('classifies handoff %s as settled', (code) => {
|
||||
expect(agentSessionRefusalOperationState('agentSession.requestHandoff', code)).toBe(
|
||||
'settled-rejected'
|
||||
)
|
||||
})
|
||||
|
||||
it.each(['agentSession.setOption', 'agentSession.send'])(
|
||||
'keeps %s admission refusals pending',
|
||||
(method) => {
|
||||
for (const code of HANDOFF_SETTLED_CODES) {
|
||||
expect(agentSessionRefusalOperationState(method, code)).toBe('pending-admission')
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -3,8 +3,18 @@ import type { AgentSessionWireRefusalCode } from './agent-session-wire'
|
||||
export type AgentSessionRefusalOperationState = 'settled-rejected' | 'pending-admission' | 'unknown'
|
||||
|
||||
export function agentSessionRefusalOperationState(
|
||||
method: string,
|
||||
code: AgentSessionWireRefusalCode
|
||||
): AgentSessionRefusalOperationState {
|
||||
if (method === 'agentSession.requestHandoff') {
|
||||
switch (code) {
|
||||
case 'structured_agent_session_unsupported':
|
||||
case 'agent_session_checkpoint_stale':
|
||||
case 'agent_session_conflict':
|
||||
case 'agent_session_operation_conflict':
|
||||
return 'settled-rejected'
|
||||
}
|
||||
}
|
||||
switch (code) {
|
||||
case 'agent_session_operation_invalid':
|
||||
case 'agent_session_item_revision_stale':
|
||||
|
||||
Reference in New Issue
Block a user