Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(mobile): honor OpenAI and Claude provider endpoints
trohitged987bd98658
diff --git a/docs/mobile-workspace.md b/docs/mobile-workspace.mdindex 1de5412b..0bf36450 100644--- a/docs/mobile-workspace.md+++ b/docs/mobile-workspace.md@@ -63,6 +63,8 @@ The selected model serves every mobile-use stage. OpenAI, Anthropic and Gemini aGemini backend selection follows the main AI agent: Vertex AI Express credentials use Vertex, and Developer API credentials use the Gemini Developer API. The isolated phone worker receives an explicit backend setting derived from the stored credential; it does not inherit an unrelated host setting. Terminal events include `model_backend=vertex_express` or `model_backend=gemini_developer`, without printing the credential. A rejected Android tool result is shown as a failed node, even though the handled error is returned to its calling AI agent.+OpenAI and Anthropic (Claude) use their own saved API credentials and official SDK endpoints by default. A saved OpenAI or Anthropic custom endpoint is passed unchanged to the phone engine, matching the main agent's provider configuration. All three model-selection modes support these providers. Choose a model that supports image input and tool use; a valid API key alone does not establish access to every model. Endpoint values and credentials are excluded from diagnostic logs. Client construction is verified with the installed engine SDKs; this does not constitute a live provider-generation test.+## Runtime files and Git`mobile_root()` currently resolves a relative `DATA_DIR` against the backend process’s working directory. With source development launched from `server/` and `DATA_DIR=.opencompany`, the installed phone is therefore under `server/.opencompany/mobile/`. This differs from the application’s canonical repository-relative data resolver. An absolute `DATA_DIR` avoids this ambiguity. Do not move an existing installation or switch its data directory while the backend is running.diff --git a/server/nodes/mobile/_node.py b/server/nodes/mobile/_node.pyindex 966813e9..023e8b4d 100644--- a/server/nodes/mobile/_node.py+++ b/server/nodes/mobile/_node.py@@ -105,6 +105,15 @@ async def resolve_model(ctx: NodeContext, params: MobileParams | None = None) ->model = selected_model or await get_default_model_async(provider_ref, database)provider, variable = adapters[provider_ref]model_env = {variable: key}+ endpoint_variables = {"openai": "OPENAI_BASE_URL", "anthropic": "ANTHROPIC_BASE_URL"}+ if provider_ref in endpoint_variables:+ from services.llm.endpoints import base_url_key++ endpoint = await auth.get_api_key(base_url_key(provider_ref), "default")+ if endpoint:+ # Use the same saved endpoint as the native provider, unchanged.+ # It may contain credentials, so it travels only through private IPC.+ model_env[endpoint_variables[provider_ref]] = endpointif provider_ref == "gemini":from services.llm.vertex import is_vertex_express_keydiff --git a/server/tests/test_mobile_models.py b/server/tests/test_mobile_models.pyindex 0826f198..3455cbee 100644--- a/server/tests/test_mobile_models.py+++ b/server/tests/test_mobile_models.py@@ -18,6 +18,7 @@ def models(monkeypatch):get_provider_defaults=AsyncMock(return_value={"default_model": "provider-default"}),)auth = SimpleNamespace(get_api_key=AsyncMock(return_value="selected-key"))+ auth.get_api_key.side_effect = lambda provider, *_: None if provider.endswith("_proxy") else auth.get_api_key.return_valuemonkeypatch.setattr(deps, "get_database", lambda: database)monkeypatch.setattr(deps, "get_ai_service", lambda: SimpleNamespace(auth=auth))monkeypatch.setattr(registry, "get_node_class", lambda _: SimpleNamespace(component_kind="model"))@@ -107,3 +108,28 @@ async def test_gemini_backend_matches_saved_key_type(models, monkeypatch, key, mresult = await resolve_model(ctx, params)assert result["provider"] == "google"assert result["model_env"] == {"GOOGLE_API_KEY": key, "GOOGLE_GENAI_USE_VERTEXAI": mode}++[email protected]("provider,key_var,url_var", [("openai", "OPENAI_API_KEY", "OPENAI_BASE_URL"),+ ("anthropic", "ANTHROPIC_API_KEY", "ANTHROPIC_BASE_URL")])[email protected]("source", ["global", "custom", "connected"])[email protected]("endpoint", [None, "https://model-relay.example/custom/v1"])+async def test_openai_and_claude_use_selected_model_credentials_and_endpoint(models, monkeypatch, provider, key_var, url_var, source, endpoint):+ import constants+ db, auth = models+ db.get_user_settings.return_value = {"default_llm_provider": provider, "default_llm_model": "selected-vision-model"}+ auth.get_api_key.side_effect = lambda name, *_: endpoint if name == provider + "_proxy" else "selected-key"+ ctx = context()+ params = MobileParams()+ if source == "custom":+ params = MobileParams(model_source="custom", provider=provider, model="selected-vision-model")+ elif source == "connected":+ monkeypatch.setattr(constants, "detect_ai_provider", lambda *_: provider)+ db.get_node_parameters.return_value = {"model": "selected-vision-model"}+ ctx.nodes = [{"id": "model", "type": provider + "ChatModel"}]+ ctx.edges = [{"source": "model", "target": "phone", "targetHandle": "input-model"}]+ result = await resolve_model(ctx, params)+ expected_env = {key_var: "selected-key"}+ if endpoint:+ expected_env[url_var] = endpoint+ assert result == {"provider": provider, "model": "selected-vision-model", "model_env": expected_env}