feat: update maximum steps and token limits to usize::MAX; add split_spans_into_lines function for improved chat display
This commit is contained in:
@@ -9,9 +9,8 @@ use crate::app::state::runtime::TurnEvent;
|
|||||||
use crate::app::state::types::{Origin, Overlay, Toast, ToastKind};
|
use crate::app::state::types::{Origin, Overlay, Toast, ToastKind};
|
||||||
use crate::dto::chat::message::{ChatMessage, Role};
|
use crate::dto::chat::message::{ChatMessage, Role};
|
||||||
|
|
||||||
const MAX_TOOL_ONLY_TURNS: usize = 1000;
|
const MAX_TOOL_ONLY_TURNS: usize = usize::MAX;
|
||||||
|
const MAX_AGENT_STEPS: usize = usize::MAX;
|
||||||
const MAX_AGENT_STEPS: usize = 1000;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::dto::chat::message::ChatMessage;
|
use crate::dto::chat::message::ChatMessage;
|
||||||
|
|
||||||
const MAX_WIRE_TOKENS: usize = 8000;
|
const MAX_WIRE_TOKENS: usize = 2_000_000;
|
||||||
const MIN_MESSAGES_BEFORE_SHAPE: usize = 20;
|
const MIN_MESSAGES_BEFORE_SHAPE: usize = 20;
|
||||||
const ENGAGE_HYSTERESIS: usize = 5;
|
const ENGAGE_HYSTERESIS: usize = 5;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::tool::{all_tools, tool_defs, tool_is_risky};
|
|||||||
use super::context::SubagentContext;
|
use super::context::SubagentContext;
|
||||||
use super::event::SubagentEvent;
|
use super::event::SubagentEvent;
|
||||||
|
|
||||||
pub const MAX_AGENT_STEPS: usize = 25;
|
pub const MAX_AGENT_STEPS: usize = usize::MAX;
|
||||||
|
|
||||||
/// Maps a subagent's allowed tool names to concrete Tool trait objects and
|
/// Maps a subagent's allowed tool names to concrete Tool trait objects and
|
||||||
/// OpenAI-style tool definitions. When `allowed_tools` is empty every tool is
|
/// OpenAI-style tool definitions. When `allowed_tools` is empty every tool is
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ fn spawn_single_agent(prompt: &str, findings_snapshot: Vec<String>) -> anyhow::R
|
|||||||
use crate::app::subagent::spawn::AgentDefinition;
|
use crate::app::subagent::spawn::AgentDefinition;
|
||||||
|
|
||||||
let def = AgentDefinition::new("workflow-agent".to_string(), "coder".to_string())
|
let def = AgentDefinition::new("workflow-agent".to_string(), "coder".to_string())
|
||||||
.with_max_steps(20);
|
.with_max_steps(usize::MAX);
|
||||||
let mut ctx = build_subagent_context(def);
|
let mut ctx = build_subagent_context(def);
|
||||||
|
|
||||||
let findings_section = if findings_snapshot.is_empty() {
|
let findings_section = if findings_snapshot.is_empty() {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ pub fn builtin_agents() -> Vec<AgentDefinition> {
|
|||||||
"glob".to_string(),
|
"glob".to_string(),
|
||||||
"git_operator".to_string(),
|
"git_operator".to_string(),
|
||||||
]
|
]
|
||||||
).with_max_steps(25),
|
).with_max_steps(usize::MAX),
|
||||||
|
|
||||||
AgentDefinition::new(
|
AgentDefinition::new(
|
||||||
"reviewer".to_string(),
|
"reviewer".to_string(),
|
||||||
@@ -32,7 +32,7 @@ pub fn builtin_agents() -> Vec<AgentDefinition> {
|
|||||||
"recall".to_string(),
|
"recall".to_string(),
|
||||||
"remember".to_string(),
|
"remember".to_string(),
|
||||||
]
|
]
|
||||||
).with_max_steps(10),
|
).with_max_steps(usize::MAX),
|
||||||
|
|
||||||
AgentDefinition::new(
|
AgentDefinition::new(
|
||||||
"researcher".to_string(),
|
"researcher".to_string(),
|
||||||
@@ -46,7 +46,7 @@ pub fn builtin_agents() -> Vec<AgentDefinition> {
|
|||||||
"glob".to_string(),
|
"glob".to_string(),
|
||||||
"search".to_string(),
|
"search".to_string(),
|
||||||
]
|
]
|
||||||
).with_max_steps(15),
|
).with_max_steps(usize::MAX),
|
||||||
|
|
||||||
AgentDefinition::new(
|
AgentDefinition::new(
|
||||||
"planner".to_string(),
|
"planner".to_string(),
|
||||||
@@ -60,6 +60,6 @@ pub fn builtin_agents() -> Vec<AgentDefinition> {
|
|||||||
"glob".to_string(),
|
"glob".to_string(),
|
||||||
"plan".to_string(),
|
"plan".to_string(),
|
||||||
]
|
]
|
||||||
).with_max_steps(20),
|
).with_max_steps(usize::MAX),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-2
@@ -5,6 +5,31 @@ use ratatui::widgets::{Block, Borders, Paragraph, Wrap};
|
|||||||
use ratatui::Frame;
|
use ratatui::Frame;
|
||||||
use super::theme::Theme;
|
use super::theme::Theme;
|
||||||
|
|
||||||
|
fn split_spans_into_lines<'a>(spans: Vec<Span<'a>>) -> Vec<Line<'a>> {
|
||||||
|
let mut lines = Vec::new();
|
||||||
|
let mut current_spans = Vec::new();
|
||||||
|
|
||||||
|
for span in spans {
|
||||||
|
let text = span.content.as_ref();
|
||||||
|
let mut parts = text.split('\n').peekable();
|
||||||
|
while let Some(part) = parts.next() {
|
||||||
|
if !part.is_empty() {
|
||||||
|
current_spans.push(Span::styled(part.to_string(), span.style));
|
||||||
|
}
|
||||||
|
if parts.peek().is_some() {
|
||||||
|
lines.push(Line::from(std::mem::take(&mut current_spans)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !current_spans.is_empty() {
|
||||||
|
lines.push(Line::from(current_spans));
|
||||||
|
}
|
||||||
|
if lines.is_empty() {
|
||||||
|
lines.push(Line::from(vec![]));
|
||||||
|
}
|
||||||
|
lines
|
||||||
|
}
|
||||||
|
|
||||||
fn _role_name(role: &crate::dto::chat::message::Role) -> &'static str {
|
fn _role_name(role: &crate::dto::chat::message::Role) -> &'static str {
|
||||||
match role {
|
match role {
|
||||||
crate::dto::chat::message::Role::User => "User",
|
crate::dto::chat::message::Role::User => "User",
|
||||||
@@ -81,10 +106,12 @@ pub fn draw_chat(frame: &mut Frame, area: Rect, state: &crate::app::state::rest:
|
|||||||
};
|
};
|
||||||
let mut content_spans = vec![Span::styled(format!("{} ", prefix), Style::default().fg(role_color))];
|
let mut content_spans = vec![Span::styled(format!("{} ", prefix), Style::default().fg(role_color))];
|
||||||
content_spans.extend(super::markdown::render_markdown(&content_str, area.width));
|
content_spans.extend(super::markdown::render_markdown(&content_str, area.width));
|
||||||
let content_line = Line::from(content_spans);
|
let message_lines = split_spans_into_lines(content_spans);
|
||||||
|
|
||||||
display_lines.push(header);
|
display_lines.push(header);
|
||||||
display_lines.push(content_line);
|
for line in message_lines {
|
||||||
|
display_lines.push(line);
|
||||||
|
}
|
||||||
display_lines.push(Line::from(Span::raw("")));
|
display_lines.push(Line::from(Span::raw("")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user