Show tool execution messages in AI agent chat (#13117)
https://github.com/user-attachments/assets/c0a42726-50ac-496e-a993-9d6076a84a6a --------- Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { AgentService } from 'src/engine/metadata-modules/agent/agent.service';
|
||||
import { AgentResolver } from 'src/engine/metadata-modules/agent/agent.resolver';
|
||||
import {
|
||||
AgentException,
|
||||
AgentExceptionCode,
|
||||
} from 'src/engine/metadata-modules/agent/agent.exception';
|
||||
import { AgentResolver } from 'src/engine/metadata-modules/agent/agent.resolver';
|
||||
import { AgentService } from 'src/engine/metadata-modules/agent/agent.service';
|
||||
|
||||
// Mock the agent service
|
||||
jest.mock('../../../../../src/engine/metadata-modules/agent/agent.service');
|
||||
|
||||
@ -216,7 +216,7 @@ describe('AgentToolService Integration', () => {
|
||||
}
|
||||
|
||||
const result = await createTool.execute(
|
||||
{ name: 'Test Record', description: 'Test description' },
|
||||
{ input: { name: 'Test Record', description: 'Test description' } },
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
messages: [
|
||||
@ -260,7 +260,7 @@ describe('AgentToolService Integration', () => {
|
||||
}
|
||||
|
||||
const result = await createTool.execute(
|
||||
{ name: 'Test Record' },
|
||||
{ input: { name: 'Test Record' } },
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
messages: [
|
||||
@ -304,7 +304,7 @@ describe('AgentToolService Integration', () => {
|
||||
}
|
||||
|
||||
const result = await findTool.execute(
|
||||
{ limit: 10, offset: 0 },
|
||||
{ input: { limit: 10, offset: 0 } },
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
messages: [
|
||||
@ -352,7 +352,7 @@ describe('AgentToolService Integration', () => {
|
||||
}
|
||||
|
||||
const result = await findOneTool.execute(
|
||||
{ id: 'test-record-id' },
|
||||
{ input: { id: 'test-record-id' } },
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
messages: [
|
||||
@ -393,7 +393,7 @@ describe('AgentToolService Integration', () => {
|
||||
}
|
||||
|
||||
const result = await findOneTool.execute(
|
||||
{ id: 'non-existent-id' },
|
||||
{ input: { id: 'non-existent-id' } },
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
messages: [
|
||||
@ -430,7 +430,7 @@ describe('AgentToolService Integration', () => {
|
||||
}
|
||||
|
||||
const result = await findOneTool.execute(
|
||||
{},
|
||||
{ input: {} },
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
messages: [
|
||||
@ -488,9 +488,11 @@ describe('AgentToolService Integration', () => {
|
||||
|
||||
const result = await updateTool.execute(
|
||||
{
|
||||
id: 'test-record-id',
|
||||
name: 'New Name',
|
||||
description: 'New description',
|
||||
input: {
|
||||
id: 'test-record-id',
|
||||
name: 'New Name',
|
||||
description: 'New description',
|
||||
},
|
||||
},
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
@ -534,8 +536,10 @@ describe('AgentToolService Integration', () => {
|
||||
|
||||
const result = await updateTool.execute(
|
||||
{
|
||||
id: 'non-existent-id',
|
||||
name: 'New Name',
|
||||
input: {
|
||||
id: 'non-existent-id',
|
||||
name: 'New Name',
|
||||
},
|
||||
},
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
@ -583,7 +587,7 @@ describe('AgentToolService Integration', () => {
|
||||
}
|
||||
|
||||
const result = await softDeleteTool.execute(
|
||||
{ id: 'test-record-id' },
|
||||
{ input: { id: 'test-record-id' } },
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
messages: [
|
||||
@ -624,7 +628,9 @@ describe('AgentToolService Integration', () => {
|
||||
|
||||
const result = await softDeleteManyTool.execute(
|
||||
{
|
||||
filter: { id: { in: ['record-1', 'record-2', 'record-3'] } },
|
||||
input: {
|
||||
filter: { id: { in: ['record-1', 'record-2', 'record-3'] } },
|
||||
},
|
||||
},
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
@ -671,7 +677,7 @@ describe('AgentToolService Integration', () => {
|
||||
}
|
||||
|
||||
const result = await findTool.execute(
|
||||
{},
|
||||
{ input: {} },
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
messages: [
|
||||
@ -716,10 +722,12 @@ describe('AgentToolService Integration', () => {
|
||||
|
||||
const result = await findTool.execute(
|
||||
{
|
||||
name: null,
|
||||
description: undefined,
|
||||
status: '',
|
||||
validField: 'valid value',
|
||||
input: {
|
||||
name: null,
|
||||
description: undefined,
|
||||
status: '',
|
||||
validField: 'valid value',
|
||||
},
|
||||
},
|
||||
{
|
||||
toolCallId: 'test-tool-call-id',
|
||||
|
||||
@ -3,6 +3,7 @@ import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import { ToolService } from 'src/engine/core-modules/ai/services/tool.service';
|
||||
import { AgentToolService } from 'src/engine/metadata-modules/agent/agent-tool.service';
|
||||
import { AgentEntity } from 'src/engine/metadata-modules/agent/agent.entity';
|
||||
import { AgentService } from 'src/engine/metadata-modules/agent/agent.service';
|
||||
@ -12,7 +13,6 @@ import { RoleEntity } from 'src/engine/metadata-modules/role/role.entity';
|
||||
import { WorkspacePermissionsCacheService } from 'src/engine/metadata-modules/workspace-permissions-cache/workspace-permissions-cache.service';
|
||||
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
|
||||
import { WorkspaceEventEmitter } from 'src/engine/workspace-event-emitter/workspace-event-emitter';
|
||||
import { ToolService } from 'src/engine/core-modules/ai/services/tool.service';
|
||||
|
||||
export interface AgentToolTestContext {
|
||||
module: TestingModule;
|
||||
@ -103,7 +103,10 @@ export const createAgentToolTestModule =
|
||||
|
||||
const testAgent: AgentEntity & { roleId: string | null } = {
|
||||
id: testAgentId,
|
||||
name: 'Test Agent',
|
||||
name: 'test-agent',
|
||||
label: 'Test Agent',
|
||||
icon: 'IconTest',
|
||||
isCustom: false,
|
||||
description: 'Test agent for integration tests',
|
||||
prompt: 'You are a test agent',
|
||||
modelId: 'gpt-4o',
|
||||
|
||||
Reference in New Issue
Block a user