Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions .agents/skills/contribute-adapter/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ release. Public existence alone cannot verify trusted publishing. If the PR
check reports HTTP 404, ask an authorized npm maintainer to bootstrap the exact
manifest name, then rerun the check. Do not add CI write tokens or manually
publish supported versions.


For execution deadline failures, normalize target-native errors to canonical `timeout` at the adapter boundary. Retain the owning layer, enforced limit or absolute deadline, and stable native cause in lifecycle error metadata or normalized error extensions. Keep startup, shutdown, transport, and configuration failures distinct; consumer bridges must not contain harness-specific timeout code tables.
1 change: 1 addition & 0 deletions .agents/skills/validate-change/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ surfaces touched by a change.
- **Adapter behavior changed**
Run the focused adapter tests under `tests/adapters`, then `just test-python`.
- **Harbor integration changed**
For deadline changes, test runtime-owned and adapter-normalized invocation deadlines, genuine outer expiration, and setup/transport failures with cleanup and verifier invocation counts. Verify Harbor phase ownership separately when its upstream fix is an external dependency; do not claim an unpatched Harbor summary preserves nested deadlines.
Use `qualify-harbor` for real inference and container checks across the adapter catalog or a developer subset. Retain its complete catalog report; deterministic tests alone do not establish an all-harness integration pass.
Run `tests/integrations/test_harbor_runner.py`,
`tests/integrations/test_harbor_model_config.py`, and
Expand Down
7 changes: 6 additions & 1 deletion adapters/typescript/kilo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ authentication and per-server tool filters are unsupported.
The adapter accepts plain-text input and returns the terminal assistant text in
`output.response`. Ordered invocations reuse one warm Kilo Code session and its
conversation history. A prompt has a 30-minute deadline; on timeout the adapter
asks Kilo Code to abort the prompt and reports `kilo_prompt_timeout`.
asks Kilo Code to abort the prompt and reports `timeout`, retaining `kilo_prompt_timeout` as the cause.

The adapter disables project Kilo Code configuration and uses temporary Kilo
and XDG directories. The child process receives required operating-system
Expand Down Expand Up @@ -155,3 +155,8 @@ credentials, or MCP connectivity. Checks never send prompts or abort a turn.
At most one native health request remains outstanding after a caller timeout.

Refer to the [SDK health-check overview](../../../docs/sdk/health-checks.mdx) for shared behavior and a comparison of native evidence across adapters.


## Invocation deadlines

Kilo 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.
22 changes: 22 additions & 0 deletions adapters/typescript/kilo/kilo.fabric-adapter.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@
"additionalProperties": false
},
"extension_schemas": {
"run_error": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"owner": {
"const": "adapter"
},
"timeout_seconds": {
"type": "number",
"minimum": 0
},
"cause_code": {
"const": "kilo_prompt_timeout"
}
},
"required": [
"owner",
"timeout_seconds",
"cause_code"
],
"additionalProperties": false
},
"usage": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
Expand Down
10 changes: 9 additions & 1 deletion adapters/typescript/kilo/src/kilo-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,15 @@ class KiloSdkSessionHandle implements KiloSessionHandle {
} catch {
if (timedOut) {
await abortPromise;
throw new LifecycleError("kilo_prompt_timeout", "Timed out while waiting for Kilo Code to complete the prompt", {retryable: false});
throw new LifecycleError(
"timeout",
`Kilo adapter invocation timed out after ${this.promptTimeoutMs / 1000} seconds`,
{metadata: {
owner: "adapter",
timeout_seconds: this.promptTimeoutMs / 1000,
cause_code: "kilo_prompt_timeout",
}},
);
}
throw new LifecycleError("kilo_session_failed", "Kilo Code session communication failed", {retryable: false});
} finally {
Expand Down
9 changes: 5 additions & 4 deletions adapters/typescript/kilo/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
AgentRunRequest,
AgentRunResult,
AgentUsage,
JsonObject,
RuntimeContext,
} from "nemo-fabric-adapter-contract";
import {
Expand All @@ -19,16 +20,16 @@ import {
/** Failed communication retains its usage snapshot while the session is retired. */
export class KiloPromptError extends LifecycleError {
constructor(error: LifecycleError, readonly usage: AgentUsage) {
super(error.code, error.message, { retryable: error.retryable });
super(error.code, error.message, { retryable: error.retryable, metadata: error.metadata });
}
}

export interface KiloPromptOutcome { text?: string; error?: boolean; usage?: AgentUsage; messageId?: string }
export interface KiloSessionHandle { id: string; check(level: CheckLevel): Promise<AdapterCheckResult>; prompt(text: string, deadlineMillis?: number): Promise<KiloPromptOutcome>; stop(): Promise<void> }
export interface KiloSessionFactory { create(input: AdapterStartInput): Promise<KiloSessionHandle> }

function failed(code: string, message: string, usage?: AgentUsage): AgentRunResult {
return {status: "failed", output: null, error: {code, message, retryable: false}, ...(usage === undefined ? {} : {usage})};
function failed(code: string, message: string, usage?: AgentUsage, metadata?: JsonObject): AgentRunResult {
return {status: "failed", output: null, error: {code, message, retryable: false, ...(metadata === undefined ? {} : {extensions: metadata})}, ...(usage === undefined ? {} : {usage})};
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

export class KiloAdapterRuntime implements AdapterRuntime {
Expand Down Expand Up @@ -57,7 +58,7 @@ export class KiloAdapterRuntime implements AdapterRuntime {
this.generation += 1;
this.session = undefined;
try { await session.stop(); } catch { /* Preserve the prompt failure. */ }
if (error instanceof KiloPromptError) return failed(error.code, error.message, error.usage);
if (error instanceof KiloPromptError) return failed(error.code, error.message, error.usage, error.metadata);
if (error instanceof LifecycleError) throw error;
throw new LifecycleError("kilo_session_failed", "Kilo Code session communication failed", {retryable: true});
} finally {
Expand Down
10 changes: 8 additions & 2 deletions adapters/typescript/kilo/test/kilo-sdk.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ test("aborts the Kilo session when a prompt reaches its deadline", async () => {
},
},
});
await assert.rejects(handle.prompt("wait forever"), (error) => error.code === "kilo_prompt_timeout");
await assert.rejects(handle.prompt("wait forever"), {
code: "timeout",
metadata: {owner: "adapter", timeout_seconds: 0, cause_code: "kilo_prompt_timeout"},
});
assert.equal(promptSignal.aborted, true);
assert.deepEqual(abortParameters, {sessionID: "session-timeout", directory: workspace});
assert.ok(abortSignal instanceof AbortSignal);
Expand Down Expand Up @@ -338,7 +341,10 @@ for (const phase of ["headers", "body"]) {
});
const prompting = handle.prompt("wait for the result");
if (expire) {
const rejected = assert.rejects(prompting, (error) => error.code === "kilo_prompt_timeout");
const rejected = assert.rejects(prompting, {
code: "timeout",
metadata: {owner: "adapter", timeout_seconds: 0.5, cause_code: "kilo_prompt_timeout"},
});
await requestReady;
await rejected;
await Promise.all([sessionAborted, requestClosed]);
Expand Down
23 changes: 22 additions & 1 deletion adapters/typescript/kilo/test/runtime.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import assert from "node:assert/strict";
import test from "node:test";

import {KiloAdapterRuntime} from "../dist/runtime.js";
import {KiloAdapterRuntime, KiloPromptError} from "../dist/runtime.js";
import {LifecycleError} from "nemo-fabric-adapters-common";

const context = {runtime_id: "r", invocation_id: "i", request_id: "q", artifacts: {}, environment: {environment_id: "e", provider: "local", ownership: "caller_owned", control_location: "external_control", env: {}}};

Expand Down Expand Up @@ -36,3 +37,23 @@ test("invalidates the runtime after transport failure", async () => {
await assert.rejects(runtime.invoke({input: "two"}, context), (error) => error.code === "kilo_not_started");
assert.equal(stopped, 1);
});


test("preserves deadline ownership and usage through normalized failure and cleanup", async () => {
const metadata = {owner: "adapter", timeout_seconds: 300, cause_code: "kilo_prompt_timeout"};
const usage = {input_tokens: 1, output_tokens: 2};
let stopped = 0;
const runtime = new KiloAdapterRuntime({create: async () => ({
id: "s",
prompt: async () => { throw new KiloPromptError(new LifecycleError("timeout", "Kilo deadline after 300 seconds", {metadata}), usage); },
stop: async () => { stopped += 1; },
})});
await runtime.start({agentName: "agent", baseDir: ".", config: {}, runtimeContext: context});
const result = await runtime.invoke({input: "test"}, context);
assert.equal(result.error.code, "timeout");
assert.deepEqual(result.error.extensions, metadata);
assert.deepEqual(result.usage, usage);
assert.equal(stopped, 1);
await runtime.stop();
assert.equal(stopped, 1);
});
5 changes: 5 additions & 0 deletions adapters/typescript/kiro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ live, and a stopped or exited process fails the liveness observation.
`active` and `ready` are unsupported. Checks do not send prompts, change session settings, or cancel invocations.

Refer to the [SDK health-check overview](../../../docs/sdk/health-checks.mdx) for shared behavior and a comparison of native evidence across adapters.


## 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.
22 changes: 22 additions & 0 deletions adapters/typescript/kiro/kiro.fabric-adapter.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@
"additionalProperties": false
},
"extension_schemas": {
"run_error": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"owner": {
"const": "adapter"
},
"deadline_millis": {
"type": "integer",
"minimum": 0
},
"cause_code": {
"const": "kiro_deadline_exceeded"
}
},
"required": [
"owner",
"deadline_millis",
"cause_code"
],
"additionalProperties": false
},
"run_result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
Expand Down
17 changes: 13 additions & 4 deletions adapters/typescript/kiro/src/kiro-acp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function childEnvironment(input: AdapterStartInput): NodeJS.ProcessEnv {
return environment;
}

function translateRunnerError(error: AcpRunnerError, stage: "start" | "prompt"): LifecycleError {
function translateRunnerError(error: AcpRunnerError, stage: "start" | "prompt", timeoutMs = 300_000): LifecycleError {
if (error.code === "acp_process_unavailable") {
return new LifecycleError("kiro_harness_unavailable", "The installed Kiro CLI could not be started");
}
Expand All @@ -78,7 +78,16 @@ function translateRunnerError(error: AcpRunnerError, stage: "start" | "prompt"):
);
}
if (error.code === "acp_prompt_timeout") {
return new LifecycleError("kiro_prompt_timeout", "Kiro did not finish the invocation before the deadline");
return new LifecycleError(
"timeout",
`Kiro adapter invocation timed out after ${timeoutMs / 1000} seconds`,
{ metadata: {
owner: "adapter",
timeout_seconds: timeoutMs / 1000,
cause_code: "kiro_prompt_timeout",
native_code: error.code,
} },
);
}
return new LifecycleError(
stage === "start" ? "kiro_start_failed" : "kiro_session_failed",
Expand Down Expand Up @@ -185,12 +194,12 @@ class KiroAcpSession implements KiroSessionHandle {
};
}

async prompt(text: string, timeoutMs?: number): Promise<KiroPromptOutcome> {
async prompt(text: string, timeoutMs = 300_000): Promise<KiroPromptOutcome> {
let result: AcpPromptResult;
try {
result = await this.session.prompt(text, timeoutMs);
} catch (error) {
if (error instanceof AcpRunnerError) throw translateRunnerError(error, "prompt");
if (error instanceof AcpRunnerError) throw translateRunnerError(error, "prompt", timeoutMs);
throw new LifecycleError("kiro_session_failed", "Kiro ACP session communication failed");
}
let usage: AgentUsage | undefined;
Expand Down
9 changes: 7 additions & 2 deletions adapters/typescript/kiro/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@ export class KiroAdapterRuntime implements AdapterRuntime {
status: "failed",
output: null,
error: {
code: "kiro_deadline_exceeded",
message: "The Kiro invocation deadline has already elapsed",
code: "timeout",
message: `Kiro adapter invocation deadline ${context.deadline_millis} (Unix milliseconds) has already elapsed`,
retryable: false,
extensions: {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
owner: "adapter",
deadline_millis: context.deadline_millis,
cause_code: "kiro_deadline_exceeded",
},
},
};
}
Expand Down
Loading
Loading