Skip to content

Commit c9e4d8f

Browse files
MaxLinCodeclaude
andcommitted
feat: build and inject entityContext into interpretWriteTurn pipeline
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c0f161d commit c9e4d8f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

apps/web/src/lib/server/turn-router.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import {
22
applyWriteCommit,
3+
buildEntityContext,
34
type ConversationDiscourseState,
45
type ConversationEntity,
56
type ConversationTurn,
67
createEmptyDiscourseState,
78
deriveAmbiguity,
89
type PendingWriteOperation,
10+
renderEntityContext,
911
type RoutedTurn,
1012
routedTurnSchema,
13+
taskSchema,
1114
type TurnAmbiguity,
1215
type TurnClassifierOutput,
1316
type TurnInterpretation,
@@ -75,6 +78,7 @@ export async function routeMessageTurn(
7578
): Promise<TurnRouterResult> {
7679
const discourseState = input.discourseState ?? createEmptyDiscourseState();
7780
const entityRegistry = input.entityRegistry ?? [];
81+
const tasks = (input.tasks ?? []).map((task) => taskSchema.parse(task));
7882

7983
// Pipeline A: classify intent
8084
let classification = await classifyTurn({
@@ -122,6 +126,13 @@ export async function routeMessageTurn(
122126
turnType: classification.turnType,
123127
priorPendingWriteOperation: priorOperation,
124128
conversationContext: deriveConversationContext(input.recentTurns),
129+
entityContext: renderEntityContext(
130+
buildEntityContext({
131+
entityRegistry,
132+
tasks,
133+
discourseState,
134+
}),
135+
),
125136
})
126137
: {
127138
operationKind: priorOperation?.operationKind ?? "plan",

0 commit comments

Comments
 (0)