(retryContext: RetryContext)
| 1536 | let lastRequestBetas: string[] | undefined |
| 1537 | |
| 1538 | const paramsFromContext = (retryContext: RetryContext) => { |
| 1539 | const betasParams = [...betas] |
| 1540 | |
| 1541 | // Append 1M beta dynamically for the Sonnet 1M experiment. |
| 1542 | if ( |
| 1543 | !betasParams.includes(CONTEXT_1M_BETA_HEADER) && |
| 1544 | getSonnet1mExpTreatmentEnabled(retryContext.model) |
| 1545 | ) { |
| 1546 | betasParams.push(CONTEXT_1M_BETA_HEADER) |
| 1547 | } |
| 1548 | |
| 1549 | // For Bedrock, include both model-based betas and dynamically-added tool search header |
| 1550 | const bedrockBetas = |
| 1551 | getAPIProvider() === 'bedrock' |
| 1552 | ? [ |
| 1553 | ...getBedrockExtraBodyParamsBetas(retryContext.model), |
| 1554 | ...(toolSearchHeader ? [toolSearchHeader] : []), |
| 1555 | ] |
| 1556 | : [] |
| 1557 | const extraBodyParams = getExtraBodyParams(bedrockBetas) |
| 1558 | |
| 1559 | const outputConfig: BetaOutputConfig = { |
| 1560 | ...((extraBodyParams.output_config as BetaOutputConfig) ?? {}), |
| 1561 | } |
| 1562 | |
| 1563 | configureEffortParams( |
| 1564 | effort, |
| 1565 | outputConfig, |
| 1566 | extraBodyParams, |
| 1567 | betasParams, |
| 1568 | options.model, |
| 1569 | ) |
| 1570 | |
| 1571 | configureTaskBudgetParams( |
| 1572 | options.taskBudget, |
| 1573 | outputConfig as BetaOutputConfig & { task_budget?: TaskBudgetParam }, |
| 1574 | betasParams, |
| 1575 | ) |
| 1576 | |
| 1577 | // Merge outputFormat into extraBodyParams.output_config alongside effort |
| 1578 | // Requires structured-outputs beta header per SDK (see parse() in messages.mjs) |
| 1579 | if (options.outputFormat && !('format' in outputConfig)) { |
| 1580 | outputConfig.format = options.outputFormat as BetaJSONOutputFormat |
| 1581 | // Add beta header if not already present and provider supports it |
| 1582 | if ( |
| 1583 | modelSupportsStructuredOutputs(options.model) && |
| 1584 | !betasParams.includes(STRUCTURED_OUTPUTS_BETA_HEADER) |
| 1585 | ) { |
| 1586 | betasParams.push(STRUCTURED_OUTPUTS_BETA_HEADER) |
| 1587 | } |
| 1588 | } |
| 1589 | |
| 1590 | // Retry context gets preference because it tries to course correct if we exceed the context window limit |
| 1591 | const maxOutputTokens = |
| 1592 | retryContext?.maxTokensOverride || |
| 1593 | options.maxOutputTokensOverride || |
| 1594 | getMaxOutputTokensForModel(options.model) |
| 1595 |
no test coverage detected