(
&self,
input: PromptInput,
session: &mut Session,
provider: Arc<dyn Provider>,
system_prompt: Option<String>,
tools: Vec<ToolDefinition>,
agen
| 786 | } |
| 787 | |
| 788 | pub async fn prompt_with_update_hook( |
| 789 | &self, |
| 790 | input: PromptInput, |
| 791 | session: &mut Session, |
| 792 | provider: Arc<dyn Provider>, |
| 793 | system_prompt: Option<String>, |
| 794 | tools: Vec<ToolDefinition>, |
| 795 | agent_params: AgentParams, |
| 796 | update_hook: Option<SessionUpdateHook>, |
| 797 | ) -> anyhow::Result<()> { |
| 798 | self.assert_not_busy(&input.session_id).await?; |
| 799 | |
| 800 | let cancel_token = self.start(&input.session_id).await; |
| 801 | let token = match cancel_token { |
| 802 | Some(t) => t, |
| 803 | None => return Err(anyhow::anyhow!("Session already running")), |
| 804 | }; |
| 805 | |
| 806 | self.create_user_message(&input, session).await?; |
| 807 | session.touch(); |
| 808 | Self::emit_session_update(update_hook.as_ref(), session); |
| 809 | |
| 810 | if input.no_reply { |
| 811 | self.finish_run(&input.session_id).await; |
| 812 | return Ok(()); |
| 813 | } |
| 814 | |
| 815 | { |
| 816 | let mut session_state = self.session_state.write().await; |
| 817 | session_state.set_busy(&input.session_id); |
| 818 | } |
| 819 | |
| 820 | let session_id = input.session_id.clone(); |
| 821 | let model_id = input |
| 822 | .model |
| 823 | .as_ref() |
| 824 | .map(|m| m.model_id.clone()) |
| 825 | .unwrap_or_else(|| "default".to_string()); |
| 826 | let provider_id = input |
| 827 | .model |
| 828 | .as_ref() |
| 829 | .map(|m| m.provider_id.clone()) |
| 830 | .unwrap_or_else(|| "anthropic".to_string()); |
| 831 | |
| 832 | let result = Self::loop_inner( |
| 833 | session_id.clone(), |
| 834 | token, |
| 835 | provider, |
| 836 | model_id, |
| 837 | provider_id, |
| 838 | session, |
| 839 | input.agent.as_deref(), |
| 840 | system_prompt, |
| 841 | tools, |
| 842 | &agent_params, |
| 843 | update_hook, |
| 844 | ) |
| 845 | .await; |
no test coverage detected