MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / execute

Method execute

crates/opencode-session/src/prompt.rs:2741–2782  ·  view source on GitHub ↗
(
        &self,
        provider: Arc<dyn Provider>,
        tool_registry: &opencode_tool::ToolRegistry,
        ctx: &opencode_tool::ToolContext,
    )

Source from the content-addressed store, hash-verified

2739 }
2740
2741 pub async fn execute(
2742 &self,
2743 provider: Arc<dyn Provider>,
2744 tool_registry: &opencode_tool::ToolRegistry,
2745 ctx: &opencode_tool::ToolContext,
2746 ) -> anyhow::Result<String> {
2747 let model = self.model.as_ref().cloned().unwrap_or(ModelRef {
2748 provider_id: "default".to_string(),
2749 model_id: "default".to_string(),
2750 });
2751 let model_ref = format!("{}:{}", model.provider_id, model.model_id);
2752 let title = self
2753 .description
2754 .clone()
2755 .unwrap_or_else(|| "Subtask".to_string());
2756
2757 let subsession_id = ctx
2758 .do_create_subsession(
2759 self.agent_name.clone(),
2760 Some(title.clone()),
2761 Some(model_ref),
2762 vec!["todowrite".to_string(), "todoread".to_string()],
2763 )
2764 .await
2765 .unwrap_or_else(|_| format!("task_{}_{}", self.agent_name, uuid::Uuid::new_v4()));
2766
2767 if let Ok(output) = ctx
2768 .do_prompt_subsession(subsession_id.clone(), self.prompt.clone())
2769 .await
2770 {
2771 return Ok(format!(
2772 "task_id: {} (for resuming to continue this task if needed)\n\n<task_result>\n{}\n</task_result>",
2773 subsession_id, output
2774 ));
2775 }
2776
2777 let output = self.execute_inline(provider, tool_registry, &[]).await?;
2778 Ok(format!(
2779 "task_id: {} (for resuming to continue this task if needed)\n\n<task_result>\n{}\n</task_result>",
2780 subsession_id, output
2781 ))
2782 }
2783
2784 pub async fn execute_inline(
2785 &self,

Callers 8

createMethod · 0.45
updateMethod · 0.45
deleteMethod · 0.45
upsertMethod · 0.45
delete_for_sessionMethod · 0.45
delete_for_messageMethod · 0.45
run_migrationsMethod · 0.45
execute_tool_callsMethod · 0.45

Calls 4

do_create_subsessionMethod · 0.80
do_prompt_subsessionMethod · 0.80
execute_inlineMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected