Handle required fields correctly for hosted keys

This commit is contained in:
Theodore Li
2026-02-12 19:08:08 -08:00
parent 2cdb89681b
commit 3e6527a540
4 changed files with 6 additions and 6 deletions

View File

@@ -243,11 +243,7 @@ export interface SubBlockConfig {
hidden?: boolean
hideFromPreview?: boolean // Hide this subblock from the workflow block preview
requiresFeature?: string // Environment variable name that must be truthy for this subblock to be visible
/**
* Hide this subblock when running on hosted Sim (isHosted is true).
* Used for tool API key fields that should be hidden when Sim provides hosted keys.
*/
hideWhenHosted?: boolean
hideWhenHosted?: boolean // Hide this subblock when running on hosted sim
description?: string
tooltip?: string // Tooltip text displayed via info icon next to the title
value?: (params: Record<string, any>) => string

View File

@@ -10,6 +10,7 @@ import {
isCanonicalPair,
isNonEmptyValue,
isSubBlockFeatureEnabled,
isSubBlockHiddenByHostedKey,
resolveCanonicalMode,
} from '@/lib/workflows/subblocks/visibility'
import { getBlock } from '@/blocks'
@@ -49,6 +50,7 @@ function shouldSerializeSubBlock(
canonicalModeOverrides?: CanonicalModeOverrides
): boolean {
if (!isSubBlockFeatureEnabled(subBlockConfig)) return false
if (isSubBlockHiddenByHostedKey(subBlockConfig)) return false
if (subBlockConfig.mode === 'trigger') {
if (!isTriggerContext && !isTriggerCategory) return false

View File

@@ -3,6 +3,7 @@ import { generateInternalToken } from '@/lib/auth/internal'
import { getBYOKKey } from '@/lib/api-key/byok'
import { logFixedUsage } from '@/lib/billing/core/usage-log'
import { env } from '@/lib/core/config/env'
import { isHosted } from '@/lib/core/config/feature-flags'
import { DEFAULT_EXECUTION_TIMEOUT_MS } from '@/lib/core/execution-limits'
import {
secureFetchWithPinnedIP,
@@ -61,6 +62,7 @@ async function injectHostedKeyIfNeeded(
requestId: string
): Promise<boolean> {
if (!tool.hosting) return false
if (!isHosted) return false
const { envKeys, apiKeyParam, byokProviderId } = tool.hosting
const userProvidedKey = params[apiKeyParam]

View File

@@ -43,7 +43,7 @@ export const searchTool: ToolConfig<SearchParams, SearchResponse> = {
},
apiKey: {
type: 'string',
required: false,
required: true,
visibility: 'user-only',
description: 'Serper API Key',
},