twenty/packages/twenty-server
Félix Malfait 3216b634a3
feat: improve AI chat - system prompt, tool output, context window display (#17769)
⚠️ **AI-generated PR — not ready for review** ⚠️

cc @FelixMalfait

---

## Changes

### System prompt improvements
- Explicit skill-before-tools workflow to prevent the model from calling
tools without loading the matching skill first
- Data efficiency guidance (default small limits, use filters)
- Pluralized `load_skill` → `load_skills` for consistency with
`load_tools`

### Token usage reduction
- Output serialization layer: strips null/undefined/empty values from
tool results
- Lowered default `find_*` limit from 100 → 10, max from 1000 → 100

### System object tool generation
- System objects (calendar events, messages, etc.) now generate AI tools
- Only workflow-related and favorite-related objects are excluded

### Context window display fix
- **Bug**: UI compared cumulative tokens (sum of all turns) against
single-request context window → showed 100% after a few turns
- **Fix**: Track `conversationSize` (last step's `inputTokens`) which
represents the actual conversation history size sent to the model
- New `conversationSize` column on thread entity with migration

### Workspace AI instructions
- Support for custom workspace-level AI instructions

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
2026-02-09 14:26:02 +01:00
..
@types Row level permissions - POC 1 (#16599) 2025-12-31 16:15:17 +01:00
patches Create query runner context from request context instead of schema builder internal context (#16858) 2025-12-30 15:16:57 +01:00
scripts Fixed eslint warnings on changed files (#15928) 2025-11-19 17:13:07 +01:00
src feat: improve AI chat - system prompt, tool output, context window display (#17769) 2026-02-09 14:26:02 +01:00
test Reorganize logic function files (#17766) 2026-02-09 12:36:39 +01:00
.env.e2e-testing-server e2e tests (#16533) 2025-12-17 08:48:17 +01:00
.env.example Added option to prevent sending requests to twenty-icons (#16723) 2026-01-30 16:56:22 +01:00
.env.test Refactor rls backend simplify add tests (#17357) 2026-01-22 15:44:18 +00:00
.gitignore
.prettierignore
.swcrc Lingui working with NODE ENV=production again (#10067) 2025-02-07 10:05:07 +01:00
eslint.config.mjs Reorganize logic function files (#17766) 2026-02-09 12:36:39 +01:00
jest-integration.config.ts feat(i18n): fix translation QA issues and add automation (#16756) 2025-12-22 17:30:46 +01:00
jest.config.mjs Refactor read only object and fields (#13936) 2025-08-19 18:10:35 +02:00
lingui.config.ts BREAKING - feat(auth): refactor tokens logic & enhance email verification flow (#13487) 2025-07-31 12:00:59 +02:00
nest-cli.json Reorganize logic function files (#17766) 2026-02-09 12:36:39 +01:00
package.json feat: improve AI chat - system prompt, tool output, context window display (#17769) 2026-02-09 14:26:02 +01:00
project.json feat: migrate typecheck to tsgo for faster type checking (#17331) 2026-01-22 13:39:07 +01:00
setupTests.ts Re-add prettier (#13812) 2025-08-11 14:10:04 +02:00
tsconfig.build.json
tsconfig.json Upgrade NestJS from 10.x to 11.x (#15836) 2025-11-16 18:20:06 +01:00
tsconfig.scripts.json