huskies: merge 1127 story Migrate all LLM-invoking transports onto assemble_prompt_context; delete legacy Vec

This commit is contained in:
dave
2026-05-17 22:23:15 +00:00
parent c97b7c841f
commit fe00fe6a25
9 changed files with 94 additions and 286 deletions
+22 -2
View File
@@ -139,6 +139,14 @@ where
let received_at = Utc::now().format("%Y-%m-%dT%H:%M:%SZ").to_string();
inject_received_at(&mut messages, &received_at);
// Assemble CRDT pipeline-transition events once per turn and advance the
// high-water mark. Uses the Claude Code session_id when available so the
// same event stream key is used for resumable sessions; falls back to
// "web-ui" for Anthropic/Ollama turns which have no persistent session.
let event_ctx = crate::llm_session::assemble_prompt_context(
config.session_id.as_deref().unwrap_or("web-ui"),
);
let _ = state.cancel_tx.send(false);
let mut cancel_rx = state.cancel_rx.clone();
cancel_rx.borrow_and_update();
@@ -177,10 +185,14 @@ where
// would be lost because Claude Code only receives a single prompt
// string. In that case, prepend the conversation history so the LLM
// retains full context even though the session cannot be resumed.
// In both cases, prepend any pending CRDT pipeline-transition events.
let user_message = if config.session_id.is_some() {
latest_user_content
format!("{event_ctx}{latest_user_content}")
} else {
build_claude_code_context_prompt(&messages, &latest_user_content)
format!(
"{event_ctx}{}",
build_claude_code_context_prompt(&messages, &latest_user_content)
)
};
let project_root = state
@@ -233,6 +245,14 @@ where
&[]
};
// Prepend pipeline-transition events to the last user message so Anthropic
// and Ollama providers also receive the CRDT context on every turn.
if !event_ctx.is_empty()
&& let Some(msg) = messages.iter_mut().rev().find(|m| m.role == Role::User)
{
msg.content = format!("{event_ctx}{}", msg.content);
}
let mut current_history = messages.clone();
// Build the system prompt — append onboarding instructions when the