TurnResult: remove text field, simplify oneshot loop
- Remove TurnResult.text (was dead code - Agent::turn handles text internally) - Simplify run_with_backend to just iterate over steps (Agent::turn loops for tool calls and handles empty responses internally) - Change run/run_shared/run_forked_shared to return Result<(), String> - Remove AgentResult.output field (no callers used it) - Stub out legacy text-parsing code (audit, compare) that needs redesign - Update digest.rs to not depend on text return - Add level parameter to journal_new/journal_update for digest support Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
ef80398466
commit
f00532bdb7
11 changed files with 82 additions and 422 deletions
|
|
@ -23,7 +23,7 @@ use std::sync::Arc;
|
|||
use anyhow::Result;
|
||||
|
||||
use api::ApiClient;
|
||||
use context::{AstNode, NodeBody, ContextState, Section, Ast, PendingToolCall, ResponseParser, Role};
|
||||
use context::{AstNode, ContextState, Section, Ast, PendingToolCall, ResponseParser, Role};
|
||||
|
||||
use crate::mind::log::ConversationLog;
|
||||
|
||||
|
|
@ -105,9 +105,6 @@ pub async fn start_activity(agent: &Arc<Agent>, label: impl Into<String>) -> Act
|
|||
|
||||
/// Result of a single agent turn.
|
||||
pub struct TurnResult {
|
||||
/// The text response (already sent through UI channel).
|
||||
#[allow(dead_code)]
|
||||
pub text: String,
|
||||
/// Whether the model called yield_to_user during this turn.
|
||||
pub yield_requested: bool,
|
||||
/// Whether any tools (other than yield_to_user) were called.
|
||||
|
|
@ -445,24 +442,12 @@ impl Agent {
|
|||
}
|
||||
|
||||
// Text-only response — extract text and return
|
||||
let text = {
|
||||
let ctx = agent.context.lock().await;
|
||||
let children = ctx.conversation()[branch_idx].children();
|
||||
children.iter()
|
||||
.filter_map(|c| c.leaf())
|
||||
.filter(|l| matches!(l.body(), NodeBody::Content(_)))
|
||||
.map(|l| l.body().text())
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
};
|
||||
|
||||
let mut st = agent.state.lock().await;
|
||||
if st.pending_yield { ds.yield_requested = true; st.pending_yield = false; }
|
||||
if st.pending_model_switch.is_some() { ds.model_switch = st.pending_model_switch.take(); }
|
||||
if st.pending_dmn_pause { ds.dmn_pause = true; st.pending_dmn_pause = false; }
|
||||
|
||||
return Ok(TurnResult {
|
||||
text,
|
||||
yield_requested: ds.yield_requested,
|
||||
had_tool_calls: ds.had_tool_calls,
|
||||
tool_errors: ds.tool_errors,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue