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:
asepharyana
2026-07-12 04:01:10 +07:00
parent a974118b5a
commit 0cc60c12ce
6 changed files with 38 additions and 12 deletions
+2 -3
View File
@@ -9,9 +9,8 @@ use crate::app::state::runtime::TurnEvent;
use crate::app::state::types::{Origin, Overlay, Toast, ToastKind};
use crate::dto::chat::message::{ChatMessage, Role};
const MAX_TOOL_ONLY_TURNS: usize = 1000;
const MAX_AGENT_STEPS: usize = 1000;
const MAX_TOOL_ONLY_TURNS: usize = usize::MAX;
const MAX_AGENT_STEPS: usize = usize::MAX;
#[derive(Debug, Clone)]
pub enum Action {
+1 -1
View File
@@ -1,6 +1,6 @@
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 ENGAGE_HYSTERESIS: usize = 5;
+1 -1
View File
@@ -5,7 +5,7 @@ use crate::tool::{all_tools, tool_defs, tool_is_risky};
use super::context::SubagentContext;
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
/// OpenAI-style tool definitions. When `allowed_tools` is empty every tool is
+1 -1
View File
@@ -49,7 +49,7 @@ fn spawn_single_agent(prompt: &str, findings_snapshot: Vec<String>) -> anyhow::R
use crate::app::subagent::spawn::AgentDefinition;
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 findings_section = if findings_snapshot.is_empty() {
+4 -4
View File
@@ -17,7 +17,7 @@ pub fn builtin_agents() -> Vec<AgentDefinition> {
"glob".to_string(),
"git_operator".to_string(),
]
).with_max_steps(25),
).with_max_steps(usize::MAX),
AgentDefinition::new(
"reviewer".to_string(),
@@ -32,7 +32,7 @@ pub fn builtin_agents() -> Vec<AgentDefinition> {
"recall".to_string(),
"remember".to_string(),
]
).with_max_steps(10),
).with_max_steps(usize::MAX),
AgentDefinition::new(
"researcher".to_string(),
@@ -46,7 +46,7 @@ pub fn builtin_agents() -> Vec<AgentDefinition> {
"glob".to_string(),
"search".to_string(),
]
).with_max_steps(15),
).with_max_steps(usize::MAX),
AgentDefinition::new(
"planner".to_string(),
@@ -60,6 +60,6 @@ pub fn builtin_agents() -> Vec<AgentDefinition> {
"glob".to_string(),
"plan".to_string(),
]
).with_max_steps(20),
).with_max_steps(usize::MAX),
]
}
+29 -2
View File
@@ -5,6 +5,31 @@ use ratatui::widgets::{Block, Borders, Paragraph, Wrap};
use ratatui::Frame;
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 {
match role {
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))];
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(content_line);
for line in message_lines {
display_lines.push(line);
}
display_lines.push(Line::from(Span::raw("")));
}