fix(invoke): preserve model maxTokens when overriding model at harness invoke#1287
Conversation
… harness invoke time When --model-id was passed to `agentcore invoke --harness`, the CLI constructed a new model config override that dropped maxTokens, temperature, and topP from the harness spec's model configuration. Since the server treats invoke-time model overrides as a full replacement of the deployed model config, this silently removed the model's token limit — allowing unbounded output. Also expands the HarnessModelConfiguration type to properly declare inference parameters (temperature, topP, topK, maxTokens) instead of relying on spread operators to bypass the narrow type at deploy time.
Coverage Report
|
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Thanks for catching this — silently dropping maxTokens on invoke-time model overrides is a real correctness/safety bug, and the fix in buildHarnessBaseOpts matches what harness-mapper.ts already does at deploy time.
Main ask before merging: please add a unit test for buildHarnessBaseOpts. The PR description notes that 125 existing tests pass, but none of them exercise this code path — the regression that this PR fixes was not caught by the existing suite, and without a test the same regression could re-emerge. A small test that asserts the produced baseOpts.model includes the spec's temperature / topP / topK / maxTokens (per provider) when --model-id is overridden would lock the fix down.
Also left a small note about reusing the existing HarnessModel schema type rather than duplicating the interface locally.
…ldHarnessBaseOpts - Replace local HarnessModel interface with imported schema type to prevent drift when new inference params are added - Export buildHarnessBaseOpts for testability - Add 8 unit tests covering all provider branches, param preservation, param omission, CLI precedence, and execution limits
Summary
buildHarnessBaseOptsto forward model inference parameters (temperature, topP, topK, maxTokens) from the harness spec when constructing invoke-time model overridesHarnessModeltype from schema instead of maintaining a local duplicate interfacebuildHarnessBaseOptscovering all provider branches, param omission, and CLI precedenceFixes #1290
Test plan
stopReason: "max_tokens"andoutputTokens: 500