11import {
22 type ConversationEntity ,
3- getActivePendingClarifications ,
43 type TurnClassifierInput ,
54 type TurnClassifierOutput ,
65} from "@atlas/core" ;
@@ -14,7 +13,6 @@ export async function classifyTurn(
1413 client ?: OpenAIResponsesClient ,
1514) : Promise < TurnClassifierOutput > {
1615 const entityRegistry = input . entityRegistry ?? [ ] ;
17- const discourseState = input . discourseState ?? null ;
1816 const normalizedText = input . normalizedText . trim ( ) ;
1917 const lower = normalizedText . toLowerCase ( ) ;
2018
@@ -26,11 +24,6 @@ export async function classifyTurn(
2624 ( entity . status === "active" || entity . status === "presented" ) ,
2725 ) ;
2826
29- const resolvedEntityIds = compactResolvedEntityIds ( [
30- discourseState ?. currently_editable_entity_id ?? null ,
31- discourseState ?. focus_entity_id ?? null ,
32- ] ) ;
33-
3427 const singleProposal =
3528 activeProposals . length === 1 ? activeProposals [ 0 ] : null ;
3629
@@ -39,43 +32,22 @@ export async function classifyTurn(
3932 return {
4033 turnType : "confirmation" ,
4134 confidence : 0.97 ,
42- resolvedEntityIds : singleProposal . data . targetEntityId
43- ? [ singleProposal . data . targetEntityId ]
44- : resolvedEntityIds ,
45- resolvedProposalId : singleProposal . id ,
4635 } ;
4736 }
4837
49- // TEMP: disabled informational fast-exit until routing stabilizes
50- // Fast-exit informational: question lead + no write verbs + no active clarifications
51- // const activeClarifications = discourseState
52- // ? getActivePendingClarifications(discourseState)
53- // : [];
54-
55- // if (isInformationalTurn(lower) && activeClarifications.length === 0 && !containsWriteVerb(lower)) {
56- // return {
57- // turnType: "informational",
58- // confidence: 0.93,
59- // resolvedEntityIds
60- // };
61- // }
62-
6338 // Everything else → LLM
6439 try {
6540 const llmResponse = await classifyTurnWithResponses ( input , client ) ;
6641
6742 return {
6843 turnType : llmResponse . turnType ,
6944 confidence : Math . max ( 0 , Math . min ( 1 , llmResponse . confidence ) ) ,
70- resolvedEntityIds,
71- ...( singleProposal ? { resolvedProposalId : singleProposal . id } : { } ) ,
7245 } ;
7346 } catch {
7447 // Degrade gracefully: return unknown with low confidence
7548 return {
7649 turnType : "unknown" ,
7750 confidence : 0.3 ,
78- resolvedEntityIds,
7951 } ;
8052 }
8153}
@@ -86,20 +58,3 @@ function isPureConfirmationTurn(lower: string) {
8658 ) ;
8759}
8860
89- function isInformationalTurn ( lower : string ) {
90- return / ^ ( w h a t | w h e n | w h e r e | w h y | h o w | w h o | w h i c h | c a n y o u e x p l a i n | t e l l m e ) \b / . test (
91- lower ,
92- ) ;
93- }
94-
95- function containsWriteVerb ( lower : string ) {
96- return / \b ( s c h e d u l e | p l a n | m o v e | r e s c h e d u l e | s h i f t | c r e a t e | a d d | b o o k | p u t | m a r k | c o m p l e t e | a r c h i v e | c a n c e l | d e l e t e | c h a n g e | u p d a t e ) \b / . test (
97- lower ,
98- ) ;
99- }
100-
101- function compactResolvedEntityIds ( entityIds : Array < string | null > ) {
102- return Array . from (
103- new Set ( entityIds . filter ( ( id ) : id is string => Boolean ( id ) ) ) ,
104- ) ;
105- }
0 commit comments