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:
Dhanji R. Prasanna
2026-01-12 05:13:02 +05:30
parent ac17b95b24
commit f415dbb84b
14 changed files with 1771 additions and 27 deletions

View File

@@ -7,7 +7,7 @@ use anyhow::Result;
use tracing::{debug, warn};
use crate::tools::executor::ToolContext;
use crate::tools::{file_ops, memory, misc, research, shell, todo, webdriver};
use crate::tools::{acd, file_ops, memory, misc, research, shell, todo, webdriver};
use crate::ui_writer::UiWriter;
use crate::ToolCall;
@@ -47,6 +47,9 @@ pub async fn dispatch_tool<W: UiWriter>(
// Project memory tools
"remember" => memory::execute_remember(tool_call, ctx).await,
// ACD (Aggressive Context Dehydration) tools
"rehydrate" => acd::execute_rehydrate(tool_call, ctx).await,
// WebDriver tools
"webdriver_start" => webdriver::execute_webdriver_start(tool_call, ctx).await,
"webdriver_navigate" => webdriver::execute_webdriver_navigate(tool_call, ctx).await,