Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/plugin-sdk/src/generated/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4610,7 +4610,7 @@ export interface ClientOperation {
*/
reference?: RecoveryRef | null;
/**
* A known returned business outcome; absent is never proof that it did not run.
* A terminal business outcome; absent is never proof that it did not run.
*/
receipt?: Receipt | null;
}
Expand Down
225 changes: 83 additions & 142 deletions plugins/agent/engine/src/prepared_prompt/wire/production_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,31 +126,31 @@ async fn capture(

#[tokio::test]
async fn two_captured_requests_reach_send_ready_and_last_output_retains_full_charge() {
tokio::time::timeout(Duration::from_secs(10), async {
let directory = tempfile::tempdir().unwrap();
let (root, log, execution, selection) = source(directory.path()).await;
let provider = provider();
let options = serde_json::Value::Null;
let cancellation = CancellationToken::new();
let probe_resources = ModelPreparationResources::new(PreparationPolicy::default()).unwrap();
let probe = capture(&log, selection.clone(), probe_resources.clone()).await;
let encoding = WireEncoding::new(Language::En, &provider, &options, &[]).unwrap();
let plan = encoding
.count_prompt(&probe.model(), probe_resources)
.await
.unwrap();
let source_bytes = probe.resident_bytes();
let full_bytes = source_bytes + plan.allocation();
drop(plan);
probe.close().await.unwrap();
drop(probe);

let resources = ModelPreparationResources::new(PreparationPolicy {
staging_bytes: 2 * source_bytes,
resident_bytes: full_bytes,
..Default::default()
})
let directory = tempfile::tempdir().unwrap();
let (root, log, execution, selection) = source(directory.path()).await;
let provider = provider();
let options = serde_json::Value::Null;
let cancellation = CancellationToken::new();
let probe_resources = ModelPreparationResources::new(PreparationPolicy::default()).unwrap();
let probe = capture(&log, selection.clone(), probe_resources.clone()).await;
let encoding = WireEncoding::new(Language::En, &provider, &options, &[]).unwrap();
let plan = encoding
.count_prompt(&probe.model(), probe_resources)
.await
.unwrap();
let source_bytes = probe.resident_bytes();
let full_bytes = source_bytes + plan.allocation();
drop(plan);
probe.close().await.unwrap();
drop(probe);

let resources = ModelPreparationResources::new(PreparationPolicy {
staging_bytes: 2 * source_bytes,
resident_bytes: full_bytes,
..Default::default()
})
.unwrap();
tokio::time::timeout(Duration::from_secs(10), async {
let mut first = capture(&log, selection.clone(), resources.clone()).await;
let mut second = capture(&log, selection, resources.clone()).await;
assert_eq!(first.resident_bytes(), source_bytes);
Expand Down Expand Up @@ -203,134 +203,75 @@ async fn two_captured_requests_reach_send_ready_and_last_output_retains_full_cha
drop(cursor);
second.close().await.unwrap();
drop(second);
drop(log);
execution.finish();
root.shutdown().await.unwrap();
})
.await
.expect("source capture, admission and final output release must make progress");
drop(log);
execution.finish();
root.shutdown().await.unwrap();
}

#[tokio::test]
async fn direct_catalog_definitions_release_after_cancelled_wire_admission() {
use maka_agent_facts::tools::{ToolExecutor, ToolFuture};
use maka_tools::{
CodeExecutor, RunTools, ToolCatalog, ToolHandler, ToolMode, ToolNesting, ToolRegistration,
ToolSemantics, availability::LoadedTools,
};

struct Handler;
impl ToolExecutor for Handler {
fn names(&self) -> Vec<String> {
vec!["fixture".into()]
}
fn invoke(&self, _: String, input: serde_json::Value, _: CancellationToken) -> ToolFuture {
Box::pin(async move { Ok(input) })
}
}
async fn blocked_wire_admission_releases_counting_work_and_observes_cancellation() {
let directory = tempfile::tempdir().unwrap();
let (root, log, execution, selection) = source(directory.path()).await;
let definitions = [Arc::new(ToolDefinition {
name: "fixture".into(),
description: "fixture input".into(),
input_schema: serde_json::json!({"type":"object"}),
output_schema: None,
provider: None,
freeform: None,
})];
let policy = PreparationPolicy::default();
let resources = ModelPreparationResources::new(PreparationPolicy {
progress_bytes: policy.work_bytes,
..policy
})
.unwrap();
let resident = resources
.reserve_staging(1)
.await
.unwrap()
.promote(policy.resident_bytes)
.await
.unwrap();
let mut prompt = capture(&log, selection, resources.clone()).await;
let provider = provider();
let options = serde_json::Value::Null;
let cancellation = CancellationToken::new();

tokio::time::timeout(Duration::from_secs(10), async {
let directory = tempfile::tempdir().unwrap();
let (root, log, execution, selection) = source(directory.path()).await;
let catalog = ToolCatalog::new([ToolRegistration {
definition: ToolDefinition {
name: "fixture".into(),
description: "shared catalog definition".into(),
input_schema: serde_json::json!({"type":"object"}),
output_schema: None,
provider: None,
freeform: None,
},
nesting: ToolNesting::DirectOnly,
semantics: ToolSemantics::Parallel,
handler: ToolHandler::Immediate(Arc::new(Handler)),
}])
.unwrap();
let definition = catalog.shared_definitions().next().unwrap();
let weak = Arc::downgrade(&definition);
let tools = RunTools::new(
let work = resources.acquire_work().await.unwrap();
let compilation = prompt.compile_wire(
Language::En,
log.clone(),
Invocation {
session_id: "session".into(),
turn_id: "turn".into(),
run_id: "run".into(),
invocation_id: "invocation".into(),
},
catalog,
ToolMode::Direct,
CodeExecutor::new(maka_code_runtime::CellLimits::default()).unwrap(),
LoadedTools::temporary().unwrap(),
&provider,
&options,
&definitions,
&cancellation,
);
let request = tools.capture(".", CancellationToken::new()).await.unwrap();
let definitions = request.definitions();
assert_eq!(definitions.len(), 1);
assert!(Arc::ptr_eq(&definition, &definitions[0]));

let policy = PreparationPolicy::default();
let resources = ModelPreparationResources::new(PreparationPolicy {
progress_bytes: policy.work_bytes,
..policy
})
.unwrap();
let resident = resources
.reserve_staging(1)
.await
.unwrap()
.promote(policy.resident_bytes)
.await
.unwrap();
let mut prompt = capture(&log, selection, resources.clone()).await;
let provider = provider();
let options = serde_json::Value::Null;
let cancellation = CancellationToken::new();
let owners = Arc::strong_count(&definition);
{
let work = resources.acquire_work().await.unwrap();
let compilation = async {
let attempt_definitions = request.definitions();
assert!(Arc::ptr_eq(&definition, &attempt_definitions[0]));
prompt
.compile_wire(
Language::En,
&provider,
&options,
&attempt_definitions,
&cancellation,
)
.await
};
tokio::pin!(compilation);
assert!(matches!(poll!(&mut compilation), Poll::Pending));
let counted = resources.acquire_work();
tokio::pin!(counted);
assert!(matches!(poll!(&mut counted), Poll::Pending));
drop(work);
let counted = tokio::select! {
result = &mut compilation => panic!("resident admission must wait: {result:?}"),
result = &mut counted => result.unwrap(),
};
// The sole work envelope is released only after counting, before promotion.
assert!(matches!(poll!(&mut compilation), Poll::Pending));
assert!(Arc::strong_count(&definition) > owners);
cancellation.cancel();
assert!(matches!(compilation.await, Err(RunError::Cancelled)));
drop(counted);
}
assert_eq!(Arc::strong_count(&definition), owners);
drop(resident);
prompt.close().await.unwrap();
drop(prompt);
drop(definitions);
drop(request);
tools.shutdown().await.unwrap();
drop(tools);
drop(definition);
assert!(weak.upgrade().is_none());
drop(log);
execution.finish();
root.shutdown().await.unwrap();
tokio::pin!(compilation);
assert!(matches!(poll!(&mut compilation), Poll::Pending));
let counted = resources.acquire_work();
tokio::pin!(counted);
assert!(matches!(poll!(&mut counted), Poll::Pending));
drop(work);
let counted = tokio::select! {
result = &mut compilation => panic!("resident admission must wait: {result:?}"),
result = &mut counted => result.unwrap(),
};
assert!(matches!(poll!(&mut compilation), Poll::Pending));
cancellation.cancel();
assert!(matches!(compilation.await, Err(RunError::Cancelled)));
drop(counted);
})
.await
.expect("blocked wire admission must release shared definitions on cancellation");
.expect("wire admission must release counting work and observe cancellation");

drop(resident);
prompt.close().await.unwrap();
drop(prompt);
drop(log);
execution.finish();
root.shutdown().await.unwrap();
}
5 changes: 2 additions & 3 deletions plugins/agent/native/src/owner/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1255,9 +1255,8 @@ async fn cleanup_case(panic: bool) {
fixture.owner.runs.lock().await.retained_cleanup.len(),
usize::from(panic)
);
assert_eq!(
fixture.owner.runs.lock().await.closing,
false,
assert!(
!fixture.owner.runs.lock().await.closing,
"one failed invocation must not close the Agent owner"
);
assert!(!fixture.owner.stop.is_cancelled());
Expand Down
2 changes: 1 addition & 1 deletion plugins/agent/tool-catalog/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ mod tests {
definition: ToolDefinition {
provider: None,
name: "fixture".into(),
description: "d".repeat(1024 * 1024 + 1),
description: "catalog definition".into(),
input_schema: json!({"type":"string"}),
freeform: None,
output_schema: None,
Expand Down
12 changes: 6 additions & 6 deletions products/maka/cli/THIRD_PARTY_NOTICES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9936,7 +9936,7 @@ Apache License

clipboard-rs@0.3.5 (MIT); authors declared by package: ChurchTao <swkzymlyy@gmail.com>

git+https://github.com/maka-agent/cua?rev=7dfc429ba3db0568c46c49f633b724750f34f451#7dfc429ba3db0568c46c49f633b724750f34f451 :: LICENSE
git+https://github.com/maka-agent/cua?rev=9e385e6671acb9b985bc88257e94357db39d21ac#9e385e6671acb9b985bc88257e94357db39d21ac :: LICENSE
https://crates.io/api/v1/crates/clipboard-rs/0.3.5/download :: LICENSE

MIT License
Expand Down Expand Up @@ -9977,7 +9977,7 @@ platform-windows@0.38.0 (MIT)
zbus@5.19.0 (MIT); authors declared by package: Zeeshan Ali Khan <zeeshanak@gnome.org>

git+https://github.com/maka-agent/cua?rev=23221967ce6044c1fed303701f43fa54564f0f53#23221967ce6044c1fed303701f43fa54564f0f53
git+https://github.com/maka-agent/cua?rev=7dfc429ba3db0568c46c49f633b724750f34f451#7dfc429ba3db0568c46c49f633b724750f34f451
git+https://github.com/maka-agent/cua?rev=9e385e6671acb9b985bc88257e94357db39d21ac#9e385e6671acb9b985bc88257e94357db39d21ac

Cua Driver Rust SDK and its workspace crates
Source: https://github.com/trycua/cua
Expand Down Expand Up @@ -13312,7 +13312,7 @@ DEALINGS IN THE SOFTWARE.

cua-cursor-motion@0.38.0 (MIT); authors declared by package: trycua

git+https://github.com/maka-agent/cua?rev=7dfc429ba3db0568c46c49f633b724750f34f451#7dfc429ba3db0568c46c49f633b724750f34f451 :: LICENSE
git+https://github.com/maka-agent/cua?rev=9e385e6671acb9b985bc88257e94357db39d21ac#9e385e6671acb9b985bc88257e94357db39d21ac :: LICENSE

MIT License

Expand Down Expand Up @@ -13340,7 +13340,7 @@ SOFTWARE.

cua-driver-core@0.38.0 (MIT AND Apache-2.0)

git+https://github.com/maka-agent/cua?rev=7dfc429ba3db0568c46c49f633b724750f34f451#7dfc429ba3db0568c46c49f633b724750f34f451 :: src/browser/extension_assets/maka-ui/LICENSE
git+https://github.com/maka-agent/cua?rev=9e385e6671acb9b985bc88257e94357db39d21ac#9e385e6671acb9b985bc88257e94357db39d21ac :: src/browser/extension_assets/maka-ui/LICENSE

Apache License
Version 2.0, January 2004
Expand Down Expand Up @@ -13714,7 +13714,7 @@ third-party/gix-discover/{LICENSE-APACHE,LICENSE-MIT,upstream.json,SOURCE.md}.

cua-driver-core@0.38.0 (MIT AND Apache-2.0)

git+https://github.com/maka-agent/cua?rev=7dfc429ba3db0568c46c49f633b724750f34f451#7dfc429ba3db0568c46c49f633b724750f34f451 :: src/browser/extension_assets/maka-ui/NOTICE
git+https://github.com/maka-agent/cua?rev=9e385e6671acb9b985bc88257e94357db39d21ac#9e385e6671acb9b985bc88257e94357db39d21ac :: src/browser/extension_assets/maka-ui/NOTICE

Apache Maka (incubating)
Copyright 2026 The Apache Software Foundation
Expand Down Expand Up @@ -49499,7 +49499,7 @@ zbus_xml@5.2.1 (MIT); authors declared by package: Zeeshan Ali Khan <zeeshanak@g
zvariant@5.15.1 (MIT); authors declared by package: Zeeshan Ali Khan <zeeshanak@gnome.org>
zvariant_derive@5.15.1 (MIT); authors declared by package: Zeeshan Ali Khan <zeeshanak@gnome.org>

git+https://github.com/maka-agent/cua?rev=7dfc429ba3db0568c46c49f633b724750f34f451#7dfc429ba3db0568c46c49f633b724750f34f451 :: LICENSE
git+https://github.com/maka-agent/cua?rev=9e385e6671acb9b985bc88257e94357db39d21ac#9e385e6671acb9b985bc88257e94357db39d21ac :: LICENSE
https://crates.io/api/v1/crates/zbus_macros/5.19.0/download :: LICENSE
https://crates.io/api/v1/crates/zbus_names/4.3.5/download :: LICENSE
https://crates.io/api/v1/crates/zbus_xml/5.2.1/download :: LICENSE
Expand Down
Loading
Loading