src/thought -> src/agent
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
39d6ca3fe0
commit
2f0c7ce5c2
21 changed files with 57 additions and 141 deletions
|
|
@ -32,7 +32,7 @@ use clap::Parser;
|
|||
use poc_memory::dbglog;
|
||||
|
||||
use poc_memory::user::*;
|
||||
use poc_memory::user::runner::{Agent, TurnResult};
|
||||
use poc_memory::agent::{tools, runner::{Agent, TurnResult}};
|
||||
use poc_memory::user::api::ApiClient;
|
||||
use poc_memory::user::tui::HotkeyAction;
|
||||
use poc_memory::config::{self, AppConfig, SessionConfig};
|
||||
|
|
@ -40,7 +40,7 @@ use poc_memory::user::ui_channel::{ContextInfo, StatusInfo, StreamTarget, UiMess
|
|||
|
||||
/// Compaction threshold — context is rebuilt when prompt tokens exceed this.
|
||||
fn compaction_threshold(app: &AppConfig) -> u32 {
|
||||
(poc_memory::thought::context::context_window() as u32) * app.compaction.hard_threshold_pct / 100
|
||||
(poc_memory::agent::context::context_window() as u32) * app.compaction.hard_threshold_pct / 100
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
|
@ -435,7 +435,7 @@ impl Session {
|
|||
let _ = self.ui_tx.send(UiMessage::Debug("[score] task spawning".into()));
|
||||
tokio::spawn(async move {
|
||||
let _ = ui_tx.send(UiMessage::Debug("[score] task started, calling score_memories".into()));
|
||||
let result = poc_memory::thought::training::score_memories(
|
||||
let result = poc_memory::agent::training::score_memories(
|
||||
&context, &client, &ui_tx,
|
||||
).await;
|
||||
let _ = ui_tx.send(UiMessage::Debug("[score] score_memories returned, acquiring lock".into()));
|
||||
|
|
@ -507,13 +507,6 @@ impl Session {
|
|||
self.update_status();
|
||||
Command::Handled
|
||||
}
|
||||
"/test" => {
|
||||
let _ = self
|
||||
.ui_tx
|
||||
.send(UiMessage::Info("Running tool smoke tests...".into()));
|
||||
run_tool_tests(&self.ui_tx, &self.process_tracker).await;
|
||||
Command::Handled
|
||||
}
|
||||
"/retry" => {
|
||||
if self.turn_in_progress {
|
||||
let _ = self
|
||||
|
|
@ -1093,79 +1086,6 @@ fn drain_ui_messages(rx: &mut ui_channel::UiReceiver, app: &mut tui::App) -> boo
|
|||
any
|
||||
}
|
||||
|
||||
async fn run_tool_tests(ui_tx: &ui_channel::UiSender, tracker: &tools::ProcessTracker) {
|
||||
use serde_json::json;
|
||||
|
||||
let tests: Vec<(&str, serde_json::Value, bool)> = vec![
|
||||
("read_file", json!({"file_path": "/etc/hostname"}), true),
|
||||
(
|
||||
"read_file",
|
||||
json!({"file_path": "/nonexistent/path"}),
|
||||
false,
|
||||
),
|
||||
(
|
||||
"write_file",
|
||||
json!({"file_path": "/tmp/poc-agent-test.txt", "content": "hello from poc-agent\n"}),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"read_file",
|
||||
json!({"file_path": "/tmp/poc-agent-test.txt"}),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"edit_file",
|
||||
json!({"file_path": "/tmp/poc-agent-test.txt", "old_string": "hello", "new_string": "goodbye"}),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"read_file",
|
||||
json!({"file_path": "/tmp/poc-agent-test.txt"}),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"bash",
|
||||
json!({"command": "echo 'tool test passed'"}),
|
||||
true,
|
||||
),
|
||||
("bash", json!({"command": "sleep 5", "timeout_secs": 1}), false),
|
||||
(
|
||||
"grep",
|
||||
json!({"pattern": "fn main", "path": "src/", "show_content": true}),
|
||||
true,
|
||||
),
|
||||
("glob", json!({"pattern": "src/**/*.rs"}), true),
|
||||
("yield_to_user", json!({"message": "test yield"}), true),
|
||||
];
|
||||
|
||||
let mut pass = 0;
|
||||
let mut fail = 0;
|
||||
|
||||
for (name, args, should_succeed) in &tests {
|
||||
let output = tools::dispatch(name, args, tracker).await;
|
||||
let is_error = output.text.starts_with("Error:");
|
||||
let ok = if *should_succeed { !is_error } else { is_error };
|
||||
|
||||
if ok {
|
||||
let _ = ui_tx.send(UiMessage::Info(format!(" PASS: {}", name)));
|
||||
pass += 1;
|
||||
} else {
|
||||
let _ = ui_tx.send(UiMessage::Info(format!(
|
||||
" FAIL: {} — {}",
|
||||
name,
|
||||
&output.text[..output.text.len().min(100)]
|
||||
)));
|
||||
fail += 1;
|
||||
}
|
||||
}
|
||||
|
||||
let _ = std::fs::remove_file("/tmp/poc-agent-test.txt");
|
||||
let _ = ui_tx.send(UiMessage::Info(format!(
|
||||
" {} passed, {} failed",
|
||||
pass, fail
|
||||
)));
|
||||
}
|
||||
|
||||
/// Replay a restored session into the TUI panes so the user can see
|
||||
/// conversation history immediately on restart. Shows user input,
|
||||
/// assistant responses, and brief tool call summaries. Skips the system
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue