mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 23:42:03 +00:00
fix(subagents): treat unknown prefixes as bare model IDs
Model IDs can legitimately contain colons (e.g., `gpt-4o:online`). Previously, any string with a colon was parsed as `authType:modelId`, which caused valid model IDs with colons to be rejected. Now, if the prefix before a colon isn't a known AuthType, the entire string is treated as a bare model ID. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
4293641d14
commit
fd58818f58
3 changed files with 23 additions and 11 deletions
|
|
@ -36,9 +36,17 @@ describe('parseSubagentModelSelection', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('rejects invalid authType prefixes', () => {
|
||||
expect(() => parseSubagentModelSelection('invalid:glm-5')).toThrow(
|
||||
/Invalid authType prefix/,
|
||||
);
|
||||
it('treats unknown prefix as bare model ID (colon in model ID)', () => {
|
||||
expect(parseSubagentModelSelection('invalid:glm-5')).toEqual({
|
||||
modelId: 'invalid:glm-5',
|
||||
inherits: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('treats model IDs with colons as bare model IDs', () => {
|
||||
expect(parseSubagentModelSelection('gpt-4o:online')).toEqual({
|
||||
modelId: 'gpt-4o:online',
|
||||
inherits: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ export function parseSubagentModelSelection(
|
|||
const maybeAuthType = trimmed.slice(0, colonIndex).trim();
|
||||
const modelId = trimmed.slice(colonIndex + 1).trim();
|
||||
|
||||
// If the prefix isn't a known AuthType, treat the whole string as a bare
|
||||
// model ID. Model IDs can legitimately contain colons (e.g. gpt-4o:online).
|
||||
if (!AUTH_TYPES.has(maybeAuthType as AuthType)) {
|
||||
throw new Error(
|
||||
`Invalid authType prefix "${maybeAuthType}". Expected one of: ${Object.values(AuthType).join(', ')}`,
|
||||
);
|
||||
return { modelId: trimmed, inherits: false };
|
||||
}
|
||||
|
||||
if (!modelId) {
|
||||
|
|
|
|||
|
|
@ -247,13 +247,17 @@ describe('SubagentValidator', () => {
|
|||
expect(result.errors).toContain('Model must be a non-empty string');
|
||||
});
|
||||
|
||||
it('should reject invalid authType prefixes', () => {
|
||||
it('should accept model IDs containing colons with unknown prefix', () => {
|
||||
const result = validator.validateModel('invalid:glm-5');
|
||||
expect(result.isValid).toBe(false);
|
||||
expect(result.errors[0]).toContain('Invalid authType prefix');
|
||||
expect(result.isValid).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject missing model IDs after authType prefixes', () => {
|
||||
it('should accept model IDs with colons (e.g. gpt-4o:online)', () => {
|
||||
const result = validator.validateModel('gpt-4o:online');
|
||||
expect(result.isValid).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject missing model IDs after valid authType prefixes', () => {
|
||||
const result = validator.validateModel('openai:');
|
||||
expect(result.isValid).toBe(false);
|
||||
expect(result.errors).toContain(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue