agent-loop: root turn driven by the library kernel (phase 2)
ChatSessionHandler now runs the root turn on the agent-loop kernel instead of run_agent_turn; sub-agents follow on the same kernel via DelegateTool. The old loop stays for resume/recovery until phase 3. agent-loop: - DelegateTool + AgentCatalog/AgentProfile (full toolset override, per-child selector/assembler, frame-scoped get), StaticCatalog, FilteredToolSet; sync flow with sticky child_token; batch via the generic fan-out - manager: start_loop skips the registry (children are not double-driving; they ride the parent's token tree); LoopParams gains selector/token overrides - store: get_frame, get_call, set_call_extras; HistoryStore result text aligned to raw-stored semantics (projection formats) - events: ApprovalRequired.request_id, AgentSpawned/Finished parent info; AskUserTool with_name + suggested_answers alias + Question.frame skald-core (loop_adapters + handler): - SkaldAssembler (byte-parity port of MessageBuilder's projection: scratchpad/summary/window, DTL Kimi/Anthropic injection, media, user coalescing, reasoning echo) + AgentSystemContext (prompt layers, substitutions, MCP list, shared folders, user profile) - SkaldAgentCatalog (build_sub_agent_config port), SkaldHumanChannel, scratchpad/todos tools, execute_task sync/async alias, LegacyInterfaceTool, PendingLiveInput - ApprovalGate: PendingWrite diffs via LoopEvent::Host (memory/disk routed like the fs-tools); SkaldWritePreviewHook for executed-write diffs; EventTranslator LoopEvent→ServerEvent (display meta, preview, FileChanged, AgentStart/Done, root-only Done/Truncated/Cancelled) - handle_message: builds TurnParams and drives the kernel; resume of pending tools runs first (results belong to the previous turn); ChatEvent publication stays handler-side; /stop cancels the live loop - ToolRegistry.get_tool/all_tools; def builders made pub(crate) Full workspace suite green (179 skald-core, 34 agent-loop, adapters incl.); two pre-existing doc-test failures fixed along the way.
This commit is contained in:
@@ -69,6 +69,11 @@ impl HistoryStore for InMemoryStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_frame(&self, frame: FrameId) -> crate::Result<Option<FrameRecord>> {
|
||||
let i = self.inner.lock().unwrap();
|
||||
Ok(i.frames.get(&frame).cloned())
|
||||
}
|
||||
|
||||
async fn active_frames(&self, conv: &ConversationId) -> crate::Result<Vec<FrameRecord>> {
|
||||
let i = self.inner.lock().unwrap();
|
||||
Ok(i.frames.values().filter(|f| f.active && &f.conversation == conv).cloned().collect())
|
||||
@@ -185,6 +190,25 @@ impl HistoryStore for InMemoryStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_call(&self, id: ToolCallId) -> crate::Result<Option<StoredCall>> {
|
||||
let i = self.inner.lock().unwrap();
|
||||
Ok(i.calls.values().flatten().find(|c| c.id == id).cloned())
|
||||
}
|
||||
|
||||
async fn set_call_extras(&self, id: ToolCallId, extras: serde_json::Value) -> crate::Result<()> {
|
||||
let mut i = self.inner.lock().unwrap();
|
||||
update_call(&mut i, id, |c| {
|
||||
if let (Some(dst), Some(src)) = (c.extras.as_object_mut(), extras.as_object()) {
|
||||
for (k, v) in src {
|
||||
dst.insert(k.clone(), v.clone());
|
||||
}
|
||||
} else {
|
||||
c.extras = extras.clone();
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn calls_in_state(&self, frame: FrameId, states: &[CallState]) -> crate::Result<Vec<StoredCall>> {
|
||||
let i = self.inner.lock().unwrap();
|
||||
Ok(i.messages
|
||||
|
||||
Reference in New Issue
Block a user