MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / new

Method new

crates/chat-cli/src/cli/chat/conversation.rs:170–216  ·  view source on GitHub ↗
(
        conversation_id: &str,
        agents: Agents,
        tool_config: HashMap<String, ToolSpec>,
        tool_manager: ToolManager,
        current_model_id: Option<String>,
        os: &Os,
 

Source from the content-addressed store, hash-verified

168
169impl ConversationState {
170 pub async fn new(
171 conversation_id: &str,
172 agents: Agents,
173 tool_config: HashMap<String, ToolSpec>,
174 tool_manager: ToolManager,
175 current_model_id: Option<String>,
176 os: &Os,
177 mcp_enabled: bool,
178 ) -> Self {
179 let model = if let Some(model_id) = current_model_id {
180 match get_model_info(&model_id, os).await {
181 Ok(info) => Some(info),
182 Err(e) => {
183 tracing::warn!("Failed to get model info for {}: {}, using default", model_id, e);
184 Some(ModelInfo::from_id(model_id))
185 },
186 }
187 } else {
188 None
189 };
190
191 let context_manager = if let Some(agent) = agents.get_active() {
192 ContextManager::from_agent(agent, calc_max_context_files_size(model.as_ref())).ok()
193 } else {
194 None
195 };
196
197 Self {
198 conversation_id: conversation_id.to_string(),
199 next_message: None,
200 history: VecDeque::new(),
201 valid_history_range: Default::default(),
202 transcript: VecDeque::new(),
203 tools: format_tool_spec(tool_config),
204 context_manager,
205 tool_manager,
206 context_message_length: None,
207 latest_summary: None,
208 agents,
209 model: None,
210 model_info: model,
211 file_line_tracker: HashMap::new(),
212 checkpoint_manager: None,
213 mcp_enabled,
214 tangent_state: None,
215 }
216 }
217
218 pub fn latest_summary(&self) -> Option<&str> {
219 self.latest_summary.as_ref().map(|(s, _)| s.as_str())

Callers

nothing calls this directly

Calls 6

get_model_infoFunction · 0.85
format_tool_specFunction · 0.85
get_activeMethod · 0.80
to_stringMethod · 0.80
as_refMethod · 0.45

Tested by

no test coverage detected