Move conversation_log from AgentState to ContextState
The log records what goes into context, so it belongs under the context lock. push() now auto-logs conversation entries, eliminating all the manual lock-state-for-log, drop, lock-context-for-push dances. - ContextState: new conversation_log field, Clone impl drops it (forked contexts don't log) - push(): auto-logs Section::Conversation entries - push_node, apply_tool_results, collect_results: all simplified - collect_results: batch nodes under single context lock - Assistant response logged under context lock after parse completes Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
d82a2ae90d
commit
ddfdbe6cb1
4 changed files with 112 additions and 109 deletions
|
|
@ -383,10 +383,10 @@ impl Mind {
|
|||
{
|
||||
let mut ctx = self.agent.context.lock().await;
|
||||
ctx.clear(Section::Conversation);
|
||||
ctx.conversation_log = new_log;
|
||||
}
|
||||
{
|
||||
let mut st = self.agent.state.lock().await;
|
||||
st.conversation_log = new_log;
|
||||
st.generation += 1;
|
||||
st.last_prompt_tokens = 0;
|
||||
}
|
||||
|
|
@ -488,9 +488,9 @@ impl Mind {
|
|||
let mut sub_handle: Option<tokio::task::JoinHandle<()>> = None;
|
||||
let mut unc_handle: Option<tokio::task::JoinHandle<()>> = None;
|
||||
loop {
|
||||
let (timeout, turn_active, has_input) = {
|
||||
let (timeout, has_input) = {
|
||||
let me = self.shared.lock().unwrap();
|
||||
(me.dmn.interval(), me.turn_active, me.has_pending_input())
|
||||
(me.dmn.interval(), me.has_pending_input())
|
||||
};
|
||||
|
||||
let mut cmds = Vec::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue