fix(coding-agent): ignore empty entries in --models

A trailing comma in --models produced an empty pattern, which
matched every model by substring and added an extra model to
the model cycle.

fixes #10334
This commit is contained in:
David Brailovsky 2026-10-02 13:42:14 +02:00
parent b271b0a524
commit 9b3c19da5c
3 changed files with 11 additions and 1 deletions

View file

@ -9,6 +9,7 @@
### Fixed
- Fixed the shrinkwrap shipping vulnerable `brace-expansion` 5.0.9 by pinning `brace-expansion` 5.0.12 as a direct dependency (GHSA-q2hr-2g5m-vwhr, GHSA-qhr7-859c-m2p7, GHSA-6j4f-fj2g-mc7p) ([#10288](https://github.com/earendil-works/pi/issues/10288))
- Fixed a trailing comma in `--models` adding an extra model to the model cycle ([#10334](https://github.com/earendil-works/pi/issues/10334))
## [1.0.0] - 2026-10-01

View file

@ -139,7 +139,10 @@ export function parseArgs(args: string[]): Args {
} else if (arg === "--session-dir" && i + 1 < args.length) {
result.sessionDir = args[++i];
} else if (arg === "--models" && i + 1 < args.length) {
result.models = args[++i].split(",").map((s) => s.trim());
result.models = args[++i]
.split(",")
.map((s) => s.trim())
.filter((pattern) => pattern.length > 0);
} else if (arg === "--no-tools" || arg === "-nt") {
result.noTools = true;
} else if (arg === "--no-builtin-tools" || arg === "-nbt") {

View file

@ -145,6 +145,12 @@ describe("parseArgs", () => {
const result = parseArgs(["--models", "gpt-4o,claude-sonnet,gemini-pro"]);
expect(result.models).toEqual(["gpt-4o", "claude-sonnet", "gemini-pro"]);
});
// Issue #10334
test("ignores empty entries in --models", () => {
const result = parseArgs(["--models", "gpt-4o, ,claude-sonnet,"]);
expect(result.models).toEqual(["gpt-4o", "claude-sonnet"]);
});
});
// Issue #9045