Fix ACD turn summary loss and add /dump command
ACD (Aggressive Context Dehydration) fixes: - Fixed dehydrate_context() to extract turn summary from context window instead of using the passed-in final_response (which contained only the timing footer, not the actual LLM response) - Removed final_response parameter from dehydrate_context() since it now self-extracts the last assistant message as the summary - This ensures the actual turn summary is preserved after dehydration, not just the timing footer New /dump command: - Added /dump command to dump entire context window to tmp/ for debugging - Shows message index, role, kind, content length, and full content - Available in both console and machine modes UTF-8 safety: - Fixed truncate_to_word_boundary() to use character indices instead of byte indices, preventing panics on multi-byte UTF-8 characters - Added UTF-8 string slicing guidance to AGENTS.md Agent: g3
This commit is contained in:
13
AGENTS.md
13
AGENTS.md
@@ -71,6 +71,18 @@
|
||||
- Different configs for interactive vs autonomous mode
|
||||
- **Risk**: Aggressive retries can hit rate limits harder
|
||||
|
||||
### UTF-8 String Slicing (Throughout Codebase)
|
||||
|
||||
- Rust string slices (`&s[..n]`) use **byte indices**, not character indices
|
||||
- Multi-byte UTF-8 characters (emoji, bullets `•`, `×`, `⚡`) cause panics if sliced mid-character
|
||||
- **Risk**: Runtime panic on any string containing non-ASCII characters
|
||||
- **Fix**: Use `char_indices()` to find byte boundaries:
|
||||
```rust
|
||||
let byte_idx = s.char_indices().nth(char_limit).map(|(i, _)| i).unwrap_or(s.len());
|
||||
let truncated = &s[..byte_idx];
|
||||
```
|
||||
- **Danger zones**: Display truncation, ACD stubs, user input handling
|
||||
|
||||
## Do's and Don'ts for Automated Changes
|
||||
|
||||
### Do
|
||||
@@ -99,6 +111,7 @@
|
||||
3. **"Tool results are always small"** - File reads can return megabytes
|
||||
4. **"Sessions persist across runs"** - Sessions are ephemeral by default
|
||||
5. **"All platforms are equal"** - macOS has more features (Vision, Accessibility)
|
||||
6. **"String length equals character count"** - `s.len()` returns bytes; use `s.chars().count()` for characters
|
||||
|
||||
## Dependency Analysis Artifacts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user