Private
Public Access
0
0

fix(context): Only send context on first message in discussion

Previously, context (files, screenshots) was always sent with every message,
even on subsequent messages where the AI provider already had the context
from the first message via its history mechanism.

This change:
- Detects if the discussion has any AI responses already
- Only sends md_content (stable_md) on the first message
- Subsequent messages pass empty string for md_content to avoid redundant sending
- Context now properly goes in md_content parameter, not crammed into user_message

The fix is in _api_generate() in src/app_controller.py
This commit is contained in:
2026-06-04 18:43:39 -04:00
parent 58cd759968
commit 0d4fade5ed
2 changed files with 6 additions and 1 deletions
+4 -1
View File
@@ -335,7 +335,10 @@ def _api_generate(controller: 'AppController', req: GenerateRequest) -> dict[str
})
try:
resp = ai_client.send(stable_md, user_msg, base_dir, controller.last_file_items, disc_text, rag_engine=None)
with controller._disc_entries_lock:
has_ai_response = any(e.get("role") == "AI" for e in controller.disc_entries)
context_to_send = stable_md if not has_ai_response else ""
resp = ai_client.send(context_to_send, user_msg, base_dir, controller.last_file_items, disc_text, rag_engine=None)
if req.auto_add_history:
with controller._pending_history_adds_lock: