Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(mcp-host): treat every non-channel task as unattended (n6.3)

Andy Pavia511f01239a91
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index db06dfb96..1a9181a97 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.264",
+ "version": "0.1.265",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.264",
+ "version": "0.1.265",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index ec90473ca..32ad1aefd 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.264",
+ "version": "0.1.265",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/agent/__tests__/taskExecutor.test.ts b/mcp-host/src/agent/__tests__/taskExecutor.test.ts
index 9c9ed0d3f..51f2f82b5 100644
--- a/mcp-host/src/agent/__tests__/taskExecutor.test.ts
+++ b/mcp-host/src/agent/__tests__/taskExecutor.test.ts
@@ -10,9 +10,9 @@ import {
} from '../../core/tools/workflowEffectiveTargets'
import type { Attachment, ChatMessage, MessageContentPart, TraceContextV1 } from '../../core/types'
import { TaskLifecycle } from '../../lifecycle/taskLifecycle'
-import type { Task, TaskError } from '../../queue/types'
+import type { Task, TaskError, TaskSource } from '../../queue/types'
import { resolveProviderWorkflowCallerContext } from '../../workflow/providerWorkflowCallerContextClient'
-import { TaskExecutor, type TaskExecutorDeps } from '../taskExecutor'
+import { TaskExecutor, type TaskExecutorDeps, executionModeForSource } from '../taskExecutor'
vi.mock('../../config', () => ({
config: {
@@ -1470,3 +1470,25 @@ describe('D3 durability barrier — a turn is never ACKed when the persist fails
expect(deps.onFail).toHaveBeenCalledTimes(1)
})
})
+
+describe('executionModeForSource (§6.3)', () => {
+ it('treats channel tasks as interactive — a person sent the message', () => {
+ expect(executionModeForSource('channel')).toBe('interactive')
+ })
+
+ it.each(['cron', 'internal'] as const)(
+ 'treats %s tasks as unattended so a guardrail ask fails safe to deny',
+ source => {
+ expect(executionModeForSource(source)).toBe('unattended')
+ }
+ )
+
+ // The regression: `internal` fell through to 'interactive', so an `ask` took the
+ // suspension path and parked in pending_approval with no responder — the task
+ // hung. Not reachable today (createInternalTask has no production caller), which
+ // is exactly why the mapping needs pinning rather than the behaviour.
+ it('never labels an autonomous source interactive', () => {
+ const autonomous: TaskSource[] = ['cron', 'internal']
+ expect(autonomous.map(executionModeForSource)).not.toContain('interactive')
+ })
+})
diff --git a/mcp-host/src/agent/taskExecutor.ts b/mcp-host/src/agent/taskExecutor.ts
index ddaaa086d..9e6b8a82e 100644
--- a/mcp-host/src/agent/taskExecutor.ts
+++ b/mcp-host/src/agent/taskExecutor.ts
@@ -86,7 +86,7 @@ import {
ensureReporter,
progressReporterRegistry,
} from '../progress/sseProgressReporter.js'
-import type { Task, TaskError } from '../queue/types'
+import type { Task, TaskError, TaskSource } from '../queue/types'
import { resolveCronTaskSessionKey, serializeSessionKey } from '../session'
import { GovernedRunReporter, UsageReporter } from '../usage/usageReporter.js'
import { resolveProviderWorkflowCallerContext } from '../workflow/providerWorkflowCallerContextClient'
@@ -124,6 +124,24 @@ export function resolveTaskSessionKey(task: Task): string {
)
}
+/**
+ * §6.3 — is there a human who can answer a guardrail `ask` in this run?
+ *
+ * Only `channel` tasks have one: a person is on the other end of the message that
+ * started them (including channelType `rpc`, the Desktop App). `cron` fires on a
+ * schedule and `internal` is a system-generated task with no requester, so an
+ * `ask` there would suspend into `pending_approval` with nobody able to respond —
+ * the task hangs. Unattended turns that into the fail-safe deny instead.
+ *
+ * Deliberately an allowlist of the attended source, not a denylist of the
+ * autonomous ones: a source added later defaults to "assume nobody is watching",
+ * which fails closed. The previous `source === 'cron' ? ... : 'interactive'` had
+ * the opposite default and already mislabelled `internal`.
+ */
+export function executionModeForSource(source: TaskSource): 'interactive' | 'unattended' {
+ return source === 'channel' ? 'interactive' : 'unattended'
+}
+
export interface TaskExecutorDeps {
conversationManager: ConversationManager
llmProvider: SingleTurnProvider
@@ -1198,9 +1216,8 @@ export class TaskExecutor {
// Undefined when no rules are configured (no-config compatibility, §5); a
// malformed set throws here (fail-closed admission, §3/§5).
loopConfig.guardrails = buildToolLaneGuardrail(this.deps.guardrailsConfig)
- // §6.3: cron/autonomous tasks have no human to answer an approval, so a
- // guardrail `ask` there fails safe to deny.
- loopConfig.executionMode = this.task.source === 'cron' ? 'unattended' : 'interactive'
+ // §6.3: a run with no human to answer an approval must fail safe to deny.
+ loopConfig.executionMode = executionModeForSource(this.task.source)
loopConfig.skipContextManager =
opts?.skipContextManager ?? this.conversation?.pending_approval !== undefined
// T1.5 — pass the storage + taskId down so `executeSingleTool` can persist