Private
Public Access
0
0

straggler spec

This commit is contained in:
2026-06-04 19:42:04 -04:00
parent ba7733b365
commit ce211e76f8
@@ -0,0 +1,59 @@
# Context First Message Fix
## Problem
When sending a message, context is always aggregated and included in the user message even when it's not the first message in the conversation. The context should only be sent on the first message, and subsequent messages should rely on the conversation history maintained by the AI provider.
Additionally, the aggregated context is being shoved into the `user_message` parameter instead of being sent as a separate `md_content` context block.
## Current Behavior
In `src/app_controller.py:_api_generate()`:
```python
full_md, path, file_items, stable_md, disc_text = controller._do_generate()
...
resp = ai_client.send(stable_md, user_msg, base_dir, controller.last_file_items, disc_text, rag_engine=None)
```
The context (file content, screenshots, etc.) is being passed as `md_content` parameter along with the history text. But the problem is that on subsequent messages, this same context is re-sent every time, even though:
1. The AI provider already has the context from the first message (via caching or history)
2. The history (`disc_text`) already contains the previous turns
## Desired Behavior
1. **First message**: Send context (md_content) + user message + history (empty)
2. **Subsequent messages**: Send only the user message + history (no redundant context)
## Implementation Plan
1. **Track whether this is the first message** in the session/discussion
- Add a method to check if the discussion has any AI responses
- Or maintain a flag indicating context has been sent
2. **Modify `_api_generate` to conditionally include context**:
- If this is the first message (no history of AI responses): include `md_content` (stable_md)
- If subsequent message: pass empty string for `md_content` to avoid redundant sending
3. **Ensure context is separate from user_message**:
- The `md_content` parameter should contain the file/screenshot context
- The `user_message` should only contain the current user input
- The `discussion_history` should contain previous turns
## Files to Modify
- `src/app_controller.py` - `_api_generate()` function
- Possibly `src/ai_client.py` - `send()` function logic
## Key Code Locations
1. `src/app_controller.py:338`: `ai_client.send(stable_md, user_msg, ...)`
2. `src/aggregate.py:481`: `build_markdown()` function
3. `src/ai_client.py:2495`: `send()` function signature
## Verification
1. First message should include full context (files, screenshots)
2. Second message should NOT include context again
3. Context should be in md_content, not crammed into user_message