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

Method update_state

crates/chat-cli/src/cli/chat/conversation.rs:539–566  ·  view source on GitHub ↗
(&mut self, force_update: bool)

Source from the content-addressed store, hash-verified

537 }
538
539 pub async fn update_state(&mut self, force_update: bool) {
540 let needs_update = self.tool_manager.has_new_stuff.load(Ordering::Acquire) || force_update;
541 if !needs_update {
542 return;
543 }
544 self.tool_manager.update().await;
545 // TODO: make this more targeted so we don't have to clone the entire list of tools
546 self.tools = self
547 .tool_manager
548 .schema
549 .values()
550 .fold(HashMap::<ToolOrigin, Vec<Tool>>::new(), |mut acc, v| {
551 let tool = Tool::ToolSpecification(ToolSpecification {
552 name: v.name.clone(),
553 description: v.description.clone(),
554 input_schema: v.input_schema.clone().into(),
555 });
556 acc.entry(v.tool_origin.clone())
557 .and_modify(|tools| tools.push(tool.clone()))
558 .or_insert(vec![tool]);
559 acc
560 });
561 self.tool_manager.has_new_stuff.store(false, Ordering::Release);
562 // We call this in [Self::enforce_conversation_invariants] as well. But we need to call it
563 // here as well because when it's being called in [Self::enforce_conversation_invariants]
564 // it is only checking the last entry.
565 self.enforce_tool_use_history_invariants();
566 }
567
568 /// Returns a conversation state representation which reflects the exact conversation to send
569 /// back to the model.

Callers 4

newMethod · 0.80
nextMethod · 0.80
swap_agentMethod · 0.80

Calls 6

ToolSpecificationClass · 0.50
loadMethod · 0.45
updateMethod · 0.45
valuesMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected