thalamus: interactive sampling parameter controls

F5 screen now shows temperature, top_p, top_k with interactive
adjustment:
- Up/down: select parameter
- Left/right: adjust value (0.05 steps for temp/top_p, 5 for top_k)
- Updates Agent and display immediately via HotkeyAction

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-04 14:06:42 -04:00 committed by Kent Overstreet
parent dd009742ef
commit c2c5530ecc
3 changed files with 61 additions and 7 deletions

View file

@ -928,6 +928,16 @@ pub async fn run(cli: crate::user::CliArgs) -> Result<()> {
HotkeyAction::KillProcess => session.kill_processes().await,
HotkeyAction::Interrupt => session.interrupt().await,
HotkeyAction::CycleAutonomy => session.cycle_autonomy(),
HotkeyAction::AdjustSampling(param, delta) => {
if let Ok(mut agent) = session.agent.try_lock() {
match param {
0 => { agent.temperature = (agent.temperature + delta).clamp(0.0, 2.0); app.temperature = agent.temperature; }
1 => { agent.top_p = (agent.top_p + delta).clamp(0.0, 1.0); app.top_p = agent.top_p; }
2 => { agent.top_k = (agent.top_k as f32 + delta).max(0.0) as u32; app.top_k = agent.top_k; }
_ => {}
}
}
}
}
}

View file

@ -242,6 +242,9 @@ pub enum Screen {
#[derive(Debug)]
pub enum HotkeyAction {
CycleReasoning, KillProcess, Interrupt, CycleAutonomy,
/// Adjust a sampling parameter: (param_index, delta)
/// 0=temperature, 1=top_p, 2=top_k
AdjustSampling(usize, f32),
}
#[derive(Clone)]
@ -296,6 +299,8 @@ pub struct App {
pub(crate) agent_state: Vec<crate::subconscious::subconscious::AgentSnapshot>,
pub(crate) channel_status: Vec<ChannelStatus>,
pub(crate) idle_info: Option<IdleInfo>,
/// Thalamus screen: selected sampling param (0=temp, 1=top_p, 2=top_k).
pub(crate) sampling_selected: usize,
}
impl App {
@ -326,7 +331,7 @@ impl App {
debug_expanded: std::collections::HashSet::new(),
context_info: None, shared_context,
agent_selected: 0, agent_log_view: false, agent_state: Vec::new(),
channel_status: Vec::new(), idle_info: None,
channel_status: Vec::new(), idle_info: None, sampling_selected: 0,
}
}
@ -477,7 +482,7 @@ impl App {
_ => {}
}
}
Screen::Unconscious | Screen::Thalamus => {
Screen::Unconscious => {
match key.code {
KeyCode::PageUp => { self.debug_scroll = self.debug_scroll.saturating_sub(10); return; }
KeyCode::PageDown => { self.debug_scroll += 10; return; }
@ -485,6 +490,34 @@ impl App {
_ => {}
}
}
Screen::Thalamus => {
match key.code {
KeyCode::Up => { self.sampling_selected = self.sampling_selected.saturating_sub(1); return; }
KeyCode::Down => { self.sampling_selected = (self.sampling_selected + 1).min(2); return; }
KeyCode::Right => {
let delta = match self.sampling_selected {
0 => 0.05, // temperature
1 => 0.05, // top_p
2 => 5.0, // top_k
_ => 0.0,
};
self.hotkey_actions.push(HotkeyAction::AdjustSampling(self.sampling_selected, delta));
return;
}
KeyCode::Left => {
let delta = match self.sampling_selected {
0 => -0.05,
1 => -0.05,
2 => -5.0,
_ => 0.0,
};
self.hotkey_actions.push(HotkeyAction::AdjustSampling(self.sampling_selected, delta));
return;
}
KeyCode::Esc => { self.screen = Screen::Interact; return; }
_ => {}
}
}
Screen::Interact => {}
}

View file

@ -48,12 +48,23 @@ impl App {
}
lines.push(Line::raw(""));
// Sampling parameters
lines.push(Line::styled("── Sampling ──", section));
// Sampling parameters (↑/↓ select, ←/→ adjust)
lines.push(Line::styled("── Sampling (←/→ adjust) ──", section));
lines.push(Line::raw(""));
lines.push(Line::raw(format!(" temperature: {:.2}", self.temperature)));
lines.push(Line::raw(format!(" top_p: {:.2}", self.top_p)));
lines.push(Line::raw(format!(" top_k: {}", self.top_k)));
let params = [
format!("temperature: {:.2}", self.temperature),
format!("top_p: {:.2}", self.top_p),
format!("top_k: {}", self.top_k),
];
for (i, label) in params.iter().enumerate() {
let prefix = if i == self.sampling_selected { "" } else { " " };
let style = if i == self.sampling_selected {
Style::default().fg(Color::Cyan)
} else {
Style::default()
};
lines.push(Line::styled(format!("{}{}", prefix, label), style));
}
lines.push(Line::raw(""));
// Channel status from cached data