add request_debug command
This commit is contained in:
@@ -166,6 +166,11 @@ impl ClaudeAgent {
|
||||
let _ = self.input_tx.try_send(Input::Compact);
|
||||
}
|
||||
|
||||
/// Request the worker to log its message buffer for debugging.
|
||||
pub fn request_debug(&self) {
|
||||
let _ = self.input_tx.try_send(Input::Debug);
|
||||
}
|
||||
|
||||
/// Request the worker to interrupt any prompts it is responding to, discard any queued messages,
|
||||
/// and get ready to accept different prompts.
|
||||
///
|
||||
|
||||
@@ -44,6 +44,7 @@ impl SentBy {
|
||||
pub enum Input {
|
||||
Chat(ChatMessage),
|
||||
Compact,
|
||||
Debug,
|
||||
}
|
||||
|
||||
/// A chat message
|
||||
@@ -141,6 +142,9 @@ impl ClaudeWorker {
|
||||
Input::Compact => {
|
||||
self.handle_compact().await;
|
||||
}
|
||||
Input::Debug => {
|
||||
self.handle_debug();
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = self.stop_rx.recv() => {
|
||||
@@ -165,7 +169,7 @@ impl ClaudeWorker {
|
||||
let _ = sender.send(Err(ClaudeError::StopRequested));
|
||||
}
|
||||
}
|
||||
Input::Compact => {}
|
||||
Input::Compact | Input::Debug => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,6 +189,11 @@ impl ClaudeWorker {
|
||||
self.messages.clear();
|
||||
}
|
||||
|
||||
/// Log the message buffer for debugging.
|
||||
fn handle_debug(&self) {
|
||||
info!("Claude message buffer:\n{:#?}", self.messages);
|
||||
}
|
||||
|
||||
/// Handle a single request to the Claude API.
|
||||
async fn handle_request(&mut self) -> Result<AdminMessageResponse, ClaudeError> {
|
||||
let max_iterations = self.config.claude_max_iterations;
|
||||
|
||||
@@ -161,6 +161,9 @@ enum GatewayCommand {
|
||||
/// Compact Claude's message history
|
||||
#[conf(name = "claude-compact", alias = "CLAUDE-COMPACT")]
|
||||
ClaudeCompact,
|
||||
/// Log Claude's message buffer for debugging
|
||||
#[conf(name = "claude-debug", alias = "CLAUDE-DEBUG")]
|
||||
ClaudeDebug,
|
||||
}
|
||||
|
||||
/// Parse a gateway command from a string (with or without leading /)
|
||||
@@ -793,6 +796,15 @@ impl Gateway {
|
||||
claude.request_compaction();
|
||||
Ok(AdminMessageResponse::new("compaction requested"))
|
||||
}
|
||||
GatewayCommand::ClaudeDebug => {
|
||||
let claude = self
|
||||
.claude
|
||||
.get()
|
||||
.ok_or_else(|| (501u16, "claude was not configured".into()))?;
|
||||
|
||||
claude.request_debug();
|
||||
Ok(AdminMessageResponse::new("debug logged"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user