Allow chat history to be sent to AI engine (#6128)

# Description of Changes
Add an extra parameter to every agent to receive the conversation
history in addition to the current message. This will make it possible
to answer followup questions from the AI without needing to give full
context in your message.
This commit is contained in:
James Brunton
2026-04-21 15:03:10 +00:00
committed by GitHub
parent f779085d75
commit 2a856fbc19
14 changed files with 116 additions and 19 deletions
@@ -238,6 +238,8 @@ export function ChatProvider({ children }: { children: ReactNode }) {
const { files: activeFiles, fileStubs: activeFileStubs } = useAllFiles();
const { actions: fileActions } = useFileActions();
const abortRef = useRef<AbortController | null>(null);
const messagesRef = useRef<ChatMessage[]>(state.messages);
messagesRef.current = state.messages;
// Download a File from the Stirling files endpoint.
const downloadFile = useCallback(
@@ -323,6 +325,8 @@ export function ChatProvider({ children }: { children: ReactNode }) {
const controller = new AbortController();
abortRef.current = controller;
const priorMessages = messagesRef.current;
const userMessage: ChatMessage = {
id: crypto.randomUUID(),
role: "user",
@@ -339,6 +343,10 @@ export function ChatProvider({ children }: { children: ReactNode }) {
activeFiles.forEach((file, i) => {
formData.append(`fileInputs[${i}].fileInput`, file);
});
priorMessages.forEach((message, i) => {
formData.append(`conversationHistory[${i}].role`, message.role);
formData.append(`conversationHistory[${i}].content`, message.content);
});
const response = await fetch("/api/v1/ai/orchestrate/stream", {
method: "POST",