@@ -42,6 +42,7 @@ def test_settings_no_keys_returns_none() -> None:
4242
4343 assert settings .api_key is None
4444 assert settings .api_base is None
45+ assert settings .client_args == {"extra_headers" : {"HTTP-Referer" : "https://bub.build/" , "X-Title" : "Bub" }}
4546
4647
4748def test_settings_provider_names_are_lowercased () -> None :
@@ -74,6 +75,10 @@ def test_settings_load_values_from_yaml(tmp_path: Path) -> None:
7475 openai: sk-yaml
7576api_base:
7677 openai: https://api.openai.com
78+ client_args:
79+ extra_headers:
80+ HTTP-Referer: https://openclaw.ai
81+ X-Title: OpenClaw
7782""" .strip (),
7883 )
7984
@@ -85,6 +90,9 @@ def test_settings_load_values_from_yaml(tmp_path: Path) -> None:
8590 assert settings .max_steps == 77
8691 assert settings .api_key == {"openai" : "sk-yaml" }
8792 assert settings .api_base == {"openai" : "https://api.openai.com" }
93+ assert settings .client_args == {
94+ "extra_headers" : {"HTTP-Referer" : "https://openclaw.ai" , "X-Title" : "OpenClaw" },
95+ }
8896
8997
9098def test_env_settings_override_yaml (tmp_path : Path ) -> None :
@@ -94,6 +102,10 @@ def test_env_settings_override_yaml(tmp_path: Path) -> None:
94102model: openai:gpt-5
95103api_key: sk-yaml
96104max_steps: 77
105+ client_args:
106+ extra_headers:
107+ HTTP-Referer: https://yaml.example
108+ X-Title: YAML App
97109""" .strip (),
98110 )
99111
@@ -103,6 +115,7 @@ def test_env_settings_override_yaml(tmp_path: Path) -> None:
103115 "BUB_HOME" : str (tmp_path ),
104116 "BUB_MODEL" : "anthropic:claude-3-7-sonnet" ,
105117 "BUB_API_KEY" : "sk-env" ,
118+ "BUB_CLIENT_ARGS" : '{"extra_headers":{"HTTP-Referer":"https://env.example","X-Title":"Env App"}}' ,
106119 "BUB_MAX_STEPS" : "12" ,
107120 },
108121 clear = True ,
@@ -112,6 +125,15 @@ def test_env_settings_override_yaml(tmp_path: Path) -> None:
112125 assert settings .model == "anthropic:claude-3-7-sonnet"
113126 assert settings .api_key == "sk-env"
114127 assert settings .max_steps == 12
128+ assert settings .client_args == {
129+ "extra_headers" : {"HTTP-Referer" : "https://env.example" , "X-Title" : "Env App" },
130+ }
131+
132+
133+ def test_settings_client_args_can_be_disabled () -> None :
134+ settings = _settings_with_env ({"BUB_CLIENT_ARGS" : "null" })
135+
136+ assert settings .client_args is None
115137
116138
117139def test_load_settings_reads_yaml_from_bub_home (tmp_path : Path ) -> None :
0 commit comments