Skip to content

Conversation

@yaonyan
Copy link

@yaonyan yaonyan commented Nov 1, 2025

Fixes session load failure when using models not in the preset list (e.g., custom model providers zed-industries/zed#40292).

Previously, if a model wasn't found in the presets list, the session would fail to load. This prevented using custom model providers with arbitrary model names. Now falls back to the configured model string, allowing custom providers to work without being in the preset list.

This puts the custom auth option #52 aside for now and instead provides a simpler way to achieve the same result.

@benbrandt plz review

Previously, if a model wasn't found in the presets list, the session
would fail to load. This prevented using custom model providers with
arbitrary model names. Now falls back to the configured model string,
allowing custom providers to work without being in the preset list.
ModelId(format!("{id}/{effort}").into())
}

fn parse_model_id(id: ModelId) -> Result<(String, ReasoningEffort), Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to update this as well.
Either here or where we call it, if this fails, we should return the model string as is and return an Option<ReasoningEffort> of None so that we can update the config accordingly

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've added graceful parsing and a fallback to the user's config.

})?;
Ok((model.to_owned(), reasoning))

let reasoning = serde_json::from_value(reasoning.into()).ok();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if here, we should also return the original model name?
Like in case the model name had a / in it, we don't want to return the first part, but rather treat this as a failure as well.

I also wonder if model name should always return a string, not an option, and then reasoning only returns an option if we can parse.

OR we treat this as a parse, and this instead an Option<(String, ReasoningEffor)>, so we only return values at all if it is one we expect

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think we don't need a Result anymore

@cndoit18
Copy link

cndoit18 commented Nov 4, 2025

Could you please help review and release this PR when you have a moment? It would be really helpful for my current work. Thanks a lot! @benbrandt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants