Skip to content

Commit fbbfb58

Browse files
authored
Merge pull request #245 from codelitdev/fix/chat-history-limit
Stop the chat from sending its whole history with each message
2 parents a996b9c + 79a4438 commit fbbfb58

3 files changed

Lines changed: 3 additions & 18 deletions

File tree

‎apps/api/docs/ai-agent.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,9 @@ The widget appends an assistant message only when `answer` is non-null. For
501501
here” state and continues polling the same thread.
502502

503503
Public chat request validation requires a 1–4,000-character `message` and
504-
either both `conversationId` and `conversationToken` or neither. The legacy
505-
client `history` field may be accepted during rollout but is ignored; persisted
506-
ticket messages are the only history supplied to the model.
504+
either both `conversationId` and `conversationToken` or neither. Clients don't
505+
send history; persisted ticket messages are the only history supplied to the
506+
model.
507507

508508
Permissions are field-level:
509509

‎apps/sites/lib/use-visitor-chat.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,6 @@ export function useVisitorChat({
456456
if ((!question && pendingFiles.length === 0) || isSending || attaching) return;
457457
if (sessionExpired) return;
458458

459-
const history = messages
460-
.filter((m) => !m.error)
461-
.map((m) => ({ role: m.role, content: m.content }));
462-
463459
const userMessage: ChatMessage = {
464460
id: newId("local"),
465461
role: "user",
@@ -482,7 +478,6 @@ export function useVisitorChat({
482478
headers: { "content-type": "application/json" },
483479
body: JSON.stringify({
484480
message: question,
485-
history,
486481
attachmentIds: pendingFiles.map((file) => file.attachmentId),
487482
...(conversation
488483
? {

‎packages/api-contract/src/schemas/chatbot.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,6 @@ export const chatRequestBodySchema = z
9898
* ticket from the session, or continues their open one. */
9999
sessionToken: z.string().optional(),
100100
attachmentIds: z.array(z.string().min(1)).max(5).optional(),
101-
/** Ignored. Persisted ticket messages are the only model history. */
102-
history: z
103-
.array(
104-
z.object({
105-
role: z.enum(["user", "assistant"]),
106-
content: z.string(),
107-
}),
108-
)
109-
.max(20)
110-
.optional(),
111101
})
112102
.refine(
113103
(value) => Boolean(value.conversationId) === Boolean(value.conversationToken),

0 commit comments

Comments
 (0)