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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ NeMo Fabric separates consumers from execution targets through a stable, version
Planned areas of development include:

- **Refine runtime resource measurements:** Improve CPU, memory, elapsed-time, and available GPU measurements through broader benchmark validation.
- **Support long-running, artifact-heavy workloads:** Make OpenShell timeouts and response/artifact limits configurable, including unlimited task duration, with clear limit errors and guidance for retrieving large screenshots.
- **Support artifact-heavy workloads:** Make response and artifact limits configurable, with clear limit errors and guidance for retrieving large screenshots.
- **Expose task progress and recoverable results:** Provide task state, step progress, plans, pending requests, sandbox task listings, and paginated events, with final results retrievable after invocation ends or the caller disconnects.
- **Standardize model usage accounting:** Report input, cached, output, and reasoning tokens consistently, distinguish complete, partial, and unknown usage, and attribute delegated work to the correct invocation.
- **Capture execution provenance:** Record NeMo Fabric and adapter versions, requested models, sanitized MCP configuration, and execution environment, with explicit sources and unknowns.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
"description": "Artifact manifest visible to the adapter at invocation start."
},
"deadline_millis": {
"description": "Unix time in milliseconds by which the adapter should return its result.\nPresent on every invocation, shortly before Fabric's own invocation timeout.",
"description": "Unix time in milliseconds by which the adapter should return its result.\nPresent when runtime.timeout_seconds is set, shortly before Fabric's invocation timeout.",
"format": "uint64",
"minimum": 0,
"type": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface RuntimeContext {
artifacts: ArtifactManifest;
/**
* Unix time in milliseconds by which the adapter should return its result.
* Present on every invocation, shortly before Fabric's own invocation timeout.
* Present when runtime.timeout_seconds is set, shortly before Fabric's invocation timeout.
*/
deadline_millis?: number | null;
environment: EnvironmentHandle;
Expand Down
6 changes: 4 additions & 2 deletions adapters/typescript/common/src/acp-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export interface AcpSession {
readonly sessionId: string;
readonly initializeResponse: InitializeResponse;
observeProcess(): { alive: boolean };
prompt(text: string, timeoutMs?: number): Promise<AcpPromptResult>;
// Pass null to disable the prompt deadline; omission uses the session default.
prompt(text: string, timeoutMs?: number | null): Promise<AcpPromptResult>;
stop(): Promise<void>;
}

Expand Down Expand Up @@ -258,7 +259,7 @@ class SpawnedAcpSession implements AcpSession {
this.child.signalCode === null,
};
}
async prompt(text: string, timeoutMs = this.promptTimeoutMs): Promise<AcpPromptResult> {
async prompt(text: string, timeoutMs: number | null = this.promptTimeoutMs): Promise<AcpPromptResult> {
if (this.stopped) {
throw new AcpRunnerError("acp_session_stopped", "The ACP session is already stopped");
}
Expand All @@ -272,6 +273,7 @@ class SpawnedAcpSession implements AcpSession {
};
};
try {
if (timeoutMs === null) return await exchange();
return await timeout(
exchange(),
timeoutMs,
Expand Down
16 changes: 16 additions & 0 deletions adapters/typescript/common/test/acp-runner.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ import { AcpRunnerError, startAcpSession } from "../dist/index.js";

const fixture = fileURLToPath(new URL("./fixtures/acp-agent.mjs", import.meta.url));

test("an explicit null prompt deadline disables the configured session cap", async () => {
const session = await startAcpSession({
command: process.execPath,
args: [fixture],
cwd: process.cwd(),
env: { ...process.env, TEST_PROMPT_DELAY_MS: "50" },
promptTimeoutMs: 1,
});
try {
assert.ok((await session.prompt("uncapped", null)).text.startsWith("uncapped:"));
await assert.rejects(session.prompt("hang"), { code: "acp_prompt_timeout" });
} finally {
await session.stop();
}
});

test("runs two turns through one ACP session with negotiated settings", async () => {
const session = await startAcpSession({
command: process.execPath,
Expand Down
2 changes: 2 additions & 0 deletions adapters/typescript/kiro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ Refer to the [SDK health-check overview](../../../docs/sdk/health-checks.mdx) fo
## Invocation deadlines

Kiro invocation deadlines use canonical error code `timeout`. Error metadata retains `owner: "adapter"`, the native cause, and the enforced timeout in seconds or absolute `deadline_millis`. Setup and transport failures retain their existing classifications.

When `runtime.timeout_seconds` is omitted or null, NeMo Fabric does not impose a total prompt deadline. An explicit invocation deadline is forwarded to the ACP session; startup and shutdown remain separately bounded.
4 changes: 2 additions & 2 deletions adapters/typescript/kiro/src/kiro-acp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ class KiroAcpSession implements KiroSessionHandle {
};
}

async prompt(text: string, timeoutMs = 300_000): Promise<KiroPromptOutcome> {
async prompt(text: string, timeoutMs?: number): Promise<KiroPromptOutcome> {
let result: AcpPromptResult;
try {
result = await this.session.prompt(text, timeoutMs);
result = await this.session.prompt(text, timeoutMs ?? null);
} catch (error) {
if (error instanceof AcpRunnerError) throw translateRunnerError(error, "prompt", timeoutMs);
throw new LifecycleError("kiro_session_failed", "Kiro ACP session communication failed");
Expand Down
10 changes: 9 additions & 1 deletion adapters/typescript/kiro/test/kiro-acp.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { KiroAcpSessionFactory } from "../dist/kiro-acp.js";

for (const fixtureType of process.platform === "win32" ? ["executable"] : ["shell", "executable"]) {
for (const terminalState of ["timeout", "native exit"]) {
test(`runs a persistent Kiro-compatible ACP session with a ${fixtureType} fixture ending in ${terminalState}`, async () => {
test(`runs a persistent Kiro-compatible ACP session with a ${fixtureType} fixture ending in ${terminalState}`, async (t) => {
const bin = await mkdtemp(join(tmpdir(), "fabric-kiro-bin-"));
const executable = join(bin, process.platform === "win32" ? "kiro-cli.exe" : "kiro-cli");
if (fixtureType === "executable") {
Expand Down Expand Up @@ -63,6 +63,12 @@ for (const fixtureType of process.platform === "win32" ? ["executable"] : ["shel
assert.equal((await session.check("live")).outcome, "passed");
assert.equal((await session.check("active")).outcome, "unsupported");
assert.equal((await session.check("ready")).outcome, "unsupported");
const scheduled = [];
const originalSetTimeout = globalThis.setTimeout;
const timer = t.mock.method(globalThis, "setTimeout", (callback, milliseconds, ...args) => {
scheduled.push(milliseconds);
return originalSetTimeout(callback, milliseconds, ...args);
});
const firstPending = session.prompt("one");
const deadline = Date.now() + 2000;
while (true) {
Expand All @@ -72,6 +78,8 @@ for (const fixtureType of process.platform === "win32" ? ["executable"] : ["shel
}
assert.equal((await session.check("live")).outcome, "passed");
const first = await firstPending;
timer.mock.restore();
assert.ok(!scheduled.includes(300_000), "an omitted deadline must not schedule the former five-minute cap");
assert.equal((await session.check("live")).outcome, "passed");
const second = await session.prompt("permission");
assert.equal(first.text, "one:1:plan:model-b:high:mcp=0:permission=none:ready=false");
Expand Down
2 changes: 2 additions & 0 deletions adapters/typescript/strands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@ Refer to the [SDK health-check overview](../../../docs/sdk/health-checks.mdx) fo
## Invocation deadlines

Strands prompt deadlines and already-expired invocation deadlines use canonical error code `timeout`. Error metadata retains `owner: "adapter"` and the native cause (`strands_prompt_timeout` or `strands_deadline_exceeded`), plus the enforced timeout in seconds or the absolute `deadline_millis`. Prompt expiration invalidates the session and attempts process cleanup. Startup and transport failures keep their existing error classifications.

When `runtime.timeout_seconds` is omitted or null, NeMo Fabric does not impose a total prompt deadline. An explicit invocation deadline is forwarded to the ACP session; startup and shutdown remain separately bounded.
4 changes: 2 additions & 2 deletions adapters/typescript/strands/src/strands-acp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ class StrandsAcpSession implements StrandsSessionHandle {

async prompt(
text: string,
timeoutMs = 300_000,
timeoutMs?: number,
): Promise<StrandsPromptOutcome> {
try {
const result = await this.session.prompt(text, timeoutMs);
const result = await this.session.prompt(text, timeoutMs ?? null);
const usage = normalizeUsage(result.usage);
return {
text: result.text,
Expand Down
8 changes: 8 additions & 0 deletions adapters/typescript/strands/test/strands-acp.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ test("preserves real ACP session history, isolates runtime state, and uses per-i
assert.ok(state.args.includes("litellm/local"));
assert.ok(state.args.includes("--instructions=--instruction-text"));
assert.ok(state.args.includes("agentConfig.backgroundTasks=false"));
const scheduled = [];
const originalSetTimeout = globalThis.setTimeout;
const timer = t.mock.method(globalThis, "setTimeout", (callback, milliseconds, ...args) => {
scheduled.push(milliseconds);
return originalSetTimeout(callback, milliseconds, ...args);
});
const one = await first.prompt("secret-token");
timer.mock.restore();
assert.ok(!scheduled.includes(300_000), "an omitted deadline must not schedule the former five-minute cap");
const two = await first.prompt("recall");
assert.equal(two.text, "secret-token");
assert.equal(one.usage.input_tokens, 11);
Expand Down
2 changes: 1 addition & 1 deletion crates/fabric-core/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ fn probe_remote(
let response = crate::environment::command_runtime(
environment,
&command,
remaining.ceil().clamp(1.0, 320.0) as u64,
Some(remaining.ceil().clamp(1.0, 320.0) as u64),
);
let mut report = match response {
Ok(crate::task_command::TaskCommandResponse::Returned { value }) => {
Expand Down
66 changes: 51 additions & 15 deletions crates/fabric-core/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub(crate) fn release_environment(
pub(crate) fn command_runtime(
environment: &EnvironmentHandle,
command: &TaskCommand,
timeout_seconds: u64,
timeout_seconds: Option<u64>,
) -> Result<TaskCommandResponse> {
if environment.provider != OPEN_SHELL_PROVIDER_ID {
return Err(FabricError::UnsupportedEnvironmentProvider {
Expand Down Expand Up @@ -400,7 +400,10 @@ where
"could not write the bounded provider request".to_string(),
);
}
let output = match process.responses.recv_timeout(response_timeout) {
let output = match process
.responses
.recv_timeout(response_timeout.expect("bounded environment operation"))
{
Ok(Ok(output)) => output,
Ok(Err(_)) => {
process.shutdown();
Expand Down Expand Up @@ -715,7 +718,14 @@ where
"could not write the bounded provider request".to_string(),
)
})?;
match process_guard.responses.recv_timeout(response_timeout) {
let received = match response_timeout {
Some(timeout) => process_guard.responses.recv_timeout(timeout),
None => process_guard
.responses
.recv()
.map_err(|_| RecvTimeoutError::Disconnected),
};
match received {
Ok(Ok(output)) => Ok(output),
Ok(Err(_)) => Err(provider_failure(
operation_name,
Expand Down Expand Up @@ -1224,7 +1234,7 @@ enum ProviderOperation<'a> {
RuntimeCommand {
environment: &'a EnvironmentHandle,
command: &'a TaskCommand,
timeout_seconds: u64,
timeout_seconds: Option<u64>,
},
CollectArtifacts {
environment: &'a EnvironmentHandle,
Expand All @@ -1246,7 +1256,7 @@ impl ProviderOperation<'_> {
}
}

fn response_timeout(&self) -> Duration {
fn response_timeout(&self) -> Option<Duration> {
let operation_seconds = match self {
Self::Prepare { environment, .. } => readiness_seconds(environment, true)
.saturating_add(setting_seconds(
Expand All @@ -1259,7 +1269,9 @@ impl ProviderOperation<'_> {
.saturating_add(3 * PROVIDER_GATEWAY_CALL_TIMEOUT_SECONDS),
Self::RuntimeCommand {
timeout_seconds, ..
} => timeout_seconds.saturating_add(2 * PROVIDER_GATEWAY_CALL_TIMEOUT_SECONDS),
} => timeout_seconds
.as_ref()?
.saturating_add(2 * PROVIDER_GATEWAY_CALL_TIMEOUT_SECONDS),
Self::CollectArtifacts { .. } => 30 + 2 * PROVIDER_GATEWAY_CALL_TIMEOUT_SECONDS,
Self::Release { environment } => connection_seconds(
&environment.connection,
Expand All @@ -1268,7 +1280,9 @@ impl ProviderOperation<'_> {
)
.saturating_add(3 * PROVIDER_GATEWAY_CALL_TIMEOUT_SECONDS),
};
Duration::from_secs(operation_seconds.saturating_add(PROVIDER_RESPONSE_GRACE_SECONDS))
Some(Duration::from_secs(
operation_seconds.saturating_add(PROVIDER_RESPONSE_GRACE_SECONDS),
))
}
}

Expand Down Expand Up @@ -1364,7 +1378,10 @@ mod tests {
environment: &environment,
};

assert_eq!(operation.response_timeout(), Duration::from_secs(285));
assert_eq!(
operation.response_timeout().expect("finite timeout"),
Duration::from_secs(285)
);
}

#[test]
Expand Down Expand Up @@ -1394,13 +1411,19 @@ mod tests {
environment: &environment,
reference: &reference,
};
assert_eq!(attach.response_timeout(), Duration::from_secs(465));
assert_eq!(
attach.response_timeout().expect("finite timeout"),
Duration::from_secs(465)
);

let prepare = ProviderOperation::Prepare {
environment_id: "environment-test",
environment: &environment,
};
assert_eq!(prepare.response_timeout(), Duration::from_secs(765));
assert_eq!(
prepare.response_timeout().expect("finite timeout"),
Duration::from_secs(765)
);
}

#[test]
Expand All @@ -1423,16 +1446,29 @@ mod tests {
let runtime = ProviderOperation::RuntimeCommand {
environment: &environment,
command: &command,
timeout_seconds: 315,
timeout_seconds: Some(315),
};
assert_eq!(
runtime.response_timeout().expect("finite timeout"),
Duration::from_secs(390)
);

let unlimited = ProviderOperation::RuntimeCommand {
environment: &environment,
command: &command,
timeout_seconds: None,
};
assert_eq!(runtime.response_timeout(), Duration::from_secs(390));
assert_eq!(unlimited.response_timeout(), None);

let paths = Vec::new();
let artifacts = ProviderOperation::CollectArtifacts {
environment: &environment,
paths: &paths,
};
assert_eq!(artifacts.response_timeout(), Duration::from_secs(105));
assert_eq!(
artifacts.response_timeout().expect("finite timeout"),
Duration::from_secs(105)
);
}

fn provider_script(body: &str) -> (PathBuf, OsString) {
Expand Down Expand Up @@ -1516,7 +1552,7 @@ for line in sys.stdin:
ProviderOperation::RuntimeCommand {
environment: &environment,
command: &task,
timeout_seconds: 10,
timeout_seconds: Some(10),
},
);
sender.send(result).unwrap();
Expand Down Expand Up @@ -1595,7 +1631,7 @@ else:
ProviderOperation::RuntimeCommand {
environment: &environment,
command: &task,
timeout_seconds: 1,
timeout_seconds: Some(1),
},
timeout_seconds,
);
Expand Down
Loading
Loading