⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
fix(runner): pass the effective timeout to agent commands (#530)
TXyy2023dd12d7822a10
diff --git a/packages/runner/README.md b/packages/runner/README.mdindex 15bc529f..f30b6038 100644--- a/packages/runner/README.md+++ b/packages/runner/README.md@@ -206,6 +206,12 @@ Every run holds these variables:| `ITSAPLAN_API_KEY` | the agent's key, for the API and the MCP server || `ITSAPLAN_TRIGGER` | `mention`, `delegation`, `field`, `schedule`, `manual`, `status`, or `chat` || `ITSAPLAN_SYSTEM_PROMPT` | the context of the run, for a command that takes a system prompt |+| `ITSAPLAN_TIMEOUT_MS` | the effective task timeout in milliseconds, including per-agent overrides |++Custom commands can read `ITSAPLAN_TIMEOUT_MS` to configure their own execution timeout.+The runner supplies the resolved `timeoutMs`, overriding any inherited value or value in+`env`. Its timer starts when the command is spawned, so startup and waiting inside the+command count toward the same limit.A queued run adds three more:diff --git a/packages/runner/src/__tests__/execute.test.ts b/packages/runner/src/__tests__/execute.test.tsnew file mode 100644index 00000000..ed9e7686--- /dev/null+++ b/packages/runner/src/__tests__/execute.test.ts@@ -0,0 +1,37 @@+import { describe, it, expect } from 'bun:test';+import { mkdtemp, rm, writeFile } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { loadConfig } from '../config';+import { execute } from '../execute';++describe('command timeout environment', () => {+ it('passes the resolved timeout to each command, including per-agent overrides', async () => {+ const dir = await mkdtemp(join(tmpdir(), 'itsaplan-timeout-'));+ try {+ const path = join(dir, 'runner.json');+ await writeFile(+ path,+ JSON.stringify({+ url: 'http://localhost:3000',+ command: 'printf \'%s\' "$ITSAPLAN_TIMEOUT_MS"',+ timeoutMs: 10800000,+ env: { ITSAPLAN_TIMEOUT_MS: '1500000' },+ agents: [{ apiKey: 'first' }, { apiKey: 'second', timeoutMs: 60000 }],+ }),+ );+ const configs = await loadConfig(path);+ for (const config of configs) {+ const result = await execute(config, {+ prompt: '',+ systemPrompt: '',+ env: { ITSAPLAN_TIMEOUT_MS: '1' },+ });+ expect(result).toEqual({ status: 'success', output: String(config.timeoutMs) });+ }+ expect(configs.map((config) => config.timeoutMs)).toEqual([10800000, 60000]);+ } finally {+ await rm(dir, { recursive: true, force: true });+ }+ });+});diff --git a/packages/runner/src/execute.ts b/packages/runner/src/execute.tsindex 723695d0..d850c699 100644--- a/packages/runner/src/execute.ts+++ b/packages/runner/src/execute.ts@@ -42,6 +42,7 @@ function childEnv(config: RunnerConfig, task: Task): Record<string, string> {ITSAPLAN_URL: config.url,ITSAPLAN_API_KEY: config.apiKey,...task.env,+ ITSAPLAN_TIMEOUT_MS: String(config.timeoutMs),};}