Problem
Each message sends only messages: [{ role: 'user', content: prompt }] to the OpenAI API — a single-element array. The messages state in React holds the displayed conversation, but it is never passed to the API call. Follow-up questions have no context from previous answers.
Proposed Solution
- Pass the accumulated
messages array (converted to OpenAI message format) as conversation history
- Inject the legal knowledge base as a
system message once rather than prepending it to every user message
- This also reduces token usage — the 15K-token prompt is currently re-sent on every single message