11import { Agent } from "@ai-sdk-tools/agents" ;
22import type { AppContext } from "./config/context" ;
3- import {
4- extendedMemoryConfig ,
5- maxMemoryConfig ,
6- memoryTools ,
7- minimalMemoryConfig ,
8- standardMemoryConfig ,
9- withUserProfile ,
10- } from "./config/memory" ;
3+
114import { models } from "./config/models" ;
125import { buildAnalyticsInstructions } from "./prompts/analytics" ;
136import { buildReflectionInstructions } from "./prompts/reflection" ;
@@ -17,7 +10,6 @@ import { executeQueryBuilderTool } from "./tools/execute-query-builder";
1710import { executeSqlQueryTool } from "./tools/execute-sql-query" ;
1811import { createFunnelTools } from "./tools/funnels" ;
1912import { getTopPagesTool } from "./tools/get-top-pages" ;
20- import { competitorAnalysisTool , webSearchTool } from "./tools/web-search" ;
2113
2214/**
2315 * Creates analytics tools with context-aware funnels tools.
@@ -44,23 +36,11 @@ function createAnalyticsTools(context: {
4436 get_top_pages : getTopPagesTool ,
4537 execute_query_builder : executeQueryBuilderTool ,
4638 execute_sql_query : executeSqlQueryTool ,
47- web_search : webSearchTool ,
48- competitor_analysis : competitorAnalysisTool ,
4939 ...funnelTools ,
5040 ...annotationTools ,
51- ...( Object . keys ( memoryTools ) . length > 0 ? memoryTools : { } ) ,
5241 } as const ;
5342}
5443
55- /**
56- * Tools available to triage agent.
57- */
58- const triageTools = {
59- web_search : webSearchTool ,
60- competitor_analysis : competitorAnalysisTool ,
61- ...( Object . keys ( memoryTools ) . length > 0 ? memoryTools : { } ) ,
62- } as const ;
63-
6444/**
6545 * Creates an analytics specialist agent with user-specific memory.
6646 * Handles website traffic analysis, user behavior, and performance metrics.
@@ -82,11 +62,10 @@ export function createAnalyticsAgent(
8262
8363 return new Agent ( {
8464 name : "analytics" ,
85- model : withUserProfile ( models . analytics , userId ) ,
65+ model : models . analytics ,
8666 temperature : 0.3 ,
8767 instructions : buildAnalyticsInstructions ,
8868 tools,
89- memory : standardMemoryConfig ,
9069 modelSettings : {
9170 failureMode : {
9271 maxAttempts : 2 ,
@@ -113,19 +92,16 @@ export const createReflectionAgent = (
11392) => {
11493 const config = {
11594 standard : {
116- model : withUserProfile ( models . advanced , userId ) ,
95+ model : models . advanced ,
11796 maxTurns : 15 ,
118- memory : extendedMemoryConfig , // 30 messages for Sonnet
11997 } ,
12098 haiku : {
121- model : withUserProfile ( models . analytics , userId ) ,
99+ model : models . analytics ,
122100 maxTurns : 15 ,
123- memory : standardMemoryConfig , // 20 messages for Haiku
124101 } ,
125102 max : {
126- model : withUserProfile ( models . advanced , userId ) ,
103+ model : models . advanced ,
127104 maxTurns : 20 ,
128- memory : maxMemoryConfig , // 40 messages for deep investigations
129105 } ,
130106 } [ variant ] ;
131107
@@ -160,11 +136,9 @@ export function createTriageAgent(
160136) {
161137 return new Agent ( {
162138 name : "triage" ,
163- model : withUserProfile ( models . triage , userId ) ,
139+ model : models . triage ,
164140 temperature : 0.1 ,
165141 instructions : buildTriageInstructions ,
166- tools : triageTools ,
167- memory : minimalMemoryConfig ,
168142 modelSettings : {
169143 toolChoice : {
170144 type : "tool" ,
0 commit comments