[BUG] /model <name> asked the router for a doubled model name #533

Closed
opened 2026-10-27 13:36:42 +00:00 by sam · 0 comments
Owner

The nestif extraction in 651de0a pulled --provider parsing out of parseModelRest into extractProviderFlag, which took the modelParts slice by pointer and appended every non-provider field to it. The caller's own loop then appended the same fields again, so every field of the model name was duplicated: '/model gpt-5.6' resolved to 'gpt-5.6 gpt-5.6' and SetActiveModel rejected it as an unknown model. '/model gpt-5.6 --provider openai' was worse -- the space-separated provider value was no longer consumed with its flag, giving 'gpt-5.6 gpt-5.6 openai'. Direct model switching over Telegram was broken for anything but a bare --refresh or a provider-only switch. Found while auditing 6d4e0be for archie-core-ifi: the naked return in the same function could not be regression-tested until the function produced correct values.

Design

Two ways to fix the double append were available. Rejected: keep the helper
signature and delete the caller's default-branch append. That restores correct
output but leaves the shape intact -- a helper holding a pointer to the
caller's accumulator, with two loops over the same fields -- so the next person
who adds a field type has the same trap waiting. It also does not fix the
space-separated provider value, because the helper returns early on the first
--provider and never sees the fields after it.

Chosen: splitProviderFlag returns (provider, remaining) and is the sole
accumulator. One loop owns the fields, and there is no shared slice to append
to twice. The index loop is kept deliberately -- i++ after reading a
space-separated value is what removes it with its flag, and converting that to
a range loop is precisely what 651de0a did wrong.

Last --provider wins if repeated, matching the pre-651de0a behaviour rather
than the buggy helper's first-wins. Not worth a flag: /model does not document
repeating it.

Acceptance Criteria

parseModelRest returns the model name exactly once for bare names, scope flags, and both --provider spellings, with a regression test asserting field count rather than string equality.


Imported from beads archie-core-1786637489834-2-109e7cab · GitHub #23 · type bug · priority P2 · created 2026-08-08 · closed 2026-08-08

The nestif extraction in 651de0a pulled --provider parsing out of parseModelRest into extractProviderFlag, which took the modelParts slice by pointer and appended every non-provider field to it. The caller's own loop then appended the same fields again, so every field of the model name was duplicated: '/model gpt-5.6' resolved to 'gpt-5.6 gpt-5.6' and SetActiveModel rejected it as an unknown model. '/model gpt-5.6 --provider openai' was worse -- the space-separated provider value was no longer consumed with its flag, giving 'gpt-5.6 gpt-5.6 openai'. Direct model switching over Telegram was broken for anything but a bare --refresh or a provider-only switch. Found while auditing 6d4e0be for archie-core-ifi: the naked return in the same function could not be regression-tested until the function produced correct values. ### Design Two ways to fix the double append were available. Rejected: keep the helper signature and delete the caller's default-branch append. That restores correct output but leaves the shape intact -- a helper holding a pointer to the caller's accumulator, with two loops over the same fields -- so the next person who adds a field type has the same trap waiting. It also does not fix the space-separated provider value, because the helper returns early on the first --provider and never sees the fields after it. Chosen: splitProviderFlag returns (provider, remaining) and is the sole accumulator. One loop owns the fields, and there is no shared slice to append to twice. The index loop is kept deliberately -- i++ after reading a space-separated value is what removes it with its flag, and converting that to a range loop is precisely what 651de0a did wrong. Last --provider wins if repeated, matching the pre-651de0a behaviour rather than the buggy helper's first-wins. Not worth a flag: /model does not document repeating it. ### Acceptance Criteria parseModelRest returns the model name exactly once for bare names, scope flags, and both --provider spellings, with a regression test asserting field count rather than string equality. --- _Imported from beads `archie-core-1786637489834-2-109e7cab` · GitHub #23 · type bug · priority P2 · created 2026-08-08 · closed 2026-08-08_
sam added the mediumbug labels 2026-10-27 13:36:42 +00:00
sam self-assigned this 2026-10-27 13:36:42 +00:00
sam closed this issue 2026-10-27 13:36:42 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#533