Skip to content

feat(ai-agent): add conversation summary toggle - #1045

Open
jpcoseani wants to merge 1 commit into
ChatbotXIO:mainfrom
jpcoseani:feat/disable-agent-summary
Open

feat(ai-agent): add conversation summary toggle#1045
jpcoseani wants to merge 1 commit into
ChatbotXIO:mainfrom
jpcoseani:feat/disable-agent-summary

Conversation

@jpcoseani

@jpcoseani jpcoseani commented Aug 26, 2026

Copy link
Copy Markdown

Summary

Adds a per-AI-agent setting to disable the accumulated conversation summary that is prepended to the system prompt as Conversation Context.

What changed

  • Added AIAgent.disableSummary with default false.
  • Added migration for the new field.
  • Exposed the flag through create/update schemas and AI agent service types.
  • Added a toggle in the AI agent configuration modal.
  • Prevented runners from prepending Conversation Context when the flag is enabled.
  • Prevented summary generation/enqueueing when the flag is enabled.
  • Keeps only the recent conversation history when summaries are disabled, matching the expected long-conversation trade-off.
  • Added tests for schema defaults, prompt behavior, and skipped summary job enqueueing.

Why

For lead-capture and similar workflows, each new inquiry should be treated independently. The existing accumulated summary can carry stale details from previous inquiries and make the agent treat them as current context.

@github-actions github-actions Bot added the feature New feature or request label Aug 26, 2026
@nguyenvantruc92

Copy link
Copy Markdown
Contributor

@jpcoseani
Hey, thanks for this PR — the idea of letting an agent skip the accumulated conversation summary makes a lot of sense.

Right now, though, the PR is conflicting with main. PR #1046, merged about a day after this PR was opened, rewrote the same appendHistory() flow in packages/ai/src/server/services/ai-context-service.ts, so this branch needs to be synced carefully.

Could you help fix the following before this can be merged:

  1. Rebase onto the latest main and resolve the conflicts carefully. In packages/ai/src/server/services/ai-context-service.ts, please don’t just pick one side over the other. We need to keep the nextSeq dedup mechanism and the MAX_CONVERSATION_HISTORY_HARD_CAP safety net from fix(ai-agent): fix bug ai gent slow reply #1046, while also adding the disableSummary behavior:

    • when disableSummary=true, keep only the latest MAX_CONVERSATION_HISTORY entries;
    • apply that before the hard-cap check;
    • keep nextSeq updating even when history is sliced;
    • keep summarization disabled with shouldSummarize = boundedHistory.length > MAX_CONVERSATION_HISTORY && !disableSummary.
  2. Add the missing audit log check. hasOtherFieldChanges in packages/business/src/ai-agent/service.ts currently checks fields like isRichResponse; after adding this field, it should also check disableSummary. Otherwise, toggling only that setting won’t produce an audit log entry.

  3. Regenerate the migration after rebasing. The current migration snapshot chains from capi_enrichment_columns, but main already has 20260826144212_add_messaging_ads_tables from that same parent. Please delete the old generated migration and regenerate it after rebasing so the snapshot chains from the latest migration:
    pnpm --filter @chatbotx.io/database make:migration add_ai_agent_disable_summary

Also, please preserve the small appendHistory regression test after resolving conflicts: seed history with exactly 100 entries, append one more with disableSummary=true, and assert the persisted history length stays at 100 rather than growing to the 150 hard cap.

Thanks — ping me when it’s ready and I’ll take another look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants