Skip to content

fix(settings): deprecate ACPAgentSettings.llm so ACP agents keep their metrics LLM - #5434

Merged
simonrosenberg merged 2 commits into
mainfrom
acp-settings-drop-llm
Oct 1, 2026
Merged

simonrosenberg merged 2 commits into
mainfrom
acp-settings-drop-llm

Conversation

@simonrosenberg

@simonrosenberg simonrosenberg commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

Implements phase 1 of #5432 as written: ACP settings stop carrying an llm, settings-built ACP agents keep the acp-managed sentinel, and ACP titles no longer call a provider unless title_llm_profile is set. The field is removed in 1.56.0.


AGENT:

Why

ACPAgentSettings.create_agent() passed llm=self.llm. That replaced ACPAgent's acp-managed sentinel with the settings default (gpt-5.6, usage_id="default"). Title generation only skips the sentinel, so every settings-built ACP conversation (canvas agent_settings, Agent Profiles, cloud) tried to title itself with a real provider call (#4867). Profile activation, the active_profile fold and the OpenAI gateway also wrote full LLMs, api_key included, into ACP settings. Nothing ever calls that LLM: the ACP subprocess makes its own model calls.

Summary

  • SDK: create_agent() no longer passes llm, so the agent keeps acp-managed, relabelled with acp_model when set. ACPAgentSettings.llm is deprecated from 1.51.0, for removal in 1.56.0:
    • it has Field(deprecated=...) and exclude=True, so it is never serialized;
    • passing it calls warn_deprecated("ACPAgentSettings.llm", ...);
    • the "LLM (for metrics)" section is gone from the settings schema.
  • Migrations: agent settings v6→v7 drops llm from 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.
  • Agent server:
    • Profile activation, the active_profile fold in PATCH /api/settings and the OpenAI gateway set llm only on OpenHands settings.
    • Activating a profile on ACP settings still records active_profile, and returns llm_applied: false.
    • The fold checks the target kind, so a PATCH that switches to OpenHands still gets the profile's LLM.
    • llm_api_key_is_set and the provider-connection delete guard no longer read ACP llm.
  • RemoteWorkspace.get_llm(): with no active profile, ACP settings now raise ValueError instead 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.py starts a real agent-server with:

  • global ACP settings that run the canvas mock ACP server;
  • an LLM profile work (key sk-profile-secret) activated while in ACP mode;
  • OPENAI_BASE_URL pointed at a fake OpenAI endpoint that records every request;
  • OPENAI_API_KEY=sk-server-env-key in the server environment.
python .pr/acp_title_e2e.py --sdk <checkout> \
  --mock-acp ~/repositories/agent-canvas/tests/e2e/mock-llm/scripts/mock-acp-server.py
Step main (fad6377) this PR
Activate LLM profile on ACP settings llm_applied: true; GET /api/settings returns llm.api_key: sk-profile-secret; settings.json stores it llm_applied: false; no llm returned or stored
1. Canvas-style launch (ACP agent_settings, no llm) agent llm = gpt-5.6 / default; title request POST /v1/responses model gpt-5.6, Bearer sk-server-env-key acp-managed; no request; title Fix the login bug
2. Launch from GET /api/settings round-trip title request gpt-4o-mini, Bearer sk-profile-secret acp-managed; no request; truncation title
3. Launch with title_llm_profile="work" profile used, title Mock Profile Title same: profile used, Bearer sk-profile-secret, title Mock Profile Title
4. SDK LocalConversation.generate_title() on a settings-built agent title request gpt-5.6, Bearer sk-server-env-key usage_id=acp-managed, model=claude-opus-4-7; no request; truncation title

Verdicts: main fails 3/4, this PR passes 4/4.

Unit tests. Each new test fails with its fix reverted:

  • create_agent passing llm again fails 5 tests;
  • the migration as a no-op fails test_validate_agent_settings_migrates_v6_acp_llm_without_warning;
  • each agent-server file reverted to main fails its own test;
  • a fold that only looks at the persisted kind fails test_patch_settings_active_profile_applies_llm_when_switching_to_openhands.
uv run pytest 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 \
  tests/cross/test_check_persisted_settings_compat.py

Full suites. tests/sdk tests/agent_server tests/cross tests/workspace gave 9663 passed. Only 7 canvas_extensions tests failed, and they fail identically on main locally; 5 xdist-only flakes pass when run serially.

CI checks run locally:

  • check_persisted_settings_compat.py passes. It validates 17 fixtures and 8 payloads from PyPI 1.50.1, including agent_settings/acp_populated v6→v7.
  • check_agent_server_rest_api_breakage.py reports no breaking changes. ACPAgentSettings is not in the public OpenAPI.
  • check_deprecations.py, ruff and pyright are clean.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

  • Deprecation versions follow [Feature]: Remove ACPAgentSettings.llm and let ACPAgent own its metrics LLM #5432 (1.51.0 → 1.56.0, 5 minors). warn_deprecated only fires once the release bumps to 1.51.0, so the warning tests pin the SDK version.
  • The field stays typed LLM during the window. Callers such as the cloud backend's acp_settings.llm.model_copy(...) keep working, and its credential strip becomes a no-op. Reading the field emits pydantic's DeprecationWarning.
  • get_llm() behavior change: it previously returned the placeholder gpt-5.6 with no key, which failed when called. Flagging it in case a reviewer prefers to keep returning it.
  • Stats: ACP cost for new conversations is filed under acp-managed instead of default. Totals are unchanged, since get_combined_metrics() sums every key. Persisted conversations keep their stored agent llm.
  • Related PRs:
  • Docs: OpenHands/docs never documented ACPAgentSettings.llm, so no docs change. The ACP guide's agent.llm.metrics example still holds.
  • .pr/acp_title_e2e.py is 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

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:e838afa-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-e838afa-python \
  ghcr.io/openhands/agent-server:e838afa-python

All tags pushed for this build

ghcr.io/openhands/agent-server:e838afa-golang-amd64
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-golang-amd64
ghcr.io/openhands/agent-server:acp-settings-drop-llm-golang-amd64
ghcr.io/openhands/agent-server:e838afa-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:e838afa-golang-arm64
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-golang-arm64
ghcr.io/openhands/agent-server:acp-settings-drop-llm-golang-arm64
ghcr.io/openhands/agent-server:e838afa-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:e838afa-java-amd64
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-java-amd64
ghcr.io/openhands/agent-server:acp-settings-drop-llm-java-amd64
ghcr.io/openhands/agent-server:e838afa-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:e838afa-java-arm64
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-java-arm64
ghcr.io/openhands/agent-server:acp-settings-drop-llm-java-arm64
ghcr.io/openhands/agent-server:e838afa-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:e838afa-python-amd64
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-python-amd64
ghcr.io/openhands/agent-server:acp-settings-drop-llm-python-amd64
ghcr.io/openhands/agent-server:e838afa-python-node-runtime-amd64
ghcr.io/openhands/agent-server:e838afa-python-arm64
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-python-arm64
ghcr.io/openhands/agent-server:acp-settings-drop-llm-python-arm64
ghcr.io/openhands/agent-server:e838afa-python-node-runtime-arm64
ghcr.io/openhands/agent-server:e838afa-python-minimal-amd64
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-python-minimal-amd64
ghcr.io/openhands/agent-server:acp-settings-drop-llm-python-minimal-amd64
ghcr.io/openhands/agent-server:e838afa-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:e838afa-python-minimal-arm64
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-python-minimal-arm64
ghcr.io/openhands/agent-server:acp-settings-drop-llm-python-minimal-arm64
ghcr.io/openhands/agent-server:e838afa-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:e838afa-python-slim-amd64
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-python-slim-amd64
ghcr.io/openhands/agent-server:acp-settings-drop-llm-python-slim-amd64
ghcr.io/openhands/agent-server:e838afa-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:e838afa-python-slim-arm64
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-python-slim-arm64
ghcr.io/openhands/agent-server:acp-settings-drop-llm-python-slim-arm64
ghcr.io/openhands/agent-server:e838afa-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:e838afa-golang
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-golang
ghcr.io/openhands/agent-server:acp-settings-drop-llm-golang
ghcr.io/openhands/agent-server:e838afa-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:e838afa-java
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-java
ghcr.io/openhands/agent-server:acp-settings-drop-llm-java
ghcr.io/openhands/agent-server:e838afa-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:e838afa-python-minimal
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-python-minimal
ghcr.io/openhands/agent-server:acp-settings-drop-llm-python-minimal
ghcr.io/openhands/agent-server:e838afa-python-node-runtime-minimal
ghcr.io/openhands/agent-server:e838afa-python-slim
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-python-slim
ghcr.io/openhands/agent-server:acp-settings-drop-llm-python-slim
ghcr.io/openhands/agent-server:e838afa-python-node-runtime-slim
ghcr.io/openhands/agent-server:e838afa-python
ghcr.io/openhands/agent-server:e838afaf7037fa2a6530f0d5a3ac5afe4c7941a8-python
ghcr.io/openhands/agent-server:acp-settings-drop-llm-python
ghcr.io/openhands/agent-server:e838afa-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., e838afa-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., e838afa-python-amd64) are also available if needed

…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>
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
  ✅ **PR Artifacts Cleaned Up**

  The `.pr/` directory is no longer present.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   profiles_router.py200697%502–507
   provider_connections_router.py125993%177–178, 196, 206, 234–235, 257, 267–268
   settings_router.py193697%223, 552, 554–555, 593, 598
openhands-agent-server/openhands/agent_server/openai
   service.py2825282%86, 95–96, 100–101, 105–106, 155, 159–169, 171, 175–177, 181, 196, 225–227, 231–233, 267, 279, 284, 380, 385, 397, 405, 410, 419, 437–440, 537–538, 589, 599–600, 631, 642, 709
openhands-agent-server/openhands/agent_server/persistence
   models.py2372789%54, 405, 410, 448, 496, 536–542, 544, 546, 549, 553, 579, 596–597, 642, 646, 648, 677–680, 683
openhands-sdk/openhands/sdk/settings
   model.py8436992%316, 334, 542, 559, 569–572, 575, 588, 592, 598, 608, 614, 619, 744, 747–748, 754–757, 762, 766, 781, 784–786, 834, 839–840, 845, 866, 878, 927, 936, 983, 1172, 1197, 1199, 1201, 1203, 1205, 1207, 1209, 1211, 1213, 1215, 1545, 1547, 1853, 1873, 2005, 2134, 2173, 2328–2330, 2332, 2418, 2428, 2430, 2435, 2453, 2466, 2468, 2470, 2472, 2479
openhands-sdk/openhands/sdk/workspace/remote
   base.py3104087%84–85, 127–131, 290–300, 304, 387, 446, 565, 614, 616–618, 674–675, 683, 764–769, 807, 852–854, 875
TOTAL46618828382% 

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 passes llm, so a settings-built ACPAgent keeps the acp-managed sentinel (relabelled with acp_model when set). Confirmed directly: ACPAgentSettings(acp_model="sonnet").create_agent().llm -> model='sonnet', usage_id='acp-managed'. This is the exact marker generate_title_from_message uses to skip a non-callable LLM, closing #4867.
  • Deprecation metadata. Field(exclude=True, deprecated=...) plus a model_validator(mode="before") calling warn_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.py passes. model_dump() / model_dump_json() no longer contain llm; the "LLM (for metrics)" section is gone from the exported schema.
  • Migration. AGENT_SETTINGS_SCHEMA_VERSION 6->7 with _migrate_agent_settings_v6_to_v7 dropping llm only for agent_kind == "acp", and PERSISTED_SETTINGS_SCHEMA_VERSION 3->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 updated v3/v5 expectations are consistent. Migrations run before validation, so stored v6 ACP settings load without triggering the warning (asserted by test_validate_agent_settings_migrates_v6_acp_llm_without_warning). tests/cross/test_check_persisted_settings_compat.py passes.
  • No unguarded readers. Every remaining internal access to a settings llm is now kind-guarded: PersistedSettings.llm_api_key_is_set, provider_connections_router._active_settings_references_connection, conversation_service profile launch, openai/service._with_profile_llm_and_system_text, and settings_router._with_profile_llm. agent_profiles_router already gates _seed_default_llm_profile on agent_kind != "acp". This means no spurious DeprecationWarning (or UnsupportedWarning after 1.56.0) is emitted on normal startup paths.
  • Profile/credential paths. Activating a profile on ACP settings records active_profile and returns llm_applied: false without writing llm; the active_profile fold 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 158f95f3 are success (2 skipped by design), including sdk-tests, agent-server-tests, cross-tests, Persisted settings, acp-live-tests, integration-test, check_deprecations, and unresolved-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, and tests/cross/test_check_persisted_settings_compat.py all 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

@simonrosenberg simonrosenberg self-assigned this Oct 1, 2026
@simonrosenberg
simonrosenberg merged commit 0a9abc8 into main Oct 1, 2026
51 of 52 checks passed
@simonrosenberg
simonrosenberg deleted the acp-settings-drop-llm branch October 1, 2026 13:02
@github-actions github-actions Bot mentioned this pull request Oct 2, 2026
1 of 7 tasks
simonrosenberg added a commit that referenced this pull request Oct 2, 2026
…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>
@github-actions github-actions Bot mentioned this pull request Oct 3, 2026
1 of 7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ACP mode: conversation title generation fails with missing credentials (explicit LLM without a key)

2 participants