Skip to content

Commit 21876ec

Browse files
committed
feat(sdk): expose ConfirmationInheritance in Python and Node SDKs
Adds confirmation_inheritance field to WorkerAgentSpec and AgentDefinition in both Python (PyO3) and Node (napi-rs) SDKs, mirroring the Rust core API. Values: "auto_approve" (default), "deny_on_ask", "inherit_parent" Changes: - core/src/lib.rs: export ConfirmationInheritance from subagent module - sdk/node: add confirmationInheritance to WorkerAgentSpec/AgentDefinition - sdk/node: add parse/convert helpers for the enum - sdk/node: regenerate index.d.ts with napi build - sdk/python: add confirmation_inheritance to PyWorkerAgentSpec/PyAgentDefinition - sdk/python: add parse/convert helpers for the enum Both SDKs now expose the full capability inheritance contract introduced in commit 2535474. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5f1d479 commit 21876ec

4 files changed

Lines changed: 81 additions & 2 deletions

File tree

core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ pub use run::{
130130
RunStatus,
131131
};
132132
pub use subagent::{
133-
AgentDefinition, AgentRegistry, CattleAgentKind, CattleAgentSpec, WorkerAgentKind,
134-
WorkerAgentSpec,
133+
AgentDefinition, AgentRegistry, CattleAgentKind, CattleAgentSpec, ConfirmationInheritance,
134+
WorkerAgentKind, WorkerAgentSpec,
135135
};

sdk/node/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ export interface WorkerAgentSpec {
226226
prompt?: string
227227
/** Maximum execution steps/tool rounds. */
228228
maxSteps?: number
229+
/** How child runs resolve Ask decisions: "auto_approve" (default), "deny_on_ask", or "inherit_parent". */
230+
confirmationInheritance?: string
229231
}
230232
export interface AgentDefinition {
231233
name: string
@@ -235,6 +237,8 @@ export interface AgentDefinition {
235237
model?: string
236238
prompt?: string
237239
maxSteps?: number
240+
/** How child runs resolve Ask decisions: "auto_approve", "deny_on_ask", or "inherit_parent". */
241+
confirmationInheritance?: string
238242
}
239243
/**
240244
* HITL confirmation policy configuration.

sdk/node/src/lib.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,8 @@ pub struct WorkerAgentSpec {
14941494
pub prompt: Option<String>,
14951495
/// Maximum execution steps/tool rounds.
14961496
pub max_steps: Option<u32>,
1497+
/// How child runs resolve Ask decisions: "auto_approve" (default), "deny_on_ask", or "inherit_parent".
1498+
pub confirmation_inheritance: Option<String>,
14971499
}
14981500

14991501
#[napi(object)]
@@ -1505,6 +1507,8 @@ pub struct AgentDefinition {
15051507
pub model: Option<String>,
15061508
pub prompt: Option<String>,
15071509
pub max_steps: Option<u32>,
1510+
/// How child runs resolve Ask decisions: "auto_approve", "deny_on_ask", or "inherit_parent".
1511+
pub confirmation_inheritance: Option<String>,
15081512
}
15091513

15101514
/// HITL confirmation policy configuration.
@@ -2229,6 +2233,9 @@ fn js_worker_agent_spec_to_rust(spec: WorkerAgentSpec) -> napi::Result<RustWorke
22292233
if let Some(max_steps) = spec.max_steps {
22302234
worker = worker.with_max_steps(max_steps as usize);
22312235
}
2236+
if let Some(ci) = spec.confirmation_inheritance {
2237+
worker = worker.with_confirmation(parse_confirmation_inheritance(&ci)?);
2238+
}
22322239
Ok(worker)
22332240
}
22342241

@@ -2238,6 +2245,32 @@ fn parse_worker_agent_kind(kind: Option<&str>) -> napi::Result<RustWorkerAgentKi
22382245
.map_err(|e| napi::Error::from_reason(e.to_string()))
22392246
}
22402247

2248+
fn parse_confirmation_inheritance(
2249+
value: &str,
2250+
) -> napi::Result<a3s_code_core::subagent::ConfirmationInheritance> {
2251+
use a3s_code_core::subagent::ConfirmationInheritance;
2252+
match value {
2253+
"auto_approve" => Ok(ConfirmationInheritance::AutoApprove),
2254+
"deny_on_ask" => Ok(ConfirmationInheritance::DenyOnAsk),
2255+
"inherit_parent" => Ok(ConfirmationInheritance::InheritParent),
2256+
other => Err(napi::Error::from_reason(format!(
2257+
"invalid confirmation_inheritance: '{}' (expected: auto_approve, deny_on_ask, inherit_parent)",
2258+
other
2259+
))),
2260+
}
2261+
}
2262+
2263+
fn confirmation_inheritance_to_js(
2264+
ci: &a3s_code_core::subagent::ConfirmationInheritance,
2265+
) -> String {
2266+
use a3s_code_core::subagent::ConfirmationInheritance;
2267+
match ci {
2268+
ConfirmationInheritance::AutoApprove => "auto_approve".to_string(),
2269+
ConfirmationInheritance::DenyOnAsk => "deny_on_ask".to_string(),
2270+
ConfirmationInheritance::InheritParent => "inherit_parent".to_string(),
2271+
}
2272+
}
2273+
22412274
fn rust_agent_definition_to_js(def: RustAgentDefinition) -> AgentDefinition {
22422275
AgentDefinition {
22432276
name: def.name,
@@ -2247,6 +2280,10 @@ fn rust_agent_definition_to_js(def: RustAgentDefinition) -> AgentDefinition {
22472280
model: def.model.map(|model| model.model_ref()),
22482281
prompt: def.prompt,
22492282
max_steps: def.max_steps.map(|steps| steps as u32),
2283+
confirmation_inheritance: def
2284+
.confirmation_inheritance
2285+
.as_ref()
2286+
.map(confirmation_inheritance_to_js),
22502287
}
22512288
}
22522289

sdk/python/src/lib.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3330,6 +3330,8 @@ struct PyWorkerAgentSpec {
33303330
prompt: Option<String>,
33313331
#[pyo3(get, set)]
33323332
max_steps: Option<usize>,
3333+
#[pyo3(get, set)]
3334+
confirmation_inheritance: Option<String>,
33333335
}
33343336

33353337
#[pymethods]
@@ -3346,6 +3348,7 @@ impl PyWorkerAgentSpec {
33463348
model: None,
33473349
prompt: None,
33483350
max_steps: None,
3351+
confirmation_inheritance: None,
33493352
}
33503353
}
33513354

@@ -3405,6 +3408,8 @@ struct PyAgentDefinition {
34053408
prompt: Option<String>,
34063409
#[pyo3(get)]
34073410
max_steps: Option<usize>,
3411+
#[pyo3(get)]
3412+
confirmation_inheritance: Option<String>,
34083413
}
34093414

34103415
#[pymethods]
@@ -3450,9 +3455,38 @@ fn py_worker_agent_spec_to_rust(spec: PyWorkerAgentSpec) -> PyResult<RustWorkerA
34503455
if let Some(max_steps) = spec.max_steps {
34513456
worker = worker.with_max_steps(max_steps);
34523457
}
3458+
if let Some(ci) = spec.confirmation_inheritance {
3459+
worker = worker.with_confirmation(parse_py_confirmation_inheritance(&ci)?);
3460+
}
34533461
Ok(worker)
34543462
}
34553463

3464+
fn parse_py_confirmation_inheritance(
3465+
value: &str,
3466+
) -> PyResult<a3s_code_core::subagent::ConfirmationInheritance> {
3467+
use a3s_code_core::subagent::ConfirmationInheritance;
3468+
match value {
3469+
"auto_approve" => Ok(ConfirmationInheritance::AutoApprove),
3470+
"deny_on_ask" => Ok(ConfirmationInheritance::DenyOnAsk),
3471+
"inherit_parent" => Ok(ConfirmationInheritance::InheritParent),
3472+
other => Err(PyValueError::new_err(format!(
3473+
"invalid confirmation_inheritance: '{}' (expected: auto_approve, deny_on_ask, inherit_parent)",
3474+
other
3475+
))),
3476+
}
3477+
}
3478+
3479+
fn confirmation_inheritance_to_py(
3480+
ci: &a3s_code_core::subagent::ConfirmationInheritance,
3481+
) -> String {
3482+
use a3s_code_core::subagent::ConfirmationInheritance;
3483+
match ci {
3484+
ConfirmationInheritance::AutoApprove => "auto_approve".to_string(),
3485+
ConfirmationInheritance::DenyOnAsk => "deny_on_ask".to_string(),
3486+
ConfirmationInheritance::InheritParent => "inherit_parent".to_string(),
3487+
}
3488+
}
3489+
34563490
fn rust_agent_definition_to_py(def: RustAgentDefinition) -> PyAgentDefinition {
34573491
PyAgentDefinition {
34583492
name: def.name,
@@ -3462,6 +3496,10 @@ fn rust_agent_definition_to_py(def: RustAgentDefinition) -> PyAgentDefinition {
34623496
model: def.model.map(|model| model.model_ref()),
34633497
prompt: def.prompt,
34643498
max_steps: def.max_steps,
3499+
confirmation_inheritance: def
3500+
.confirmation_inheritance
3501+
.as_ref()
3502+
.map(confirmation_inheritance_to_py),
34653503
}
34663504
}
34673505

0 commit comments

Comments
 (0)