AOSSIE-Org / AOSSIE-Org/BabyNest

FEATURE REQUEST: Improve frontend behavior when backend agent is disabled (SKIP_AGENT_INIT)

未關閉
#126 3 則留言 1 個 reaction 已指派 1 人 已被 @sharma-sugurthi 認領 在 GitHub 檢視
主要語言
JavaScript
星號
56
分支
124
PR 合併指標
30 天內沒有已合併 PR

描述

### Is your feature request related to a problem?

- [x] Yes, it is related to a problem

### Describe the feature you'd like

Hi,
Right now, the React Native frontend assumes the agent/backend context is usually available:

- `AgentContext` and `ChatScreen` try to:
- Fetch `/agent/context`
- Call `/agent` or other agent-related endpoints
- If the backend is running in **Fast Dev Mode** (e.g. `SKIP_AGENT_INIT=1`, `agent_initialized=false`), or if the agent routes return an error, the user may:
- See generic errors in Chat
- Not understand why AI features depending on backend context are failing
- Not realize that the **local GGUF model is still available** for pure chat

This is confusing for new contributors and for any user/dev who intentionally runs the backend without the agent.

## Proposal

Update the frontend to handle “agent disabled” cleanly and clearly:

### 1. Detect agent availability

In `AgentContext.jsx` and/or `ChatScreen.jsx`:

- Use `/health` (or the error responses from `/agent/context`) to detect **agent status**:
- If `agent_initialized === false`:
- Treat the agent as unavailable for this session.
- If `/agent/context` or `/agent` returns a specific “agent not initialized” / 503-style error:
- Handle that case explicitly instead of treating it as a generic failure.

### 2. Show a clear UI message

When the agent is not available:

- Show a **non-intrusive banner or message** in `ChatScreen`, e.g.:

> “Backend agent is disabled (fast dev mode). Using local model only – some context-aware features may be unavailable.”

- Optionally, show a small indicator (e.g. “Mode: Local Model Only”) so the user knows why RAG-style commands might not work.

### 3. Auto-switch Chat behavior

When agent is unavailable:

- Default Chat to **model-only mode**:
- Bypass RAG/agent flows in `ragService` (no `/agent` or `/agent/context` calls).
- Directly use `generateResponse()` with the local GGUF model.
- When agent becomes available again (e.g. backend restarted without `SKIP_AGENT_INIT`):
- Allow switching back to the normal behavior (RAG + agent context).

### 4. Documentation

Update `Frontend/README.md` (or relevant doc) briefly to explain:

- What happens when:
- Backend is up but `agent_initialized=false`
- Backend is down completely
- How Chat behaves in each case (fallback to local-only mode).

## Request

If this direction sounds good, I’d like to:

1. Implement the agent-availability detection and UI banner in `ChatScreen` / `AgentContext`.
2. Make Chat automatically fall back to model-only mode when the agent is disabled.
3. Add a short note to the frontend docs about this behavior.

Happy to adjust the exact UX (banner text, placement, etc.) based on your preferences.

Thanks!
please assign me @bhavik-mangla @Vivekgupta008

### Record

- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on implementing this feature

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。