File tree Expand file tree Collapse file tree
go/deployment-operator/pkg/agentrun-harness/tool/pi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ func New(config v1.Config) v1.Tool {
3939 }
4040 }
4141 if config .Run .IsProxyEnabled () {
42- result .provider = openAIProvider
42+ result .provider = proxyProviderKey
4343 result .model = proxymodel .ProxyModel (console .AgentRuntimeTypePi , result .model )
4444 }
4545 if err := result .ensure (); err != nil {
@@ -197,9 +197,15 @@ func (in *Pi) writeConfig() error {
197197 }
198198 provider := in .provider
199199 if endpoint != "" {
200- // Pi's custom provider support is OpenAI-compatible. Keep the CLI provider
201- // stable and override its endpoint in the isolated PI config directory.
202- provider = openAIProvider
200+ if in .Config .Run .IsProxyEnabled () {
201+ // Use a non-"openai" provider key so the Pi CLI does not strip the
202+ // "openai/" prefix from the model ID before calling the proxy endpoint.
203+ provider = proxyProviderKey
204+ } else {
205+ // For custom non-proxy endpoints keep the openai provider so Pi uses
206+ // its built-in OpenAI-compatible client.
207+ provider = openAIProvider
208+ }
203209 in .provider = provider
204210 }
205211 models := map [string ]any {"providers" : map [string ]any {}}
Original file line number Diff line number Diff line change @@ -31,6 +31,27 @@ func TestArgsIncludesJSONModeSessionAndMCPConfig(t *testing.T) {
3131 }
3232}
3333
34+ func TestArgsWithProxyUsesPluralProvider (t * testing.T ) {
35+ tool := & Pi {
36+ DefaultTool : toolv1.DefaultTool {Config : toolv1.Config {WorkDir : "/work" }},
37+ model : "openai/gpt-5.4" ,
38+ provider : proxyProviderKey ,
39+ }
40+ want := []string {
41+ "--mode" , "json" ,
42+ "--approve" ,
43+ "--provider" , proxyProviderKey ,
44+ "--model" , "openai/gpt-5.4" ,
45+ "--session-dir" , "/work/.pi/agent/sessions" ,
46+ "--extension" , piMCPExtensionPath ,
47+ "--mcp-config" , "/work/.pi/agent/mcp.json" ,
48+ "write a task" ,
49+ }
50+ if got := tool .args ("write a task" , "" ); ! reflect .DeepEqual (got , want ) {
51+ t .Fatalf ("args = %#v, want %#v" , got , want )
52+ }
53+ }
54+
3455func TestMapStreamEventMapsToolLifecycle (t * testing.T ) {
3556 tool := & Pi {}
3657 start , callID := tool .mapStreamEvent (& StreamEvent {
Original file line number Diff line number Diff line change @@ -9,8 +9,13 @@ import (
99)
1010
1111const (
12- defaultModel = "gpt-5.4"
13- openAIProvider = "openai"
12+ defaultModel = "gpt-5.4"
13+ openAIProvider = "openai"
14+ // proxyProviderKey is the models.json provider block name used when aiProxy is enabled.
15+ // Using a non-"openai" name prevents the Pi CLI from stripping the "openai/" prefix
16+ // from model IDs (e.g. "openai/gpt-5.4"), ensuring the full provider/model format
17+ // reaches the Plural AI proxy at /ext/ai/v1.
18+ proxyProviderKey = "plural"
1419 pluralAPIKeyEnv = "PLRL_CONSOLE_TOKEN"
1520 openAIAPIKeyEnv = "OPENAI_API_KEY"
1621 piMCPExtensionPath = "/opt/pi-mcp-adapter/node_modules/pi-mcp-adapter/index.ts"
You can’t perform that action at this time.
0 commit comments