MCPcopy Create free account
hub / github.com/AI45Lab/Code / resolve_prompt_context

Method resolve_prompt_context

core/src/agent/turn_context.rs:59–148  ·  view source on GitHub ↗
(
        &self,
        effective_prompt: &str,
        session_id: Option<&str>,
        event_tx: &Option<mpsc::Sender<AgentEvent>>,
    )

Source from the content-addressed store, hash-verified

57 }
58
59 async fn resolve_prompt_context(
60 &self,
61 effective_prompt: &str,
62 session_id: Option<&str>,
63 event_tx: &Option<mpsc::Sender<AgentEvent>>,
64 ) -> Vec<ContextResult> {
65 if self.config.context_providers.is_empty() {
66 return Vec::new();
67 }
68
69 if let Some(tx) = event_tx {
70 tx.send(AgentEvent::ContextResolving {
71 providers: self
72 .config
73 .context_providers
74 .iter()
75 .map(|p| p.name().to_string())
76 .collect(),
77 })
78 .await
79 .ok();
80 }
81
82 let workspace = self.tool_context.workspace.display().to_string();
83 let session_id_str = session_id.unwrap_or("");
84 let harness_intent = self
85 .fire_intent_detection(effective_prompt, session_id_str, &workspace)
86 .await;
87
88 let perception_event = if let Some(detected) = harness_intent {
89 tracing::info!(
90 intent = %detected.detected_intent,
91 confidence = %detected.confidence,
92 "Intent detected from AHP harness"
93 );
94 Some(
95 context_perception::build_pre_context_perception_from_intent(
96 detected,
97 effective_prompt,
98 session_id_str,
99 &workspace,
100 ),
101 )
102 } else {
103 tracing::debug!("No intent from harness, using local keyword detection");
104 self.detect_context_perception_intent(effective_prompt, session_id_str, &workspace)
105 };
106
107 let Some(perception_event) = perception_event else {
108 return self.resolve_context(effective_prompt, session_id).await;
109 };
110
111 tracing::info!(
112 intent = %perception_event.intent,
113 target_type = %perception_event.target_type,
114 "Context perception intent detected, firing AHP hook"
115 );
116

Callers 1

prepare_turn_contextMethod · 0.80

Calls 9

fire_intent_detectionMethod · 0.80
resolve_contextMethod · 0.80
is_emptyMethod · 0.45
sendMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected