Skip to content

Commit 57ef717

Browse files
0xrinegadeclaude
andcommitted
fix: prevent server-side plan execution in final response generation
Two critical fixes for final response generation: 1. Make query_osvm_ai_with_options() public - Was private, needed by streaming_agent - Allows passing custom system prompts and ownPlan flag 2. Add finalization system prompt with ownPlan: true - Creates explicit finalization prompt telling AI: * Format results clearly * Answer user's question directly * DO NOT generate new plans/code * DO NOT execute actions - Sets ownPlan: true to prevent server from using aiPlanExecution - Passes both to query_osvm_ai_with_options() Problem solved: ❌ Before: Final response used query_with_debug() with no options → Server tried to execute with aiPlanExecution → Wasted time trying to find tools like 'getSOLTransfers' ✅ After: Uses ownPlan: true + finalization prompt → Server just generates text, no execution → Fast text-only LLM call 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 1157e4f commit 57ef717

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/services/ai_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ impl AiService {
463463
.await
464464
}
465465

466-
async fn query_osvm_ai_with_options(
466+
pub async fn query_osvm_ai_with_options(
467467
&self,
468468
question: &str,
469469
system_prompt: Option<String>,

src/utils/streaming_agent.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,24 @@ pub async fn execute_streaming_agent(query: &str, verbose: u8) -> Result<()> {
869869

870870
if tool_results_for_ai.is_empty() && tool_plan.osvm_tools_to_use.is_empty() {
871871
// No tools - direct response
872-
match ai_service.query_with_debug(query, verbose > 1).await {
872+
let finalization_prompt = format!(
873+
"You are finalizing the answer to this user query: \"{}\"\n\n\
874+
The execution has completed. Your task is to:\n\
875+
1. Format the results in a clear, human-readable way\n\
876+
2. Directly answer the user's question based on the data\n\
877+
3. DO NOT generate any new plans or code\n\
878+
4. DO NOT suggest additional steps or actions\n\
879+
5. Just present the final answer clearly and concisely\n\n\
880+
Results to format:\n{:?}",
881+
query, tool_results_for_ai
882+
);
883+
884+
match ai_service.query_osvm_ai_with_options(
885+
query,
886+
Some(finalization_prompt),
887+
Some(true), // ownPlan: true - tells server not to execute, just generate text
888+
verbose > 1
889+
).await {
873890
Ok(resp) => {
874891
println!(" ✅");
875892
resp

0 commit comments

Comments
 (0)