Repository navigation
fix(settings): deprecate ACPAgentSettings.llm so ACP agents keep their metrics LLM - #5434
Conversation
…r metrics LLM ACPAgentSettings.create_agent() passed llm=self.llm, replacing ACPAgent's acp-managed sentinel with the settings default (gpt-5.6). Title generation only skips the sentinel, so settings-built ACP conversations sent title requests to a real provider (#4867). Profile activation, the active_profile fold and the OpenAI gateway also copied full LLMs, keys included, into ACP settings. - create_agent() no longer passes llm - deprecate ACPAgentSettings.llm (1.51.0 -> 1.56.0): not serialized, warns when passed, dropped from the settings schema - agent settings v6->v7 and persisted settings v3->v4 drop llm from stored ACP settings - the agent server writes llm only to OpenHands settings - RemoteWorkspace.get_llm() rejects ACP settings when no profile is active Part of #5432. Fixes #4867. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Verdict: approves
Reviewed against .agents/skills/custom-codereview-guide.md, AGENTS.md, and the linked issue #5432 (labels ready-for-dev, priority:medium, acp, enhancement) plus #4867 (ready-for-dev). The change belongs in this repository (SDK settings + Agent Server), and the linked issue is implementation-ready.
What I verified on the current head
- Core fix.
ACPAgentSettings.create_agent()no longer passesllm, so a settings-builtACPAgentkeeps theacp-managedsentinel (relabelled withacp_modelwhen set). Confirmed directly:ACPAgentSettings(acp_model="sonnet").create_agent().llm->model='sonnet',usage_id='acp-managed'. This is the exact markergenerate_title_from_messageuses to skip a non-callable LLM, closing #4867. - Deprecation metadata.
Field(exclude=True, deprecated=...)plus amodel_validator(mode="before")callingwarn_deprecated("ACPAgentSettings.llm", deprecated_in="1.51.0", removed_in="1.56.0"). The 5-minor-release runway matches the SDK policy, and.github/scripts/check_deprecations.pypasses.model_dump()/model_dump_json()no longer containllm; the"LLM (for metrics)"section is gone from the exported schema. - Migration.
AGENT_SETTINGS_SCHEMA_VERSION6->7 with_migrate_agent_settings_v6_to_v7droppingllmonly foragent_kind == "acp", andPERSISTED_SETTINGS_SCHEMA_VERSION3->4 keeping the file version in step. New golden fixtures (v6/agent_settings_acp.json,v7/agent_settings_acp.json,v4/persisted_settings.json) and the updatedv3/v5expectations are consistent. Migrations run before validation, so stored v6 ACP settings load without triggering the warning (asserted bytest_validate_agent_settings_migrates_v6_acp_llm_without_warning).tests/cross/test_check_persisted_settings_compat.pypasses. - No unguarded readers. Every remaining internal access to a settings
llmis now kind-guarded:PersistedSettings.llm_api_key_is_set,provider_connections_router._active_settings_references_connection,conversation_serviceprofile launch,openai/service._with_profile_llm_and_system_text, andsettings_router._with_profile_llm.agent_profiles_routeralready gates_seed_default_llm_profileonagent_kind != "acp". This means no spuriousDeprecationWarning(orUnsupportedWarningafter 1.56.0) is emitted on normal startup paths. - Profile/credential paths. Activating a profile on ACP settings records
active_profileand returnsllm_applied: falsewithout writingllm; theactive_profilefold inspects the target kind (so a PATCH switching to OpenHands still receives the profile LLM). No credentials are persisted into ACP settings. - CI. All 52 check runs on
158f95f3aresuccess(2skippedby design), includingsdk-tests,agent-server-tests,cross-tests,Persisted settings,acp-live-tests,integration-test,check_deprecations, andunresolved-review-threads. - Local tests.
tests/sdk/test_settings.py,tests/sdk/conversation/test_generate_title.py,tests/sdk/workspace/remote/test_remote_workspace.py,tests/agent_server/test_settings_router.py,tests/agent_server/test_profiles_router.py,tests/agent_server/test_conversation_service.py,tests/agent_server/test_persistence_secret_detection.py,tests/agent_server/test_openai_gateway_settings.py, andtests/cross/test_check_persisted_settings_compat.pyall pass (568 passed). Related suites (test_apply_agent_settings_diff.py,tests/sdk/profiles,test_acp_agent.py,tests/sdk/settings,test_agent_profile_conv_start.py,test_active_meta_profile.py,test_check_deprecations.py) pass as well (498 + 789 passed).
One behavior change worth the maintainer's awareness (not blocking)
RemoteWorkspace.get_llm() now raises ValueError for ACP settings when no profile is active, instead of returning the keyless placeholder LLM. The placeholder could not be used for a call anyway (it had no credentials), so raising early is a net improvement and is covered by test_get_llm_without_active_profile_rejects_acp_settings; the PR description flags it explicitly. I note it only because it is a public SDK behavior change on a supported entry point, and a caller that previously inspected .model without calling the LLM would now see an exception.
Eval risk
No prompt, tool-description, or model-routing changes; the only observable shift is that new ACP conversations file cost under the acp-managed stats key rather than default. Totals are unchanged (get_combined_metrics() sums all keys), and persisted conversations keep their stored agent llm. This does not warrant an eval gate.
✅ APPROVED
…talog main took agent-settings schema v7 (drop the ACP llm) and persisted settings v4 in #5434, so the retired-switch fold is now the v7 -> v8 step and the settings file goes to v5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HUMAN:
Implements phase 1 of #5432 as written: ACP settings stop carrying an
llm, settings-built ACP agents keep theacp-managedsentinel, and ACP titles no longer call a provider unlesstitle_llm_profileis set. The field is removed in 1.56.0.AGENT:
Why
ACPAgentSettings.create_agent()passedllm=self.llm. That replacedACPAgent'sacp-managedsentinel with the settings default (gpt-5.6,usage_id="default"). Title generation only skips the sentinel, so every settings-built ACP conversation (canvasagent_settings, Agent Profiles, cloud) tried to title itself with a real provider call (#4867). Profile activation, theactive_profilefold and the OpenAI gateway also wrote full LLMs,api_keyincluded, into ACP settings. Nothing ever calls that LLM: the ACP subprocess makes its own model calls.Summary
create_agent()no longer passesllm, so the agent keepsacp-managed, relabelled withacp_modelwhen set.ACPAgentSettings.llmis deprecated from 1.51.0, for removal in 1.56.0:Field(deprecated=...)andexclude=True, so it is never serialized;warn_deprecated("ACPAgentSettings.llm", ...);llmfrom stored ACP settings, and persisted settings v3→v4 keeps the file version in step, like fix(llm): remove LLM.modify_params past its v1.47.0 removal deadline #4954 did. Migrations run before validation, so stored settings never trigger the warning. Golden fixtures added:v6/agent_settings_acp.json,v7/agent_settings_acp.json,v4/persisted_settings.json.active_profilefold inPATCH /api/settingsand the OpenAI gateway setllmonly on OpenHands settings.active_profile, and returnsllm_applied: false.llm_api_key_is_setand the provider-connection delete guard no longer read ACPllm.RemoteWorkspace.get_llm(): with no active profile, ACP settings now raiseValueErrorinstead of returning the keyless placeholder.Issue Number
Part of #5432 (phase 1; phase 2 deletes the field in 1.56.0).
Fixes #4867
How to Test
Live rig.
.pr/acp_title_e2e.pystarts a real agent-server with:work(keysk-profile-secret) activated while in ACP mode;OPENAI_BASE_URLpointed at a fake OpenAI endpoint that records every request;OPENAI_API_KEY=sk-server-env-keyin the server environment.main(fad6377)llm_applied: true;GET /api/settingsreturnsllm.api_key: sk-profile-secret;settings.jsonstores itllm_applied: false; nollmreturned or storedagent_settings, nollm)llm=gpt-5.6/default; title requestPOST /v1/responsesmodelgpt-5.6,Bearer sk-server-env-keyacp-managed; no request; titleFix the login bugGET /api/settingsround-tripgpt-4o-mini,Bearer sk-profile-secretacp-managed; no request; truncation titletitle_llm_profile="work"Mock Profile TitleBearer sk-profile-secret, titleMock Profile TitleLocalConversation.generate_title()on a settings-built agentgpt-5.6,Bearer sk-server-env-keyusage_id=acp-managed,model=claude-opus-4-7; no request; truncation titleVerdicts:
mainfails 3/4, this PR passes 4/4.Unit tests. Each new test fails with its fix reverted:
create_agentpassingllmagain fails 5 tests;test_validate_agent_settings_migrates_v6_acp_llm_without_warning;mainfails its own test;test_patch_settings_active_profile_applies_llm_when_switching_to_openhands.Full suites.
tests/sdk tests/agent_server tests/cross tests/workspacegave 9663 passed. Only 7canvas_extensionstests failed, and they fail identically onmainlocally; 5 xdist-only flakes pass when run serially.CI checks run locally:
check_persisted_settings_compat.pypasses. It validates 17 fixtures and 8 payloads from PyPI 1.50.1, includingagent_settings/acp_populatedv6→v7.check_agent_server_rest_api_breakage.pyreports no breaking changes.ACPAgentSettingsis not in the public OpenAPI.check_deprecations.py, ruff and pyright are clean.Type
Notes
ACPAgentSettings.llmand letACPAgentown its metrics LLM #5432 (1.51.0 → 1.56.0, 5 minors).warn_deprecatedonly fires once the release bumps to 1.51.0, so the warning tests pin the SDK version.LLMduring the window. Callers such as the cloud backend'sacp_settings.llm.model_copy(...)keep working, and its credential strip becomes a no-op. Reading the field emits pydantic'sDeprecationWarning.get_llm()behavior change: it previously returned the placeholdergpt-5.6with no key, which failed when called. Flagging it in case a reviewer prefers to keep returning it.acp-managedinstead ofdefault. Totals are unchanged, sinceget_combined_metrics()sums every key. Persisted conversations keep their stored agentllm.tests/sdk/launch/test_field_ownership.py, which classifies this field asLegacy(removed_in="1.33.0"). Whichever PR lands second updates it to 1.56.0.ACPAgentSettings.llm, so no docs change. The ACP guide'sagent.llm.metricsexample still holds..pr/acp_title_e2e.pyis the temporary e2e rig.🤖 Generated with Claude Code
🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:e838afa-pythonRun
All tags pushed for this build
About Multi-Architecture Support
e838afa-python) is a multi-arch manifest supporting both amd64 and arm64e838afa-python-amd64) are also available if needed