You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by wy...@apache.org on 2026/09/22 19:38:15 UTC

(maka) branch feat/runtime-host-rust updated: fix(graph): expose unambiguous executable catalog targets

This is an automated email from the ASF dual-hosted git repository.

M4n5ter pushed a commit to branch feat/runtime-host-rust
in repository https://gitbox.apache.org/repos/asf/maka.git


The following commit(s) were added to refs/heads/feat/runtime-host-rust by this push:
     new ae1192d099 fix(graph): expose unambiguous executable catalog targets
ae1192d099 is described below

commit ae1192d0996a5b81f8a0cd27e0b2aa0614e07205
Author: Wang <m4...@gmail.com>
AuthorDate: Wed Sep 23 03:38:09 2026 +0800

    fix(graph): expose unambiguous executable catalog targets
    
    Generated-by: Codex
---
 crates/graph/src/client/model.ts                   |  5 +-
 crates/graph/src/client/work.tsx                   |  4 +-
 crates/graph/src/plugin/definitions.rs             | 92 +++++++++++-----------
 crates/graph/src/plugin/read/detail.rs             |  1 -
 crates/graph/src/plugin/session.rs                 |  4 +-
 crates/graph/src/plugin/tools.rs                   |  2 +-
 crates/graph/src/schedule.rs                       | 29 ++-----
 crates/graph/tests/repository.rs                   |  1 -
 .../runtime-host/tests/integration/graph_plugin.rs | 25 +++++-
 docs/rust-runtime.md                               |  3 +
 docs/rust-runtime.zh-CN.md                         |  2 +
 11 files changed, 88 insertions(+), 80 deletions(-)

diff --git a/crates/graph/src/client/model.ts b/crates/graph/src/client/model.ts
index 8ff347e8c9..1cf210cd0e 100644
--- a/crates/graph/src/client/model.ts
+++ b/crates/graph/src/client/model.ts
@@ -83,8 +83,9 @@ export type Work = {
   } | null;
 };
 export type Target =
-  | { kind: 'agent'; agentId: string; executorId?: string }
-  | { kind: 'preset'; presetId: string; executorId?: string }
+  | { kind: 'agent'; agentId: string }
+  | { kind: 'preset'; presetId: string }
+  | { kind: 'executor'; executorId: string }
   | { kind: 'operator'; operatorId: string };
 export type Detail = {
   workId: string;
diff --git a/crates/graph/src/client/work.tsx b/crates/graph/src/client/work.tsx
index 24762400fd..4bd81288da 100644
--- a/crates/graph/src/client/work.tsx
+++ b/crates/graph/src/client/work.tsx
@@ -106,7 +106,9 @@ export function WorkDetails(props: {
                 ? detail.target.agentId
                 : detail.target.kind === 'preset'
                   ? detail.target.presetId
-                  : detail.target.operatorId}
+                  : detail.target.kind === 'executor'
+                    ? detail.target.executorId
+                    : detail.target.operatorId}
             </p>
             <p>{detail.instruction}</p>
             {detail.nextOffset !== null ? (
diff --git a/crates/graph/src/plugin/definitions.rs b/crates/graph/src/plugin/definitions.rs
index 6627406802..593bb28302 100644
--- a/crates/graph/src/plugin/definitions.rs
+++ b/crates/graph/src/plugin/definitions.rs
@@ -17,6 +17,7 @@
  * under the License.
  */
 
+use crate::schedule::Target;
 use crate::settings::{Preset as SubagentPreset, Profile as SubagentProfile};
 use maka_plugins::execution::{CreateChild, Target as ExecutionTarget};
 use maka_runtime::execution::{ModelBinding, SandboxMode};
@@ -49,7 +50,7 @@ enum Reason {
 #[derive(Serialize)]
 #[serde(rename_all = "camelCase")]
 struct Agent {
-    agent_id: &'static str,
+    target: Target,
     description: &'static str,
     availability: Availability,
     tools: Option<BTreeSet<String>>,
@@ -57,18 +58,22 @@ struct Agent {
 #[derive(Serialize)]
 #[serde(rename_all = "camelCase")]
 struct Preset {
-    preset_id: String,
+    target: Target,
     name: String,
     description: String,
     profile: SubagentProfile,
     availability: Availability,
 }
 #[derive(Serialize)]
+struct Executor {
+    target: Target,
+}
+#[derive(Serialize)]
 pub(super) struct Listing {
     agents: Vec<Agent>,
     presets: Vec<Preset>,
     /// Executor targets use general agents; native tool ceilings cannot constrain an external backend.
-    executors: Vec<String>,
+    executors: Vec<Executor>,
 }
 
 impl Definitions {
@@ -109,7 +114,7 @@ impl Definitions {
         ]
         .into_iter()
         .map(|(profile, description)| Agent {
-            agent_id: profile.id(),
+            target: Target::Agent { agent_id: profile.id().into() },
             description,
             availability: Self::availability(&capabilities, profile),
             tools: profile.tools(),
@@ -130,7 +135,9 @@ impl Definitions {
                         reason: Reason::ModelUnavailable,
                     }
                 },
-                preset_id: preset.id,
+                target: Target::Preset {
+                    preset_id: preset.id,
+                },
                 name: preset.name,
                 description: preset.description,
                 profile: preset.profile,
@@ -139,7 +146,11 @@ impl Definitions {
         let executors = capabilities
             .executors
             .into_iter()
-            .map(|id| id.as_str().to_owned())
+            .map(|id| Executor {
+                target: Target::Executor {
+                    executor_id: id.as_str().to_owned(),
+                },
+            })
             .collect();
         Ok(Listing {
             agents,
@@ -155,39 +166,33 @@ impl Definitions {
         operation_id: String,
         parent_session_id: String,
     ) -> Result<CreateChild, String> {
-        use crate::schedule::Target;
-        let (profile, name, selected, executor) = match target {
-            Target::Agent {
-                agent_id,
-                executor_id,
-            } => {
+        let capabilities = self
+            .commands
+            .capabilities(self.root.clone())
+            .await
+            .map_err(super::error)?;
+        let (profile, name, selected) = match target {
+            Target::Agent { agent_id } => {
                 let profile = match agent_id.as_str() {
                     "general" => Profile::General,
                     "local-read" => Profile::LocalRead,
                     "web-research" => Profile::WebResearch,
                     "implementation" => Profile::Implementation,
-                    _ => return Err("Agent definition does not exist".into()),
+                    _ => {
+                        return Err(format!(
+                            "Unknown agent {agent_id:?}. Call agent_list and use an available entry's target verbatim."
+                        ));
+                    }
                 };
-                (
-                    profile,
-                    format!("Graph {}", profile.id()),
-                    None,
-                    executor_id,
-                )
+                (profile, format!("Graph {}", profile.id()), None)
             }
-            Target::Preset {
-                preset_id,
-                executor_id,
-            } => {
-                if executor_id.is_some() {
-                    return Err("A model preset cannot also select an executor".into());
-                }
+            Target::Preset { preset_id } => {
                 let preferences = self.settings.read().await.map_err(super::error)?;
                 let preset = preferences
                     .presets
                     .iter()
                     .find(|preset| preset.id == *preset_id && preset.enabled)
-                    .ok_or("Agent preset is missing or disabled")?;
+                    .ok_or_else(|| format!("Preset {preset_id:?} is missing or disabled. Call agent_list and use an available entry's target verbatim."))?;
                 (
                     preset.profile.into(),
                     preset.name.clone(),
@@ -195,38 +200,33 @@ impl Definitions {
                         model: self.preset_model(preset).await?,
                         thinking_level: preset.thinking_level,
                     }),
-                    executor_id,
+                )
+            }
+            Target::Executor { executor_id } => {
+                let id = capabilities.executors.iter().find(|id| id.as_str() == executor_id)
+                    .ok_or_else(|| format!("Executor {executor_id:?} is unavailable. Call agent_list and use an available entry's target verbatim."))?;
+                (
+                    Profile::General,
+                    format!("Graph {}", id.as_str()),
+                    Some(ExecutionTarget::Executor {
+                        executor_id: id.clone(),
+                        settings: Default::default(),
+                    }),
                 )
             }
             Target::Operator { .. } => {
                 return Err("Expected the original operator definition".into());
             }
         };
-        let capabilities = self
-            .commands
-            .capabilities(self.root.clone())
-            .await
-            .map_err(super::error)?;
         if !matches!(
             Self::availability(&capabilities, profile),
             Availability::Available
         ) {
             return Err(format!(
-                "Agent {} is unavailable: required tools or workspace isolation are absent",
+                "Agent {} requires tools not currently available. Call agent_list and choose an available target",
                 profile.id()
             ));
         }
-        let selected = if let Some(executor) = executor {
-            if !matches!(profile, Profile::General) {
-                return Err("External executors cannot enforce native agent tool profiles".into());
-            }
-            Some(ExecutionTarget::Executor {
-                executor_id: executor.clone().try_into().map_err(super::error)?,
-                settings: Default::default(),
-            })
-        } else {
-            selected
-        };
         Ok(CreateChild {
             workspace: matches!(profile, Profile::Implementation)
                 .then_some(maka_plugins::execution::ChildWorkspace::IsolatedGit),
@@ -253,6 +253,6 @@ impl Definitions {
             .await
             .map_err(super::error)?
             .map(|choice| choice.model)
-            .ok_or_else(|| "Preset model is missing, disabled or retired".into())
+            .ok_or_else(|| "Preset model is missing, disabled or retired. Call agent_list and choose an available target, or repair the preset's model in settings.".into())
     }
 }
diff --git a/crates/graph/src/plugin/read/detail.rs b/crates/graph/src/plugin/read/detail.rs
index 68900f603c..e78d19d8f4 100644
--- a/crates/graph/src/plugin/read/detail.rs
+++ b/crates/graph/src/plugin/read/detail.rs
@@ -85,7 +85,6 @@ mod tests {
             work_id: WorkId::new(),
             target: Target::Agent {
                 agent_id: "general".into(),
-                executor_id: None,
             },
             instruction: instruction.clone(),
             input_ids: (0..64)
diff --git a/crates/graph/src/plugin/session.rs b/crates/graph/src/plugin/session.rs
index fd7e729b43..f7bb71a8ec 100644
--- a/crates/graph/src/plugin/session.rs
+++ b/crates/graph/src/plugin/session.rs
@@ -85,9 +85,9 @@ impl Manager {
             Ok(Preparation {
                 basis: Some(basis),
                 instructions: if handle.snapshot().swarm.is_some() {
-                    "You are the Agent Swarm supervisor. Prefer parallel delegation when at least two meaningful independent items improve the work; handle small, conversational, latency-sensitive or indivisible requests directly. Do only lightweight exploration before delegation. Discover agent_list, agent_swarm_status, view_agent_graph, update_agent_graph and yield_agent_graph with tool_search. Use exact available agent/preset IDs, bounded self-contained instructions and non-overlappin [...]
+                    "You are the Agent Swarm supervisor. Prefer parallel delegation when at least two meaningful independent items improve the work; handle small, conversational, latency-sensitive or indivisible requests directly. Do only lightweight exploration before delegation. Discover agent_list, agent_swarm_status, view_agent_graph, update_agent_graph and yield_agent_graph with tool_search. Copy available targets from agent_list; use bounded self-contained instructions and non-over [...]
                 } else {
-                    "You are the Agent Graph supervisor. Prefer delegation when it materially improves the work; handle small or indivisible requests directly. Discover agent_list, view_agent_graph, update_agent_graph and yield_agent_graph with tool_search. Delegate bounded work using exact available agent/preset IDs, inspect durable results and schedule dependent work using record IDs. Avoid overlapping writes. When waiting, yield_agent_graph rather than poll; durable outcomes will wake [...]
+                    "You are the Agent Graph supervisor. Prefer delegation when it materially improves the work; handle small or indivisible requests directly. Discover agent_list, view_agent_graph, update_agent_graph and yield_agent_graph with tool_search. Delegate bounded work by copying available targets from agent_list, inspect durable results and schedule dependent work using record IDs. Avoid overlapping writes. When waiting, yield_agent_graph rather than poll; durable outcomes wil [...]
                 }.into(),
                 tool_ceiling: None,
                 ..Default::default()
diff --git a/crates/graph/src/plugin/tools.rs b/crates/graph/src/plugin/tools.rs
index 0190c8aa11..e484d40d43 100644
--- a/crates/graph/src/plugin/tools.rs
+++ b/crates/graph/src/plugin/tools.rs
@@ -50,7 +50,7 @@ pub(super) fn register(staged: &mut Staged, manager: Arc<super::Manager>) -> Res
         ),
         (
             "agent_list",
-            "List available agents for new Graph work. Use exact returned IDs.",
+            "List agents, presets and executors for new Graph work. Copy an available entry's target verbatim into update_agent_graph work; do not infer IDs from display names. Agent targets inherit the parent's backend; presets choose their configured model; executor targets use the named plugin backend.",
             schemars::schema_for!(Empty).into(),
             ToolSemantics::Parallel,
         ),
diff --git a/crates/graph/src/schedule.rs b/crates/graph/src/schedule.rs
index b3808fdb17..b6eaded0d0 100644
--- a/crates/graph/src/schedule.rs
+++ b/crates/graph/src/schedule.rs
@@ -34,16 +34,14 @@ pub enum Target {
     Agent {
         #[schemars(length(min = 1, max = 256))]
         agent_id: String,
-        #[serde(default, skip_serializing_if = "Option::is_none")]
-        #[schemars(length(min = 1, max = 256))]
-        executor_id: Option<String>,
     },
     Preset {
         #[schemars(length(min = 1, max = 256))]
         preset_id: String,
-        #[serde(default, skip_serializing_if = "Option::is_none")]
+    },
+    Executor {
         #[schemars(length(min = 1, max = 256))]
-        executor_id: Option<String>,
+        executor_id: String,
     },
     Operator {
         operator_id: OperatorId,
@@ -130,24 +128,9 @@ impl Update {
             }
             bounded_text(&work.instruction, 60_000)?;
             match &work.target {
-                Target::Agent {
-                    agent_id,
-                    executor_id,
-                } => {
-                    identity(agent_id)?;
-                    if let Some(id) = executor_id {
-                        identity(id)?;
-                    }
-                }
-                Target::Preset {
-                    preset_id,
-                    executor_id,
-                } => {
-                    identity(preset_id)?;
-                    if let Some(id) = executor_id {
-                        identity(id)?;
-                    }
-                }
+                Target::Agent { agent_id } => identity(agent_id)?,
+                Target::Preset { preset_id } => identity(preset_id)?,
+                Target::Executor { executor_id } => identity(executor_id)?,
                 Target::Operator { .. } => {}
             }
             if work.input_ids.len() + work.selected_result_inputs.len() > 64 {
diff --git a/crates/graph/tests/repository.rs b/crates/graph/tests/repository.rs
index 279160c727..c6020b7655 100644
--- a/crates/graph/tests/repository.rs
+++ b/crates/graph/tests/repository.rs
@@ -100,7 +100,6 @@ fn update(graph_id: GraphId) -> Update {
                 work_id: WorkId::new(),
                 target: Target::Agent {
                     agent_id: "general".into(),
-                    executor_id: None,
                 },
                 instruction: "source\n".repeat(7000),
                 input_ids: vec![],
diff --git a/crates/runtime-host/tests/integration/graph_plugin.rs b/crates/runtime-host/tests/integration/graph_plugin.rs
index bf60c5dc57..05f8295138 100644
--- a/crates/runtime-host/tests/integration/graph_plugin.rs
+++ b/crates/runtime-host/tests/integration/graph_plugin.rs
@@ -322,7 +322,7 @@ async fn scenario(implementation: bool) {
                 .await
                 .unwrap();
         } else {
-            presets(&mut peer, json!([{"id":"reader","name":"Review worker","description":"Read-only review",
+            presets(&mut peer, json!([{"id":"general","name":"Review worker","description":"Read-only review",
                 "profile":if implementation { "implementation" } else { "local_read" },"connectionSlug":model.connection_slug,"model":model.model,"enabled":true}])).await;
             let created = peer.rpc("session.create", json!({
                 "sessionId":"graph-root", "workspace":{"kind":"host_path","path":fixture.workspace},
@@ -388,9 +388,28 @@ async fn scenario(implementation: bool) {
                 .send(tool("list", "agent_list", json!({})))
                 .unwrap();
             let scheduling = next(&mut requests, "available preset catalog").await;
-            assert!(scheduling.body.to_string().contains("Review worker"));
+            let output = scheduling.body["messages"]
+                .as_array()
+                .unwrap()
+                .iter()
+                .rev()
+                .find(|message| message["role"] == "tool")
+                .unwrap();
+            let catalog: Value = serde_json::from_str(output["content"].as_str().unwrap()).unwrap();
+            let preset = &catalog["presets"][0];
+            assert_eq!(preset["name"], "Review worker");
+            assert_eq!(preset["availability"]["status"], "available");
+            // Display names are not selectors; an identical profile/preset ID is unambiguous.
+            assert_eq!(
+                catalog["agents"][0]["target"],
+                json!({"kind":"agent","agentId":"general"})
+            );
+            assert_eq!(
+                preset["target"],
+                json!({"kind":"preset","presetId":"general"})
+            );
             scheduling.reply.send(tool("schedule", "update_agent_graph", json!({
-                "operation":"add_work","work":[{"target":{"kind":"preset","presetId":"reader"},"instruction":instruction}]
+                "operation":"add_work","work":[{"target":preset["target"],"instruction":instruction}]
             }))).unwrap();
             let mut child = None;
             let mut yielded = false;
diff --git a/docs/rust-runtime.md b/docs/rust-runtime.md
index 4987ceed6a..bb38c487f2 100644
--- a/docs/rust-runtime.md
+++ b/docs/rust-runtime.md
@@ -460,6 +460,9 @@ The plugin platform supports linked Rust packages, shared/dedicated-V8 JavaScrip
 scoped Host services, external executors, and Desktop Slots/Remote streams.
 Graph/Swarm and scheduling are built-in plugins. Graph implementation workers use
 Host-owned gix worktrees and publish immutable patches without automatic merging.
+`agent_list` returns ready-to-use `target` values for Graph work. Agent targets inherit
+the parent backend, presets select their configured model, and executor targets select
+a plugin backend without native tool-profile constraints.
 Per-Turn orchestration survives yield and resume without changing Session defaults;
 Swarm checkpoints carry status and final-result IDs, with paged history for retrieval.
 See the [plugin SDK](../packages/plugin-sdk/README.md) for contracts and limits.
diff --git a/docs/rust-runtime.zh-CN.md b/docs/rust-runtime.zh-CN.md
index b6d3d533da..cacaa82407 100644
--- a/docs/rust-runtime.zh-CN.md
+++ b/docs/rust-runtime.zh-CN.md
@@ -360,6 +360,8 @@ Recall 是会话历史检索,不属于排除的 Memory 子系统。原生部
 插件平台支持静态链接 Rust 包、共享/独立 V8 的 JavaScript 包、作用域 Host 服务、外部 Executor,
 以及 Desktop Slot/Remote stream。Graph/Swarm 与定时任务是内置插件。
 Graph 实现类工作使用 Host 管理的 gix worktree,发布不可变补丁,不自动合并。
+`agent_list` 返回可直接用于 Graph 工作的 `target`:Agent 继承父级后端,Preset 选择配置的模型,
+Executor 选择插件后端,不能叠加原生工具 Profile 限制。
 单次 Turn 编排跨 yield 和 resume 保留,不改变 Session 默认值;Swarm checkpoint 提供状态和最终结果 ID,
 通过历史分页取回正文。接口与限制见[插件 SDK](../packages/plugin-sdk/README.zh-CN.md)。
 OS 沙箱暂缓。Memory 留待单独重做,不移植旧实现,也不纳入本次重写。内容脱敏不实现。


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org