Guided Portfolio Conversation — Selected Source
Selected public-safe excerpts for context bounds, clearing, and export safety.
README · ARCHITECTURE · TECHNICAL
These shortened excerpts show the boundaries rather than reproducing the private production repository.
Bounded browser context
export const MAX_CONVERSATION_SUMMARY_CHARS = 2_000;
export const MAX_CONVERSATION_TURNS = 6;
export const MAX_CONVERSATION_TURN_CHARS = 1_200;
export const MAX_CONVERSATION_CONTEXT_CHARS = 6_000;
Several independent caps make the request limit legible and testable.
Epoch-safe completion
const requestEpoch = conversationRef.current.epoch;
function recordCompletedConversation(question, answer, summary, epoch) {
if (conversationRef.current.epoch !== epoch) return;
// Add the completed exchange.
}
clear creates a new epoch. Even if old asynchronous work finishes, it no longer has permission to mutate the new conversation.
Fixed HTML, escaped data
function escapeHtml(value: string) {
return value
.replaceAll("&", "&")
.replaceAll("<", "<")
.replaceAll(">", ">");
}
The production helper also escapes quotes. The important design choice is that generated text is data inserted into a fixed template; the model does not write executable markup.
Snapshot note
These excerpts show the shape of the current implementation, not the complete production routes. Authentication, operational logging, provider calls, and surrounding error handling are intentionally left out of this public packet.