@@ -27,7 +27,7 @@ export type TurnRouterInput = TurnRoutingInput;
2727export type TurnRouterResult = RoutedTurn ;
2828
2929const DEFAULT_CONTRACT : WriteContract = {
30- requiredSlots : [ ] ,
30+ requiredSlots : [ "day" , "time" ] ,
3131 intentKind : "plan"
3232} ;
3333
@@ -46,13 +46,10 @@ export async function routeMessageTurn(input: TurnRouterInput): Promise<TurnRout
4646 const activeContract = discourseState . pending_write_contract ?? DEFAULT_CONTRACT ;
4747 let slotExtraction = null ;
4848
49- if (
50- SLOT_COMMITTING_TURN_TYPES . has ( classification . turnType ) &&
51- discourseState . pending_write_contract
52- ) {
49+ if ( SLOT_COMMITTING_TURN_TYPES . has ( classification . turnType ) ) {
5350 slotExtraction = await extractSlots ( {
5451 currentTurnText : input . normalizedText ,
55- pendingSlots : derivePendingSlots ( discourseState ) ,
52+ pendingSlots : derivePendingSlots ( activeContract , discourseState . resolved_slots ?? { } ) ,
5653 priorResolvedSlots : discourseState . resolved_slots ?? { } ,
5754 conversationContext : deriveConversationContext ( input . recentTurns )
5855 } ) ;
@@ -83,11 +80,8 @@ export async function routeMessageTurn(input: TurnRouterInput): Promise<TurnRout
8380 } ) ;
8481}
8582
86- function derivePendingSlots ( discourseState : DiscourseState ) : SlotKey [ ] {
87- const contract = discourseState . pending_write_contract ;
88- if ( ! contract ) return [ ] ;
89- const resolved = discourseState . resolved_slots ?? { } ;
90- return contract . requiredSlots . filter ( ( slot ) => resolved [ slot ] === undefined ) ;
83+ function derivePendingSlots ( contract : WriteContract , resolvedSlots : Record < string , unknown > ) : SlotKey [ ] {
84+ return contract . requiredSlots . filter ( ( slot ) => resolvedSlots [ slot ] === undefined ) ;
9185}
9286
9387function deriveConversationContext ( recentTurns : ConversationTurn [ ] ) : string {
0 commit comments