@@ -114,11 +114,8 @@ fn configure_opencode(cmd: &mut Command, config: &Config) -> Result<()> {
114114 let api_key = config. resolve_api_key ( ) ?;
115115 cmd. env (
116116 OPENCODE_CONFIG_CONTENT ,
117- render_opencode_config ( config, api_key. is_some ( ) ) ?,
117+ render_opencode_config ( config, api_key. as_deref ( ) ) ?,
118118 ) ;
119- if let Some ( api_key) = api_key {
120- cmd. env ( PROVIDER_API_KEY , api_key) ;
121- }
122119 Ok ( ( ) )
123120}
124121
@@ -158,15 +155,15 @@ fn render_codex_config(config: &Config, has_api_key: bool) -> Result<String> {
158155 . context ( "failed to serialize Codex custom model configuration" )
159156}
160157
161- fn render_opencode_config ( config : & Config , has_api_key : bool ) -> Result < String > {
158+ fn render_opencode_config ( config : & Config , api_key : Option < & str > ) -> Result < String > {
162159 let mut options = serde_json:: Map :: from_iter ( [ (
163160 "baseURL" . to_string ( ) ,
164161 serde_json:: Value :: String ( config. base_url . clone ( ) ) ,
165162 ) ] ) ;
166- if has_api_key {
163+ if let Some ( api_key ) = api_key {
167164 options. insert (
168165 "apiKey" . to_string ( ) ,
169- serde_json:: Value :: String ( format ! ( "{{env:{PROVIDER_API_KEY}}}" ) ) ,
166+ serde_json:: Value :: String ( api_key . to_string ( ) ) ,
170167 ) ;
171168 }
172169
@@ -244,15 +241,15 @@ mod tests {
244241 use super :: * ;
245242
246243 #[ test]
247- fn opencode_config_uses_shared_provider_without_persisting_secret ( ) {
244+ fn opencode_config_uses_resolved_provider_secret ( ) {
248245 let rendered = render_opencode_config (
249246 & Config {
250247 base_url : "https://openrouter.ai/api/v1" . to_string ( ) ,
251248 model : "qwen/qwen3.5-9b" . to_string ( ) ,
252249 credential_id : Some ( "opaque-id" . to_string ( ) ) ,
253250 credential_resource : "test" ,
254251 } ,
255- true ,
252+ Some ( "test-api-key" ) ,
256253 )
257254 . expect ( "OpenCode config should serialize" ) ;
258255 let parsed: serde_json:: Value =
@@ -265,7 +262,7 @@ mod tests {
265262 ) ;
266263 assert_eq ! (
267264 parsed[ "provider" ] [ "intelligent-terminal" ] [ "options" ] [ "apiKey" ] ,
268- "{env:INTELLIGENT_TERMINAL_MODEL_API_KEY} "
265+ "test-api-key "
269266 ) ;
270267 assert ! ( !rendered. contains( "opaque-id" ) ) ;
271268 }
0 commit comments