Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(grok): port Codex #644/#648 presentation and tool strictness
Jose Gabriel Ramirez Encinasbf0499aa64c9
diff --git a/docs/architecture/grok-subscription-transport-contract.md b/docs/architecture/grok-subscription-transport-contract.mdindex 827ed0a62..85162162e 100644--- a/docs/architecture/grok-subscription-transport-contract.md+++ b/docs/architecture/grok-subscription-transport-contract.md@@ -52,6 +52,11 @@ CLI impersonation headers (`x-xai-token-auth`, `x-grok-client-identifier`) stayoff until a recorded SuperGrok probe requires them. Do not send `OpenAI-Beta`or `service_tier`. `max_output_tokens` is bindable on this wire.+Tool payloads send `strict: false` so optional MCP fields stay optional on the+Responses-shaped Grok wire (sibling of Codex #648). Agent tool presentation+uses the same `CODEX_TOOL_PRESENTATION` knob as Codex and defaults to `direct`+when Grok is the primary or a fallback (sibling of Codex #644).+## Allowlist ConfigMap republishcontrol-api is `replicas: 1`. After rolling a new control-api that writesdiff --git a/grok-llm-proxy/src/grokTransport.ts b/grok-llm-proxy/src/grokTransport.tsindex c812e7a99..8a79b7184 100644--- a/grok-llm-proxy/src/grokTransport.ts+++ b/grok-llm-proxy/src/grokTransport.ts@@ -290,6 +290,9 @@ function toUpstreamPayload(name: names.toWire(tool.name),description: tool.description,parameters: tool.parameters,+ // Responses-shaped Grok proxy can normalize omitted `strict` to require+ // optional MCP fields. Preserve source schema optionality explicitly.+ strict: false,}))payload.parallel_tool_calls = true}diff --git a/grok-llm-proxy/test/grokTransport.conformance.test.ts b/grok-llm-proxy/test/grokTransport.conformance.test.tsindex 1ec32795b..017009577 100644--- a/grok-llm-proxy/test/grokTransport.conformance.test.ts+++ b/grok-llm-proxy/test/grokTransport.conformance.test.ts@@ -602,7 +602,9 @@ describe('streamGrokCompletion', () => {const body = JSON.parse(String(fetchFn.mock.calls[0]?.[1]?.body)) as Record<string, unknown>expect(body.instructions).toBe('be brief')expect(body.store).toBe(false)- expect(body.tools).toEqual(request.tools.map(tool => ({ type: 'function', ...tool })))+ expect(body.tools).toEqual(+ request.tools.map(tool => ({ type: 'function', ...tool, strict: false }))+ )expect(body.parallel_tool_calls).toBe(true)expect(body.tool_choice).toBe('auto')expect(body.prompt_cache_key).toBe('sess-1')diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 22c08230e..cb7b4f1de 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.337",+ "version": "0.1.338","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.337",+ "version": "0.1.338","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 74627fcc0..8589830d5 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.337",+ "version": "0.1.338","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/core/orchestration/__tests__/toolPresentationPolicy.test.ts b/mcp-host/src/core/orchestration/__tests__/toolPresentationPolicy.test.tsindex 0922ebca4..9aa350542 100644--- a/mcp-host/src/core/orchestration/__tests__/toolPresentationPolicy.test.ts+++ b/mcp-host/src/core/orchestration/__tests__/toolPresentationPolicy.test.ts@@ -49,4 +49,15 @@ describe('tool presentation configuration', () => {})).toEqual({ bridgeEnabled: enabled })})+ it.each([false, true])('defaults Grok to the same direct presentation as Codex %s', enabled => {+ expect(resolveToolPresentation('grok-subscription', { dynamicToolsEnabled: enabled })).toEqual({+ bridgeEnabled: false,+ codexMode: 'direct',+ })+ expect(+ resolveToolPresentation('zai', { dynamicToolsEnabled: enabled }, [+ { provider: 'grok-subscription' },+ ])+ ).toEqual({ bridgeEnabled: false, codexMode: 'direct' })+ })})diff --git a/mcp-host/src/core/orchestration/toolPresentationPolicy.ts b/mcp-host/src/core/orchestration/toolPresentationPolicy.tsindex 88e28bdcb..241c9d93f 100644--- a/mcp-host/src/core/orchestration/toolPresentationPolicy.ts+++ b/mcp-host/src/core/orchestration/toolPresentationPolicy.ts@@ -24,11 +24,15 @@ export function resolveToolPresentation(// A fallback reuses the same tool request, so choose a presentation executable// and optimized across the configured provider chain before the first attempt.if (- provider === 'codex-subscription' ||- fallbacks.some(entry => entry.provider === 'codex-subscription')+ isOauthBrokerPresentationTarget(provider) ||+ fallbacks.some(entry => isOauthBrokerPresentationTarget(entry.provider))) {const codexMode = config.codexToolPresentation ?? 'direct'return { bridgeEnabled: codexMode !== 'direct', codexMode }}return { bridgeEnabled: config.dynamicToolsEnabled }}++function isOauthBrokerPresentationTarget(provider: string): boolean {+ return provider === 'codex-subscription' || provider === 'grok-subscription'+}diff --git a/scripts/tests/test-grok-subscription-t0.sh b/scripts/tests/test-grok-subscription-t0.shindex af962222f..836c08566 100755--- a/scripts/tests/test-grok-subscription-t0.sh+++ b/scripts/tests/test-grok-subscription-t0.sh@@ -138,7 +138,7 @@ run_group "grok-catalog-projection" \bash -lc "cd '${ROOT}/packages/codex-catalog-projection' && node --test index.test.cjs"run_group "grok-llm-proxy freeze+origin" \- bash -lc "cd '${ROOT}/grok-llm-proxy' && npx vitest run test/contractFreeze.test.ts test/originPolicy.test.ts --no-file-parallelism"+ bash -lc "cd '${ROOT}/grok-llm-proxy' && npx vitest run test/contractFreeze.test.ts test/originPolicy.test.ts test/grokTransport.conformance.test.ts --no-file-parallelism"run_group "control-api grok grant/oauth/redeem/authorize" \bash -lc "cd '${ROOT}/control-api' && npx vitest run test/db.grokSubscriptionMigration.test.ts test/services.grokSubscriptionConnection.test.ts test/services.grokSubscriptionOAuth.test.ts test/services.grokSubscriptionCatalog.test.ts test/services.grokProviderAttemptRedemption.test.ts test/services.llmProviderAttemptAuthorizer.grok.test.ts test/subscriptionGrantIdentity.test.ts test/routes.adminPluginWorkloadSdk.test.ts test/services.recipeCodexGrantIdentity.test.ts test/hostSpecValidation.codexSubscription.test.ts test/crd.llmProviderEnums.test.ts test/routes.mcp-host.plugin-workload-sdk.test.ts --no-file-parallelism"