Skip to content

Commit aff922e

Browse files
committed
fix(inference): propagate publisher-prefixed model_id through inference bundle
resolve_route_by_name_with_credentials built the ResolvedRoute with config.model_id (the bare stored value) rather than resolved.route.model (the publisher-prefixed value computed by resolve_vertex_ai_route). As a result, the bundle delivered to sandboxes carried e.g. "gemini-2.5-flash" instead of "google/gemini-2.5-flash", so live sandbox requests still hit Vertex AI with the bare model name and received HTTP 400 "Malformed publisher model". Fix: use resolved.route.model in the bundle construction so the publisher prefix survives the bundle boundary and the router sends the correct body to Vertex AI. Update the existing gemini bundle test to assert the prefixed model_id and add a dedicated regression test that verifies the bundle carries the publisher prefix for non-Anthropic Vertex routes. Signed-off-by: politerealism <burdcat17@gmail.com>
1 parent e6588ea commit aff922e

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

crates/openshell-server/src/inference.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ async fn resolve_route_by_name_with_credentials(
11591159
Ok(Some(ResolvedRoute {
11601160
name: route_name.to_string(),
11611161
base_url: resolved.route.endpoint,
1162-
model_id: config.model_id.clone(),
1162+
model_id: resolved.route.model.clone(),
11631163
api_key: resolved.route.api_key,
11641164
protocols: resolved.route.protocols,
11651165
provider_type: resolved.provider_type,
@@ -1749,13 +1749,41 @@ mod tests {
17491749
route.request_path_override,
17501750
Some("/chat/completions".to_string())
17511751
);
1752-
assert_eq!(route.model_id, "gemini-2.0-flash-001");
1752+
assert_eq!(route.model_id, "google/gemini-2.0-flash-001");
17531753
assert_eq!(
17541754
route.base_url,
17551755
"https://us-central1-aiplatform.googleapis.com/v1beta1/projects/my-gcp-project/locations/us-central1/endpoints/openapi"
17561756
);
17571757
}
17581758

1759+
#[tokio::test]
1760+
async fn bundle_vertex_ai_non_anthropic_model_id_carries_publisher_prefix() {
1761+
// Regression test: the bundle's model_id must carry the publisher prefix
1762+
// so the router sends e.g. "google/gemini-2.5-flash" in the request body,
1763+
// not the bare "gemini-2.5-flash" that Vertex AI rejects with HTTP 400.
1764+
let store = test_store().await;
1765+
let config = [
1766+
("VERTEX_AI_PROJECT_ID".to_string(), "my-gcp-project".to_string()),
1767+
("VERTEX_AI_REGION".to_string(), "us-central1".to_string()),
1768+
]
1769+
.into_iter()
1770+
.collect();
1771+
let provider = make_vertex_provider_with_config("vertex-dev", config);
1772+
store.put_message(&provider).await.expect("persist provider");
1773+
let route = make_route(CLUSTER_INFERENCE_ROUTE_NAME, "vertex-dev", "gemini-2.5-flash");
1774+
store.put_message(&route).await.expect("persist route");
1775+
1776+
let resp = resolve_inference_bundle(&store, "default")
1777+
.await
1778+
.expect("bundle should resolve");
1779+
1780+
assert_eq!(resp.routes.len(), 1);
1781+
assert_eq!(
1782+
resp.routes[0].model_id, "google/gemini-2.5-flash",
1783+
"bundle model_id must carry publisher prefix for non-Anthropic Vertex routes"
1784+
);
1785+
}
1786+
17591787
#[tokio::test]
17601788
async fn bundle_without_cluster_route_returns_empty_routes() {
17611789
let store = test_store().await;

0 commit comments

Comments
 (0)