Skip to content

Commit d1a4902

Browse files
authored
[AI] Drop 'serialization' from tool output naming (#20052)
didnt made sense anymore -- we dont really 'serialize'
1 parent 89ad87a commit d1a4902

7 files changed

Lines changed: 16 additions & 16 deletions

File tree

packages/twenty-server/src/engine/core-modules/tool-provider/interfaces/tool-retrieval-options.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export type ToolRetrievalOptions = {
88
// Apply output compaction (strip nulls/empty values) to dispatch results
99
// before returning. Chat enables this to reduce token usage in the
1010
// conversation context; MCP and workflow agents leave raw output intact.
11-
serializeOutput?: boolean;
11+
compactOutput?: boolean;
1212
};

packages/twenty-server/src/engine/core-modules/tool-provider/output-serialization/__tests__/strip-empty-values.util.spec.ts renamed to packages/twenty-server/src/engine/core-modules/tool-provider/output-transforms/__tests__/strip-empty-values.util.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { stripEmptyValues } from 'src/engine/core-modules/tool-provider/output-serialization/strip-empty-values.util';
1+
import { stripEmptyValues } from 'src/engine/core-modules/tool-provider/output-transforms/strip-empty-values.util';
22

33
describe('stripEmptyValues', () => {
44
it('should remove null values', () => {

packages/twenty-server/src/engine/core-modules/tool-provider/output-serialization/compact-tool-output.util.ts renamed to packages/twenty-server/src/engine/core-modules/tool-provider/output-transforms/compact-tool-output.util.ts

File renamed without changes.

packages/twenty-server/src/engine/core-modules/tool-provider/output-serialization/strip-empty-values.util.ts renamed to packages/twenty-server/src/engine/core-modules/tool-provider/output-transforms/strip-empty-values.util.ts

File renamed without changes.

packages/twenty-server/src/engine/core-modules/tool-provider/services/tool-registry.service.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { type ToolProviderContext } from 'src/engine/core-modules/tool-provider/
77
import { type ToolRetrievalOptions } from 'src/engine/core-modules/tool-provider/interfaces/tool-retrieval-options.type';
88

99
import { TOOL_PROVIDERS } from 'src/engine/core-modules/tool-provider/constants/tool-providers.token';
10-
import { compactToolOutput } from 'src/engine/core-modules/tool-provider/output-serialization/compact-tool-output.util';
10+
import { compactToolOutput } from 'src/engine/core-modules/tool-provider/output-transforms/compact-tool-output.util';
1111
import { ToolExecutorService } from 'src/engine/core-modules/tool-provider/services/tool-executor.service';
1212
import { type LearnToolsAspect } from 'src/engine/core-modules/tool-provider/tools/learn-tools.tool';
1313
import { type ToolContext } from 'src/engine/core-modules/tool-provider/types/tool-context.type';
@@ -107,12 +107,12 @@ export class ToolRegistryService {
107107
options?: {
108108
wrapWithErrorContext?: boolean;
109109
includeLoadingMessage?: boolean;
110-
serializeOutput?: boolean;
110+
compactOutput?: boolean;
111111
},
112112
): ToolSet {
113113
const toolSet: ToolSet = {};
114114
const includeLoadingMessage = options?.includeLoadingMessage ?? true;
115-
const serializeOutput = options?.serializeOutput ?? false;
115+
const compactOutput = options?.compactOutput ?? false;
116116

117117
for (const descriptor of descriptors) {
118118
const baseSchema = descriptor.inputSchema as Record<string, unknown>;
@@ -133,7 +133,7 @@ export class ToolRegistryService {
133133
context,
134134
);
135135

136-
return serializeOutput
136+
return compactOutput
137137
? (compactToolOutput(result) as ToolOutput)
138138
: result;
139139
};
@@ -170,7 +170,7 @@ export class ToolRegistryService {
170170
context: ToolContext,
171171
options?: {
172172
includeLoadingMessage?: boolean;
173-
serializeOutput?: boolean;
173+
compactOutput?: boolean;
174174
},
175175
): Promise<ToolSet> {
176176
const fullContext = this.buildContextFromToolContext(context);
@@ -190,7 +190,7 @@ export class ToolRegistryService {
190190

191191
return this.hydrateToolSet(descriptors, fullContext, {
192192
includeLoadingMessage: options?.includeLoadingMessage,
193-
serializeOutput: options?.serializeOutput,
193+
compactOutput: options?.compactOutput,
194194
});
195195
}
196196

@@ -236,7 +236,7 @@ export class ToolRegistryService {
236236
toolName: string,
237237
args: Record<string, unknown> | undefined,
238238
context: ToolContext,
239-
options?: { serializeOutput?: boolean },
239+
options?: { compactOutput?: boolean },
240240
): Promise<ToolOutput> {
241241
try {
242242
const fullContext = this.buildContextFromToolContext(context);
@@ -258,7 +258,7 @@ export class ToolRegistryService {
258258
fullContext,
259259
);
260260

261-
return options?.serializeOutput
261+
return options?.compactOutput
262262
? (compactToolOutput(result) as ToolOutput)
263263
: result;
264264
} catch (error) {
@@ -286,7 +286,7 @@ export class ToolRegistryService {
286286
excludeTools,
287287
wrapWithErrorContext,
288288
includeLoadingMessage,
289-
serializeOutput,
289+
compactOutput,
290290
} = options;
291291
const categorySet = categories ? new Set(categories) : undefined;
292292

@@ -321,7 +321,7 @@ export class ToolRegistryService {
321321
const toolSet = this.hydrateToolSet(filteredDescriptors, context, {
322322
wrapWithErrorContext,
323323
includeLoadingMessage,
324-
serializeOutput,
324+
compactOutput,
325325
});
326326

327327
this.logger.log(

packages/twenty-server/src/engine/core-modules/tool-provider/tools/execute-tool.tool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const createExecuteToolTool = (
4949
context: ToolContext,
5050
options?: {
5151
excludeTools?: Set<string>;
52-
serializeOutput?: boolean;
52+
compactOutput?: boolean;
5353
},
5454
) => ({
5555
description:
@@ -67,7 +67,7 @@ export const createExecuteToolTool = (
6767
}
6868

6969
return toolRegistry.resolveAndExecute(toolName, args, context, {
70-
serializeOutput: options?.serializeOutput,
70+
compactOutput: options?.compactOutput,
7171
});
7272
},
7373
});

packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/chat-execution.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class ChatExecutionService {
138138
const preloadedTools = await this.toolRegistry.getToolsByName(
139139
AI_CHAT_TOOL_NAMES_TO_PRELOAD,
140140
toolContext,
141-
{ serializeOutput: true },
141+
{ compactOutput: true },
142142
);
143143

144144
const resolvedModelId = modelId ?? workspace.smartModel;
@@ -186,7 +186,7 @@ export class ChatExecutionService {
186186
[EXECUTE_TOOL_TOOL_NAME]: createExecuteToolTool(
187187
this.toolRegistry,
188188
toolContext,
189-
{ serializeOutput: true },
189+
{ compactOutput: true },
190190
),
191191
[LOAD_SKILL_TOOL_NAME]: createLoadSkillTool(
192192
(skillNames) =>

0 commit comments

Comments
 (0)