mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-25 14:53:34 +00:00
fix: persist OpenAI-compatible provider and respect embeddings disable (#177)
* fix: persist OpenAI-compatible provider and respect embeddings disable (#129) Three interrelated bugs caused the agent to ignore user choices made during onboarding when using an OpenAI-compatible LLM provider: 1. Session auth ran before DB config reload, so Config::from_env() defaulted to NearAi and attempted Clerk auth before the real backend was known. Moved session auth to after final config resolution. 2. EmbeddingsConfig::resolve() force-enabled embeddings whenever OPENAI_API_KEY was present, ignoring the user's explicit disable. Changed to respect the stored setting as source of truth. 3. LLM_BACKEND was not saved to the bootstrap .env file, so Config::from_env() always defaulted to NearAi before the DB was connected. Now saves LLM_BACKEND, LLM_BASE_URL, and OLLAMA_BASE_URL alongside the database bootstrap vars. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: add SAFETY comments and sanitize .env value escaping Address PR review feedback: - Add SAFETY comments to all unsafe env var manipulation in config tests (gemini-code-assist). - Escape backslashes and double quotes in save_bootstrap_env() to prevent env var injection via malicious URLs (gemini-code-assist). - Add test verifying injection attempt is neutralized. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: incorporate PR #138 changes (chat completions, model sorting, tool schemas) Includes all changes from bigguybobby's PR #138: - Use Chat Completions API for OpenAI-compatible providers (avoids Responses API assumptions like required tool call IDs) - Fall back to settings.selected_model when LLM_MODEL env var is unset - Update OpenAI model list (add gpt-5 family) with priority-based sorting - Add is_openai_chat_model() filter with broader exclusion patterns - Fix http tool: headers schema → array of {name,value}, body → string type, parse_headers_param() accepts both legacy object and array formats - Fix json tool: data schema → string type, parse_json_input() normalizer, validate uses strict string-only check - Add mutex-serialized config tests for env var manipulation - Update NEAR AI config comment for accuracy Co-Authored-By: Bobby (bigguybobby) <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Illia Polosukhin <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Bobby (bigguybobby) <[email protected]>
This commit is contained in:
co-authored by
Illia Polosukhin
Claude Opus 4.6
Bobby
parent
c3340c60ef
commit
750a94030b
+31
-3
@@ -1054,6 +1054,37 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_openai_compatible_db_map_round_trip() {
|
||||
let settings = Settings {
|
||||
llm_backend: Some("openai_compatible".to_string()),
|
||||
openai_compatible_base_url: Some("http://my-vllm:8000/v1".to_string()),
|
||||
embeddings: EmbeddingsSettings {
|
||||
enabled: false,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let map = settings.to_db_map();
|
||||
let restored = Settings::from_db_map(&map);
|
||||
|
||||
assert_eq!(
|
||||
restored.llm_backend,
|
||||
Some("openai_compatible".to_string()),
|
||||
"llm_backend must survive DB round-trip"
|
||||
);
|
||||
assert_eq!(
|
||||
restored.openai_compatible_base_url,
|
||||
Some("http://my-vllm:8000/v1".to_string()),
|
||||
"openai_compatible_base_url must survive DB round-trip"
|
||||
);
|
||||
assert!(
|
||||
!restored.embeddings.enabled,
|
||||
"embeddings.enabled=false must survive DB round-trip"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn toml_round_trip() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
@@ -1124,8 +1155,6 @@ mod tests {
|
||||
|
||||
let mut toml_overlay = Settings::default();
|
||||
toml_overlay.agent.name = "from-toml".to_string();
|
||||
// heartbeat.interval_secs stays at default (1800) in the overlay,
|
||||
// so the base value (600) should be preserved.
|
||||
|
||||
base.merge_from(&toml_overlay);
|
||||
|
||||
@@ -1142,7 +1171,6 @@ mod tests {
|
||||
let overlay = Settings::default();
|
||||
base.merge_from(&overlay);
|
||||
|
||||
// All base values preserved since overlay is entirely default
|
||||
assert_eq!(base.agent.name, "custom-name");
|
||||
assert!(base.heartbeat.enabled);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user