- Split zclaw-kernel/kernel.rs (1486 lines) into 9 domain modules - Split zclaw-kernel/generation.rs (1080 lines) into 3 modules - Add DeerFlow-inspired middleware: DanglingTool, SubagentLimit, ToolError, ToolOutputGuard - Add PromptBuilder for structured system prompt assembly - Add FactStore (zclaw-memory) for persistent fact extraction - Add task builtin tool for agent task management - Driver improvements: Anthropic/OpenAI extended thinking, Gemini safety settings - Replace let _ = with proper log::warn! across SaaS handlers - Remove unused dependency (url) from zclaw-hands
50 lines
1.8 KiB
Rust
50 lines
1.8 KiB
Rust
//! Title generation middleware — auto-generates conversation titles after the first turn.
|
|
//!
|
|
//! Inspired by DeerFlow's TitleMiddleware: after the first user-assistant exchange,
|
|
//! generates a short descriptive title using the LLM instead of defaulting to
|
|
//! "新对话" or truncating the user's first message.
|
|
//!
|
|
//! Priority 180 — runs after compaction (100) and memory (150), before skill index (200).
|
|
//!
|
|
//! NOTE: This is a structural placeholder. Full implementation requires an LLM driver
|
|
//! reference to generate titles asynchronously, which will be wired through the
|
|
//! middleware context in a future iteration. For now it simply passes through.
|
|
|
|
use async_trait::async_trait;
|
|
use crate::middleware::{AgentMiddleware, MiddlewareDecision};
|
|
|
|
/// Middleware that auto-generates conversation titles after the first exchange.
|
|
///
|
|
/// When fully implemented, this will:
|
|
/// 1. Detect the first user-assistant exchange (via message count)
|
|
/// 2. Call the LLM with a short prompt to generate a descriptive title
|
|
/// 3. Update the session title via the middleware context
|
|
///
|
|
/// For now, it serves as a registered placeholder in the middleware chain.
|
|
pub struct TitleMiddleware {
|
|
_reserved: (),
|
|
}
|
|
|
|
impl TitleMiddleware {
|
|
pub fn new() -> Self {
|
|
Self { _reserved: () }
|
|
}
|
|
}
|
|
|
|
impl Default for TitleMiddleware {
|
|
fn default() -> Self {
|
|
Self::new()
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl AgentMiddleware for TitleMiddleware {
|
|
fn name(&self) -> &str { "title" }
|
|
fn priority(&self) -> i32 { 180 }
|
|
|
|
// All hooks default to Continue — placeholder until LLM driver is wired in.
|
|
async fn before_completion(&self, _ctx: &mut crate::middleware::MiddlewareContext) -> zclaw_types::Result<MiddlewareDecision> {
|
|
Ok(MiddlewareDecision::Continue)
|
|
}
|
|
}
|