Repository navigation
feat(sdk): deprecate ACPAgentSettings.llm credentials — create_agent no longer reads llm.api_key/base_url - #3652
Conversation
…o longer reads llm.api_key/base_url ACPAgentSettings.llm is attribution-only (the ACP subprocess makes its own model calls), but create_agent() folded llm.api_key/llm.base_url into agent_context.secrets via resolve_provider_env(). A proxy base_url from an LLM profile would silently re-route the subprocess's API calls (#3632). Both production clients already route provider credentials via request.secrets keyed by the provider env var name (canvas never sends llm; OpenHands strips the credentials before create_agent), so the fold only fired for direct-SDK callers. create_agent() now warns and ignores llm credentials; resolve_provider_env() warns on call. Both are scheduled for removal in 1.29.0 together with acp_env. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
||||||||||||||||||||||||||||||
all-hands-bot
left a comment
There was a problem hiding this comment.
✅ QA Report: PASS
Verified the SDK behavior directly: deprecated ACPAgentSettings.llm credentials are ignored by create_agent(), a deprecation warning is emitted, and the explicit conversation-secrets path still carries provider credentials.
Does this PR achieve its stated goal?
Yes. The PR set out to stop create_agent() from reading llm.api_key / llm.base_url for ACP agents while warning direct SDK callers and preserving the canonical secrets channel. In the before/after SDK runs, origin/main injected OPENAI_API_KEY and OPENAI_BASE_URL into agent_context.secrets with no warning, while the PR emitted the deprecation warning and left only the caller-provided GITHUB_TOKEN; a separate ConversationSettings.create_request(StartConversationRequest) run confirmed explicit ANTHROPIC_API_KEY / GITHUB_TOKEN secrets still reach request.secrets.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed successfully with uv-managed dependencies installed. |
| CI Status | ⏳ GitHub checks snapshot: 25 pass, 7 pending, 14 skipped; no failing checks observed. |
| Functional Verification | ✅ Public SDK calls exercised the changed behavior and compatibility path. |
Functional Verification
Test 1: create_agent() no longer folds llm credentials into ACP secrets
Step 1 — Reproduce / establish baseline without the fix:
Checked out origin/main and ran a direct SDK script constructing ACPAgentSettings(acp_server="codex", llm=LLM(api_key=..., base_url=...), agent_context=...), then called settings.create_agent().
Relevant output:
branch_behavior=baseline_main
warning_count= 0
warning_messages= []
acp_env= {'MY_VAR': 'v'}
agent_context_present= True
secret_keys= ['GITHUB_TOKEN', 'OPENAI_API_KEY', 'OPENAI_BASE_URL']
secret_value[GITHUB_TOKEN]=ghp_context
secret_value[OPENAI_API_KEY]=sk-openai-baseline
secret_value[OPENAI_BASE_URL]=https://llm-proxy.example.com
This confirms the old behavior: direct SDK callers had llm.api_key and llm.base_url folded into ACP agent context secrets, which is the leak/re-routing foot-gun described by the PR.
Step 2 — Apply the PR's changes:
Checked out commit 072a52bb1b829f64f63696e6137f71343aadc0be.
Step 3 — Re-run with the fix in place:
Ran the equivalent direct SDK script against the PR commit.
Relevant output:
branch_behavior=pr_head
warning_count= 1
warning_messages= ["ACPAgentSettings.llm credentials (api_key/base_url) is deprecated as of 1.28.0 and will be removed in 1.29.0. create_agent() ignores them. Supply ACP provider credentials as conversation secrets (agent_context.secrets / StartConversationRequest.secrets, which route through state.secret_registry) keyed by the provider's env var name (e.g. ANTHROPIC_API_KEY)."]
acp_env= {'MY_VAR': 'v'}
agent_context_present= True
secret_keys= ['GITHUB_TOKEN']
secret_value[GITHUB_TOKEN]=ghp_context
This shows the fix works: the deprecated credentials are not injected as OPENAI_API_KEY / OPENAI_BASE_URL, caller-provided context secrets remain intact, and direct SDK callers get an explicit deprecation warning.
Test 2: ignored credentials do not synthesize a new AgentContext
Step 1 — Baseline behavior being changed:
The pre-PR behavior synthesized an AgentContext when only llm.api_key was supplied, because it needed somewhere to store folded provider credentials.
Step 2 — Apply the PR's changes:
Used the PR commit and constructed ACPAgentSettings(acp_server="claude-code", llm=LLM(api_key=...)) with no caller context.
Step 3 — Run with the fix in place:
Relevant output:
scenario=no_context_llm_credentials
warning_count= 1
warning_contains_llm_credentials= True
agent_context_is_none= True
acp_env= {}
This confirms deprecated credentials are ignored rather than creating a synthetic context, with the warning as the caller-visible migration signal.
Test 3: canonical conversation secrets path still works
Step 1 — Baseline behavior that must remain available:
The PR description says provider credentials should ride agent_context.secrets / StartConversationRequest.secrets, keyed by provider env var, instead of llm credentials.
Step 2 — Apply the PR's changes:
On the PR commit, constructed ConversationSettings with an ACP agent whose agent_context.secrets included ANTHROPIC_API_KEY and GITHUB_TOKEN, then called create_request(StartConversationRequest) using a real LocalWorkspace.
Step 3 — Run with the fix in place:
Relevant output:
scenario=create_request_explicit_context_secrets
workspace_kind= LocalWorkspace
request_secret_keys= ['ANTHROPIC_API_KEY', 'GITHUB_TOKEN']
request_secret_value[ANTHROPIC_API_KEY]=sk-direct
request_secret_value[GITHUB_TOKEN]=ghp_direct
This confirms the replacement channel still carries explicit provider credentials into the start request as intended.
Test 4: deprecated resolve_provider_env() remains functional during the window
Step 1 — Baseline compatibility requirement:
The PR claims resolve_provider_env() remains functional but now warns callers during the deprecation window.
Step 2 — Apply the PR's changes:
On the PR commit, constructed Gemini ACP settings with llm.api_key and llm.base_url, then called resolve_provider_env().
Step 3 — Run with the fix in place:
Relevant output:
scenario=deprecated_resolve_provider_env
env= {'GEMINI_API_KEY': 'sk-test-gemini', 'GEMINI_BASE_URL': 'https://gemini-proxy.example.com'}
warning_count= 1
warning_contains_resolve_provider_env= True
This confirms the helper still returns the expected provider env mapping while emitting the promised deprecation warning.
Issues Found
None.
This review was created by an AI agent (OpenHands) on behalf of the user.
Final verdict: PASS
|
@OpenHands find the deprecation policy for python public api, the one with 5 minor releases. This pr used deprecation inconsistently? Verify. Why are the griffe and oasdiff workflows not falling? Wdyt should they fail in this case? explain. Respond as a comment on github here. |
|
I'm on it! enyst can track my progress at all-hands.dev |
|
@enyst it's true that I fast-tracked the deprecation... But I really want this out before acp cloud release, this way secrets will be handled cleanly by everyone when it's out... |
|
@enyst I checked the SDK policy and this PR’s markers. Policy I found
Consistency check I agree the PR is inconsistent if read as a public API removal plan:
The behavioral change itself — Why the workflows pass
My take I don’t think oasdiff should fail here. I also don’t think the Griffe breakage check, as currently scoped, should fail on the credential-fold behavior change because the Python API shape is unchanged. But I do think we should avoid leaving a public API deprecation schedule that CI will reject later. Either:
If we want this caught before the future removal PR, the best workflow improvement would be in This comment was created by an AI agent (OpenHands) in response to the requested PR review comment. |
…qualified member marker Public-API removals require removed_in >= deprecated_in + 5 minor releases (openhands-sdk AGENTS.md, enforced by check_sdk_api_breakage.py at release time by qualified feature name). Move resolve_provider_env and the llm field to removed_in=1.33.0 and rename the create_agent warning feature to 'ACPAgentSettings.llm' so the marker matches the member at removal time. acp_env stays on its compliant 1.24.0->1.29.0 schedule. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
902436a to
4ddce21
Compare
|
@enyst Good catch — the schedule was non-compliant, fixed in 4ddce21. I verified the analysis against the policy ( Changes:
No policy exception needed: the thing the ACP cloud release depends on is the behavior (credentials no longer read from Agreed on the workflow gap: |
enyst
left a comment
There was a problem hiding this comment.
LGTM. I rechecked the updated deprecation schedule: ACPAgentSettings.resolve_provider_env and the ACPAgentSettings.llm marker now use 1.28.0 → 1.33.0, matching the 5-minor public SDK API runway, while the behavioral fix remains scoped to ignoring deprecated llm credentials and routing credentials through the secrets channel. CI is green.
This review was submitted by an AI agent (OpenHands) on behalf of the user.
all-hands-bot
left a comment
There was a problem hiding this comment.
✅ QA Report: PASS
Verified the ACP SDK settings behavior with real SDK calls: PR head stops llm credential propagation while preserving the conversation-secret path.
Does this PR achieve its stated goal?
Yes. On origin/main, constructing an ACP agent with llm.api_key and llm.base_url injected ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL into both agent_context and StartConversationRequest.secrets with no warning. On PR head 4ddce219, the same SDK usage produced no injected secrets and emitted a deprecation warning compatible with DeprecationWarning; supplying credentials through agent_context.secrets still reached StartConversationRequest.secrets unchanged.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed successfully; no tests, linters, or pre-commit hooks were run manually. |
| CI Status | ✅ GitHub reports 34 successful checks, 2 skipped, 0 failing, 0 pending. |
| Functional Verification | ✅ Direct SDK usage confirms the old leak is gone and the supported secrets channel still works. |
Functional Verification
Test 1: llm.api_key / llm.base_url no longer propagate into ACP agent/request secrets
Step 1 — Reproduce / establish baseline without the fix:
Ran git checkout --detach origin/main && OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/acp_qa.py, where the script constructed ACPAgentSettings(acp_server="claude-code", llm=LLM(... api_key=..., base_url=...)), called create_agent(), ConversationSettings.create_request(StartConversationRequest), and resolve_provider_env():
{
"create_agent_with_llm_credentials": {
"context_is_none": false,
"secret_keys": [
"ANTHROPIC_API_KEY",
"ANTHROPIC_BASE_URL"
],
"warnings": []
},
"create_request_with_llm_credentials": {
"request_secret_keys": [
"ANTHROPIC_API_KEY",
"ANTHROPIC_BASE_URL"
],
"warnings": []
},
"resolve_provider_env": {
"env_keys": [
"ANTHROPIC_API_KEY",
"ANTHROPIC_BASE_URL"
],
"warnings": []
}
}This confirms the baseline bug: an LLM profile base URL/API key is silently folded into the ACP secrets path.
Step 2 — Apply the PR's changes:
Checked out acp-deprecate-llm-creds at 4ddce219e453a3fb75aa9e3200ee05d35aae229e.
Step 3 — Re-run with the fix in place:
Ran OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/acp_qa.py on the PR branch:
{
"create_agent_with_llm_credentials": {
"context_is_none": true,
"secret_keys": [],
"warnings": [
"DeprecatedWarning: ACPAgentSettings.llm is deprecated as of 1.28.0 and will be removed in 1.33.0. create_agent() ignores its api_key/base_url. Supply ACP provider credentials as conversation secrets (agent_context.secrets / StartConversationRequest.secrets, which route through state.secret_registry) keyed by the provider's env var name (e.g. ANTHROPIC_API_KEY); use acp_model for model identity."
]
},
"create_request_with_llm_credentials": {
"request_secret_keys": [],
"warnings": [
"DeprecatedWarning: ACPAgentSettings.llm is deprecated as of 1.28.0 and will be removed in 1.33.0. create_agent() ignores its api_key/base_url. Supply ACP provider credentials as conversation secrets (agent_context.secrets / StartConversationRequest.secrets, which route through state.secret_registry) keyed by the provider's env var name (e.g. ANTHROPIC_API_KEY); use acp_model for model identity."
]
},
"resolve_provider_env": {
"env_keys": [
"ANTHROPIC_API_KEY",
"ANTHROPIC_BASE_URL"
],
"warnings": [
"DeprecatedWarning: ACPAgentSettings.resolve_provider_env is deprecated as of 1.28.0 and will be removed in 1.33.0. Supply ACP provider credentials as conversation secrets (agent_context.secrets / StartConversationRequest.secrets, which route through state.secret_registry) keyed by the provider's env var name instead of ACPAgentSettings.llm."
]
}
}This confirms the PR behavior: create_agent()/create_request() ignore llm credentials and warn, while resolve_provider_env() remains functional during the deprecation window and warns.
Test 2: Supported agent_context.secrets channel still works
Using the same script, I supplied fake provider credentials through AgentContext(secrets={"ANTHROPIC_API_KEY": ..., "GITHUB_TOKEN": ...}) and created a StartConversationRequest.
Baseline and PR both produced:
{
"create_agent_with_context_secret": {
"context_is_none": false,
"secret_keys": [
"ANTHROPIC_API_KEY",
"GITHUB_TOKEN"
]
},
"create_request_with_context_secret": {
"request_secret_keys": [
"ANTHROPIC_API_KEY",
"GITHUB_TOKEN"
]
}
}This confirms the intended replacement path still works for a real SDK caller: named secrets supplied through agent_context.secrets are lifted into StartConversationRequest.secrets.
Issues Found
None.
Final verdict: PASS.
This QA review was created by an AI agent (OpenHands) on behalf of the user.
…no longer reads llm.api_key/base_url (OpenHands#3652) Co-authored-by: Simon Rosenberg <simon@openhands.dev> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
HUMAN:
deprecate ACPAgentSettings.llm credentials — create_agent no longer reads llm.api_key/base_url
AGENT:
Why
Fixes #3632; part of OpenHands/OpenHands#15722.
ACPAgentSettings.llmis attribution-only — the ACP subprocess makes its own model calls — butcreate_agent()foldedllm.api_key/llm.base_urlintoagent_context.secretsviaresolve_provider_env(). When a user's LLM profile carries a proxybase_url(e.g. an eval proxy), it leaked into the ACP subprocess asOPENAI_BASE_URL/ANTHROPIC_BASE_URLand silently re-routed its API calls, surfacing only as an opaque-32603 Internal error(#3632).Neither production client needs the fold:
llmfor ACP (ACP_SETTINGS_KEYSexcludes it); credentials ride top-levelrequest.secretskeyed byapi_key_env_var.llm.api_key/llm.base_urlbeforecreate_agent()as a caller-side guard (kept by feat(acp): add model dropdown and credential fields to agent settings page OpenHands#14733, which also moves provider credentials to ordinary named secrets ridingrequest.secrets).So the fold only ever fired for direct-SDK callers — where it was a silent foot-gun rather than a feature.
Summary
create_agent()no longer readsllm.api_key/llm.base_url. If either is set, it emits aDeprecationWarning(featureACPAgentSettings.llm, removed in 1.33.0) pointing at the conversation secrets channel (agent_context.secrets/StartConversationRequest.secrets→state.secret_registry, keyed by the provider's env var name) and ignores them.resolve_provider_env()is deprecated (warns on call, still functional through the window) — scheduled for removal in 1.33.0 together with thellmfield itself (1.28.0 + the 5-minor public-API runway;acp_envkeeps its own compliant 1.24.0 → 1.29.0 schedule).ACPAgentSettings.llmfield description and class docstring mark the field DEPRECATED (removed in 1.33.0);acp_modelis the model identity, attribution stays internal.agent_contextfield description,resolve_acp_env()docstring,_start_acp_servercomment, and test docstrings.create_requestlift test now supplies the provider credential as anagent_contextsecret keyed byANTHROPIC_API_KEY(the canonical channel, unchanged behavior).No schema change: the
llmfield stays (accepted, attribution-only) until the 1.33.0 removal train, so persisted payloads and the discriminated union are untouched.How to Test
uv run pytest tests/sdk/test_settings.py tests/sdk/agent/test_acp_agent.py tests/sdk/settings/ tests/agent_server/test_settings_router.py tests/sdk/test_apply_agent_settings_diff.py— all pass.ACPAgentSettings(acp_server="claude-code", llm=LLM(model="m", api_key=SecretStr("k"))).create_agent()→ emitsDeprecationWarningforACPAgentSettings.llm credentials;agent.agent_contextcarries no injectedANTHROPIC_API_KEY.agent_context.secrets={"ANTHROPIC_API_KEY": ...}→ reachesrequest.secretsviacreate_requestexactly as before.🤖 Generated with Claude Code
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimgolang: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:4ddce21-pythonRun
All tags pushed for this build
About Multi-Architecture Support
4ddce21-python) is a multi-arch manifest supporting both amd64 and arm644ddce21-python-amd64) are also available if needed