huskies: merge 1186 story compact chat command: distill session context deterministically, then reset with a seed

This commit is contained in:
Huskies Agent
2026-07-17 12:05:04 +00:00
parent b241661941
commit 043c77f077
29 changed files with 1051 additions and 6 deletions
@@ -6,6 +6,7 @@ mod stream;
mod tests;
use super::parse::{parse_assistant_message, parse_tool_results};
use crate::agents::TokenUsage;
use crate::llm::types::Message;
use crate::slog;
use std::sync::atomic::{AtomicBool, Ordering};
@@ -16,6 +17,7 @@ use stream::handle_stream_event;
/// Routes the event to the appropriate handler based on `type`, emitting tokens,
/// thinking output, activity signals, and parsed messages to their respective channels.
/// Returns `true` only for `"result"` events, which signal that the CLI turn is complete.
#[allow(clippy::too_many_arguments)]
pub(super) fn process_json_event(
json: &serde_json::Value,
token_tx: &tokio::sync::mpsc::UnboundedSender<String>,
@@ -23,6 +25,7 @@ pub(super) fn process_json_event(
activity_tx: &tokio::sync::mpsc::UnboundedSender<String>,
msg_tx: &std::sync::mpsc::Sender<Message>,
sid_tx: &mut Option<tokio::sync::oneshot::Sender<String>>,
usage_tx: &mut Option<tokio::sync::oneshot::Sender<TokenUsage>>,
auth_failed: &AtomicBool,
) -> bool {
let event_type = match json.get("type").and_then(|t| t.as_str()) {
@@ -80,7 +83,14 @@ pub(super) fn process_json_event(
}
false
}
"result" => true,
"result" => {
if let Some(tx) = usage_tx.take()
&& let Some(usage) = TokenUsage::from_result_event(json)
{
let _ = tx.send(usage);
}
true
}
// system, rate_limit_event, and unknown types are no-ops
_ => false,
}