Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6199,7 +6199,7 @@ from strands.models.bedrock import BedrockModel

def load_model() -> BedrockModel:
"""Get Bedrock model client using IAM credentials."""
return BedrockModel(model_id="{{#if modelId}}{{modelId}}{{else}}global.anthropic.claude-sonnet-4-5-20250929-v1:0{{/if}}")
return BedrockModel(model_id="{{#if modelId}}{{modelId}}{{else}}global.anthropic.claude-sonnet-4-5-20250929-v1:0{{/if}}"{{#if modelMaxTokens}}, max_tokens={{modelMaxTokens}}{{/if}})
{{/if}}
{{/if}}
{{#if (eq modelProvider "Anthropic")}}
Expand Down
2 changes: 1 addition & 1 deletion src/assets/python/http/strands/base/model/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def load_model():

def load_model() -> BedrockModel:
"""Get Bedrock model client using IAM credentials."""
return BedrockModel(model_id="{{#if modelId}}{{modelId}}{{else}}global.anthropic.claude-sonnet-4-5-20250929-v1:0{{/if}}")
return BedrockModel(model_id="{{#if modelId}}{{modelId}}{{else}}global.anthropic.claude-sonnet-4-5-20250929-v1:0{{/if}}"{{#if modelMaxTokens}}, max_tokens={{modelMaxTokens}}{{/if}})
{{/if}}
{{/if}}
{{#if (eq modelProvider "Anthropic")}}
Expand Down
30 changes: 30 additions & 0 deletions src/cli/commands/export/__tests__/harness-mapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,36 @@ describe('model ID propagation to renderConfig', () => {
});
});

// ============================================================================
// model maxTokens propagation
// ============================================================================

describe('model maxTokens propagation to renderConfig', () => {
it('propagates maxTokens for an ordinary Converse Bedrock model', () => {
const ctx = baseContext({
model: { provider: 'bedrock', modelId: 'anthropic.claude-3', maxTokens: 4096 },
});
const { renderConfig } = mapHarnessToExportConfig(ctx, 'CodeZip');
expect(renderConfig.modelMaxTokens).toBe(4096);
expect(renderConfig.bedrockMantle).toBeUndefined();
});

it('leaves modelMaxTokens undefined when the spec has no maxTokens', () => {
const ctx = baseContext({ model: { provider: 'bedrock', modelId: 'anthropic.claude-3' } });
const { renderConfig } = mapHarnessToExportConfig(ctx, 'CodeZip');
expect(renderConfig.modelMaxTokens).toBeUndefined();
});

it('propagates maxTokens for a Bedrock Mantle model', () => {
const ctx = baseContext({
model: { provider: 'bedrock', modelId: 'openai.gpt-oss-120b', apiFormat: 'chat_completions', maxTokens: 2048 },
});
const { renderConfig } = mapHarnessToExportConfig(ctx, 'CodeZip');
expect(renderConfig.bedrockMantle).toBe(true);
expect(renderConfig.modelMaxTokens).toBe(2048);
});
});

// ============================================================================
// resolveIdentityProvider
// ============================================================================
Expand Down
4 changes: 3 additions & 1 deletion src/cli/commands/export/harness-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@
hasExecutionLimits,
isExportHarness: true,
modelId: spec.model.modelId,
// Max output tokens, threaded into load.py for both ordinary Converse Bedrock models
// (BedrockModel max_tokens) and Mantle models (max_output_tokens/max_completion_tokens).
modelMaxTokens: spec.model.maxTokens,
// LiteLLM-only model config (apiBase + additionalParams), threaded into load.py. The model
// schema is a flat object, so apiBase/additionalParams are always typed-present — only the
// provider check + a truthiness check are needed.
Expand Down Expand Up @@ -556,7 +559,6 @@
mantleProprietary: isProprietaryOpenAiModel(spec.model.modelId),
modelTemperature: spec.model.temperature,
modelTopP: spec.model.topP,
modelMaxTokens: spec.model.maxTokens,
};
}

Expand Down Expand Up @@ -1204,7 +1206,7 @@
}

function fnmatch(pattern: string, str: string): boolean {
const re = new RegExp(

Check warning on line 1209 in src/cli/commands/export/harness-mapper.ts

View workflow job for this annotation

GitHub Actions / lint

Found non-literal argument to RegExp Constructor
'^' +
pattern
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
Expand Down
3 changes: 2 additions & 1 deletion src/cli/templates/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ export interface AgentRenderConfig {
modelTemperature?: number;
/** Model nucleus-sampling top_p (export path, Mantle): merged into the client params when set. */
modelTopP?: number;
/** Model max output tokens (export path, Mantle): mapped to max_output_tokens / max_completion_tokens. */
/** Model max output tokens (export path): BedrockModel max_tokens for Converse models;
* max_output_tokens / max_completion_tokens for Mantle models. */
modelMaxTokens?: number;

/** True when generating from a harness export (suppresses placeholder tools) */
Expand Down
Loading