diff --git a/CHANGELOG.md b/CHANGELOG.md index 30daf3f2..1d037b8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,16 @@ ### Added -- **Background Context Support**: Pass initial context to agents via CLI or Python API +- **Background Context Support**: Pass background context to agents via CLI or Python API - `haiku-rag ask --context "..." --context-file path` for Q&A with background context - `haiku-rag research --context "..." --context-file path` for research with background context - `haiku-rag chat --context "..." --context-file path` for chat sessions with persistent context - - `ResearchContext(initial_context="...")` for Python API usage - - `ChatSessionState(initial_context="...")` for chat agent sessions + - `ResearchContext(background_context="...")` for Python API usage + - `ChatSessionState(background_context="...")` for chat agent sessions - Context is included in agent system prompts and research graph planning +- **Frontend Background Context**: Settings panel in the chat app to configure persistent background context + - Context is stored in localStorage and sent with each conversation +- **Frontend Linting**: Added Biome for linting and formatting the frontend codebase ## [0.26.4] - 2026-01-15 diff --git a/app/backend/main.py b/app/backend/main.py index 6479f0ef..e8c4309a 100644 --- a/app/backend/main.py +++ b/app/backend/main.py @@ -82,7 +82,7 @@ async def stream_chat(request: Request) -> Response: # Restore session state from incoming AG-UI state (look under namespaced key) initial_qa_history: list[QAResponse] = [] - initial_context: str | None = None + background_context: str | None = None state = getattr(run_input, "state", None) if state: chat_state = state.get(AGUI_STATE_KEY, state) @@ -90,7 +90,7 @@ async def stream_chat(request: Request) -> Response: initial_qa_history = [ QAResponse(**qa) for qa in chat_state.get("qa_history", []) ] - initial_context = chat_state.get("initial_context") + background_context = chat_state.get("background_context") # Build deps with session state thread_id = getattr(run_input, "thread_id", None) @@ -100,7 +100,7 @@ async def stream_chat(request: Request) -> Response: session_state=ChatSessionState( session_id=thread_id or "", qa_history=initial_qa_history, - initial_context=initial_context, + background_context=background_context, ), state_key=AGUI_STATE_KEY, ) diff --git a/app/frontend/components/Chat.tsx b/app/frontend/components/Chat.tsx index b9bdc2be..68b0c546 100644 --- a/app/frontend/components/Chat.tsx +++ b/app/frontend/components/Chat.tsx @@ -38,7 +38,7 @@ interface ChatSessionState { session_id: string; citations: Citation[]; qa_history: QAResponse[]; - initial_context: string | null; + background_context: string | null; } // AG-UI state is namespaced under AGUI_STATE_KEY @@ -358,24 +358,24 @@ function ToolCallIndicator({ } function ChatContentInner({ - initialContext, - setInitialContext, + backgroundContext, + setBackgroundContext, }: { - initialContext: string; - setInitialContext: (value: string) => void; + backgroundContext: string; + setBackgroundContext: (value: string) => void; }) { const [settingsOpen, setSettingsOpen] = useState(false); const handleSaveContext = useCallback( (value: string) => { - setInitialContext(value); + setBackgroundContext(value); if (value) { localStorage.setItem(STORAGE_KEY, value); } else { localStorage.removeItem(STORAGE_KEY); } }, - [setInitialContext], + [setBackgroundContext], ); useCoAgent({ @@ -385,7 +385,7 @@ function ChatContentInner({ session_id: "", citations: [], qa_history: [], - initial_context: initialContext || null, + background_context: backgroundContext || null, }, }, }); @@ -517,10 +517,10 @@ function ChatContentInner({