Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): default Codex tool presentation to direct
Alfredo Lopezb8c9cd6ab3d0
diff --git a/docs/architecture/codex-subscription-transport-contract.md b/docs/architecture/codex-subscription-transport-contract.mdindex 86e3e24a2..b70a57d4e 100644--- a/docs/architecture/codex-subscription-transport-contract.md+++ b/docs/architecture/codex-subscription-transport-contract.md@@ -174,9 +174,12 @@ the grant; revoke of one key fail-closes only that assignment.## Tool presentation in the agent`CODEX_TOOL_PRESENTATION=auto|direct|discovery` controls presentation, not access.-Auto is the default when the primary or an allowed fallback uses Codex: it-uses discovery above the existing `CLERUM_DYNAMIC_TOOLS_THRESHOLD` (60) or-`CODEX_TOOL_DISCOVERY_BYTES` (32768 serialized MCP definition bytes). These+Direct is the default when the primary or an allowed fallback uses Codex. It+presents all approved definitions without the search/describe/call discovery bridge,+regardless of the discovery thresholds or legacy dynamic-tools flag.+Explicitly selecting auto uses discovery above the existing+`CLERUM_DYNAMIC_TOOLS_THRESHOLD` (60) or `CODEX_TOOL_DISCOVERY_BYTES`+(32768 serialized MCP definition bytes). Theseare optimization thresholds; no tools are discarded from the local registry.Direct retains all definitions subject to the bounded request contract.Discovery exposes the stable native set and search/describe/call bridge.diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 8afefb69d..3e51a6eb4 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.329",+ "version": "0.1.330","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.329",+ "version": "0.1.330","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex e8e13a6e2..856c5c2a1 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.329",+ "version": "0.1.330","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/config.codexToolPresentation.test.ts b/mcp-host/src/config.codexToolPresentation.test.tsindex b9e0f67a8..c2c482af2 100644--- a/mcp-host/src/config.codexToolPresentation.test.ts+++ b/mcp-host/src/config.codexToolPresentation.test.ts@@ -40,8 +40,8 @@ describe('CODEX_TOOL_DISCOVERY_BYTES import-time configuration', () => {})describe('CODEX_TOOL_PRESENTATION import-time configuration', () => {- it('defaults to auto when unset', async () => {- expect((await loadConfig(undefined)).codexToolPresentation).toBe('auto')+ it('defaults to direct when unset', async () => {+ expect((await loadConfig(undefined)).codexToolPresentation).toBe('direct')})it.each(['auto', 'direct', 'discovery'] as const)('loads explicit %s', async value => {diff --git a/mcp-host/src/core/orchestration/__tests__/approvedToolsLifecycle.integration.test.ts b/mcp-host/src/core/orchestration/__tests__/approvedToolsLifecycle.integration.test.tsindex 65168fdc5..4dfbc00d9 100644--- a/mcp-host/src/core/orchestration/__tests__/approvedToolsLifecycle.integration.test.ts+++ b/mcp-host/src/core/orchestration/__tests__/approvedToolsLifecycle.integration.test.ts@@ -21,6 +21,7 @@ import { FinishReason } from '../../types'import { DeferrableToolController } from '../deferrableToolController'import { SimpleEventEmitter } from '../eventEmitter'import { DefaultLoopController, buildLoopConfig } from '../loopConfig'+import { parseCodexToolPresentation } from '../toolPresentationPolicy'import { validateToolLinkages } from '../toolUseLoopLinkages'import { executeToolCalls } from '../toolUseLoopToolBatch'@@ -563,28 +564,36 @@ describe('approved catalog across presentation and lifecycle', () => {)})- it.each(['approve', 'direct', 'deny', 'cancel', 'revoke', 'schema-change'] as const)(+ it.each(['approve', 'direct', 'default', 'deny', 'cancel', 'revoke', 'schema-change'] as const)('TaskExecutor %s uses the actual loop and never duplicates the MCP call',async decision => {+ const direct = decision === 'direct' || decision === 'default'const saved = {enableApproval: appConfig.enableApproval,codexToolPresentation: appConfig.codexToolPresentation,+ dynamicToolsEnabled: appConfig.dynamicToolsEnabled,contextMaxTokens: appConfig.contextMaxTokens,promptCacheEnabled: appConfig.promptCacheEnabled,}Object.assign(appConfig, {enableApproval: true,- codexToolPresentation: decision === 'direct' ? 'direct' : 'discovery',+ // Exercise the unset environment default through the real execution loop.+ codexToolPresentation:+ decision === 'default'+ ? parseCodexToolPresentation(undefined)+ : direct+ ? 'direct'+ : 'discovery',+ dynamicToolsEnabled: true,contextMaxTokens: 100000,promptCacheEnabled: false,})try {const { manager } = await setup(83)const target = 'alpha__record__read_082'- const call: ToolCall =- decision === 'direct'- ? { id: 'durable-call', name: target, arguments: {} }- : bridgeCall(target, 'durable-call')+ const call: ToolCall = direct+ ? { id: 'durable-call', name: target, arguments: {} }+ : bridgeCall(target, 'durable-call')const providerCalls: ChatMessage[][] = []const provider: SingleTurnProvider = {getProviderType: () => 'codex-subscription',@@ -596,13 +605,11 @@ describe('approved catalog across presentation and lifecycle', () => {},completeSingleTurnWithTools: async (messages, tools) => {providerCalls.push(structuredClone(messages))- expect(tools.some(tool => tool.name === 'clerum__tool_call')).toBe(- decision !== 'direct'- )+ expect(tools.some(tool => tool.name === 'clerum__tool_call')).toBe(!direct)const connectorDefinitions = tools.filter(tool => tool.name.startsWith('alpha__') || tool.name.startsWith('beta__'))- expect(connectorDefinitions.length).toBe(decision === 'direct' ? 83 : 0)+ expect(connectorDefinitions.length).toBe(direct ? 83 : 0)const usage = { input_tokens: 1, output_tokens: 1, total_tokens: 2 }if (providerCalls.length === 1)return {@@ -684,7 +691,7 @@ describe('approved catalog across presentation and lifecycle', () => {const approvalId = executor.pendingApproval!.request_idexpect(approvalId).toBeTruthy()expect(remote.calls).not.toHaveBeenCalled()- if (decision === 'approve' || decision === 'direct') {+ if (decision === 'approve' || direct) {await executor.resumeAfterApproval(false)expect(executor.executorState).toBe('completed')expect(remote.calls).toHaveBeenCalledTimes(1)diff --git a/mcp-host/src/core/orchestration/__tests__/toolPresentationPolicy.test.ts b/mcp-host/src/core/orchestration/__tests__/toolPresentationPolicy.test.tsindex e4d91e6f4..0922ebca4 100644--- a/mcp-host/src/core/orchestration/__tests__/toolPresentationPolicy.test.ts+++ b/mcp-host/src/core/orchestration/__tests__/toolPresentationPolicy.test.ts@@ -6,14 +6,23 @@ import {} from '../toolPresentationPolicy'describe('tool presentation configuration', () => {- it('defaults Codex to auto independently of the legacy flag', () => {- expect(parseCodexToolPresentation(undefined)).toBe('auto')- expect(resolveToolPresentation('codex-subscription', { dynamicToolsEnabled: false })).toEqual({- bridgeEnabled: true,- codexMode: 'auto',- })+ it.each([false, true])('defaults Codex to direct with legacy flag %s', enabled => {+ expect(parseCodexToolPresentation(undefined)).toBe('direct')+ expect(resolveToolPresentation('codex-subscription', { dynamicToolsEnabled: enabled })).toEqual(+ {+ bridgeEnabled: false,+ codexMode: 'direct',+ }+ )expect(parseCodexToolDiscoveryBytes(undefined)).toBe(32_768)})+ it.each([false, true])('defaults Codex fallback to direct with legacy flag %s', enabled => {+ expect(+ resolveToolPresentation('zai', { dynamicToolsEnabled: enabled }, [+ { provider: 'codex-subscription' },+ ])+ ).toEqual({ bridgeEnabled: false, codexMode: 'direct' })+ })it.each(['auto', 'direct', 'discovery'] as const)('accepts explicit %s', mode => {expect(parseCodexToolPresentation(mode)).toBe(mode)expect(diff --git a/mcp-host/src/core/orchestration/toolPresentationPolicy.ts b/mcp-host/src/core/orchestration/toolPresentationPolicy.tsindex 11e06d762..88e28bdcb 100644--- a/mcp-host/src/core/orchestration/toolPresentationPolicy.ts+++ b/mcp-host/src/core/orchestration/toolPresentationPolicy.ts@@ -2,7 +2,7 @@export type CodexToolPresentation = 'auto' | 'direct' | 'discovery'export function parseCodexToolPresentation(raw: string | undefined): CodexToolPresentation {- if (raw === undefined) return 'auto'+ if (raw === undefined) return 'direct'if (raw === 'auto' || raw === 'direct' || raw === 'discovery') return rawthrow new Error('CODEX_TOOL_PRESENTATION must be auto, direct, or discovery')}@@ -27,7 +27,7 @@ export function resolveToolPresentation(provider === 'codex-subscription' ||fallbacks.some(entry => entry.provider === 'codex-subscription')) {- const codexMode = config.codexToolPresentation ?? 'auto'+ const codexMode = config.codexToolPresentation ?? 'direct'return { bridgeEnabled: codexMode !== 'direct', codexMode }}return { bridgeEnabled: config.dynamicToolsEnabled }