Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
518 changes: 487 additions & 31 deletions crates/octos-agent/src/agent/execution.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/octos-agent/src/agent/loop_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3487,6 +3487,7 @@ printf '{"output":"voice saved","success":true}\n'
env: vec![],
risk: None,
spawn_only_message: None,
auto_summarize: false,
concurrency_class: None,
};
let plugin = PluginTool::new("mofa-fm".into(), def, script_path).with_extra_env(vec![(
Expand Down
3 changes: 3 additions & 0 deletions crates/octos-agent/src/plugins/extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub struct SkillExtras {
pub spawn_only_tools: Vec<String>,
/// Custom messages per spawn_only tool.
pub spawn_only_messages: std::collections::HashMap<String, String>,
/// spawn_only tools opted into bounded file summary follow-ups.
pub spawn_only_auto_summarize: Vec<String>,
}

/// Resolve manifest extras against the skill directory.
Expand Down Expand Up @@ -438,6 +440,7 @@ mod tests {
env: vec![],
risk: None,
spawn_only_message: None,
auto_summarize: false,
concurrency_class: None,
})
.collect(),
Expand Down
52 changes: 52 additions & 0 deletions crates/octos-agent/src/plugins/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ impl PluginLoader {
Ok((tools, extras)) => {
let n = tools.len();
let spawn_only = extras.spawn_only_tools.clone();
let auto_summarize = extras.spawn_only_auto_summarize.clone();
for loaded in tools {
let tool = loaded.tool;
let name = tool.name().to_string();
Expand All @@ -230,6 +231,9 @@ impl PluginLoader {
for name in &spawn_only {
let msg = extras.spawn_only_messages.get(name).cloned();
registry.mark_spawn_only(name, msg);
if auto_summarize.iter().any(|tool| tool == name) {
registry.mark_spawn_only_auto_summarize(name);
}
}
// Don't defer — tool stays visible to LLM.
// The execution loop auto-redirects calls to background spawn.
Expand Down Expand Up @@ -565,6 +569,12 @@ impl PluginLoader {
)
})
.collect();
let spawn_only_auto_summarize: Vec<String> = manifest
.tools
.iter()
.filter(|t| t.spawn_only && t.auto_summarize && t.validate_for_registration().is_ok())
.map(|t| t.name.clone())
.collect();

let plugin_name = manifest.name.clone();
let tools: Vec<LoadedPluginTool> = manifest
Expand Down Expand Up @@ -664,6 +674,7 @@ impl PluginLoader {
// Return extras with spawn_only info
extras.spawn_only_tools = spawn_only_names;
extras.spawn_only_messages = spawn_only_msgs;
extras.spawn_only_auto_summarize = spawn_only_auto_summarize;

Ok((tools, extras))
}
Expand Down Expand Up @@ -1919,6 +1930,42 @@ mod tests {
assert!(plugin_dir.join("main").exists());
}

#[cfg(unix)]
#[test]
fn test_loader_marks_spawn_only_auto_summarize_from_manifest() {
let dir = tempfile::tempdir().unwrap();
let plugin_dir = dir.path().join("mofa-publish");
std::fs::create_dir_all(plugin_dir.join("scripts")).unwrap();

std::fs::write(
plugin_dir.join("manifest.json"),
r#"{
"name": "mofa-publish",
"version": "0.1.0",
"tools": [{
"name": "mofa_publish",
"description": "deploy",
"input_schema": {"type": "object", "properties": {}},
"spawn_only": true,
"auto_summarize": true
}]
}"#,
)
.unwrap();
std::fs::write(
plugin_dir.join("scripts/publish_site.sh"),
"#!/usr/bin/env bash\nset -euo pipefail\necho \"publish:$*\"\n",
)
.unwrap();

let mut registry = ToolRegistry::new();
let result =
PluginLoader::load_into(&mut registry, &[dir.path().to_path_buf()], &[]).unwrap();
assert_eq!(result.tool_count, 1);
assert!(registry.is_spawn_only("mofa_publish"));
assert!(registry.spawn_only_auto_summarize("mofa_publish"));
}

#[test]
fn test_builtin_env_allowlist_augments_first_party_mofa_tools_only() {
let def = PluginToolDef {
Expand All @@ -1929,6 +1976,7 @@ mod tests {
env: vec!["EXISTING_ENV".to_string(), "GEMINI_API_KEY".to_string()],
risk: None,
spawn_only_message: None,
auto_summarize: false,
concurrency_class: None,
};

Expand All @@ -1953,6 +2001,7 @@ mod tests {
env: vec![],
risk: None,
spawn_only_message: None,
auto_summarize: false,
concurrency_class: None,
};
let untrusted = apply_builtin_env_allowlist("custom-plugin", untrusted);
Expand Down Expand Up @@ -2466,6 +2515,7 @@ edition = "2021"
],
spawn_only_tools: vec![],
spawn_only_messages: Default::default(),
spawn_only_auto_summarize: vec![],
};
result.merge_extras(e1);

Expand All @@ -2479,6 +2529,7 @@ edition = "2021"
],
spawn_only_tools: vec![],
spawn_only_messages: Default::default(),
spawn_only_auto_summarize: vec![],
};
result.merge_extras(e2);

Expand All @@ -2492,6 +2543,7 @@ edition = "2021"
],
spawn_only_tools: vec![],
spawn_only_messages: Default::default(),
spawn_only_auto_summarize: vec![],
};
result.merge_extras(e3);

Expand Down
34 changes: 34 additions & 0 deletions crates/octos-agent/src/plugins/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ pub struct PluginToolDef {
/// Default: "SUCCESS: Task is now running in background..."
#[serde(default)]
pub spawn_only_message: Option<String>,
/// If true, successful spawn_only completions with large text file outputs
/// append a bounded LLM-generated summary to chat history.
#[serde(default)]
pub auto_summarize: bool,
/// Item 6 of OCTOS_M8_FIX_FIRST_CHECKLIST_2026-04-24:
/// optional concurrency class. When `"exclusive"` the M8.8
/// scheduler serialises this tool against any sibling in the same
Expand Down Expand Up @@ -715,10 +719,39 @@ mod tests {
env: env.into_iter().map(str::to_string).collect(),
risk: None,
spawn_only_message: None,
auto_summarize: false,
concurrency_class: None,
}
}

#[test]
fn tool_auto_summarize_defaults_false_and_parses_true() {
let manifest: PluginManifest = serde_json::from_str(
r#"{
"name": "summary-default",
"version": "0.1.0",
"tools": [{"name": "default_tool", "description": "d"}]
}"#,
)
.unwrap();
assert!(!manifest.tools[0].auto_summarize);

let manifest: PluginManifest = serde_json::from_str(
r#"{
"name": "summary-opt-in",
"version": "0.1.0",
"tools": [{
"name": "summary_tool",
"description": "d",
"spawn_only": true,
"auto_summarize": true
}]
}"#,
)
.unwrap();
assert!(manifest.tools[0].auto_summarize);
}

#[test]
fn validate_for_registration_accepts_clean_allowlist() {
let def = def_with_env(vec!["OPENAI_API_KEY", "SMTP_HOST", "_FOO_BAR_"]);
Expand Down Expand Up @@ -843,6 +876,7 @@ mod tests {
env: vec![],
risk: None,
spawn_only_message: None,
auto_summarize: false,
concurrency_class: class.map(str::to_string),
}
}
Expand Down
Loading
Loading