diff --git a/autogpt_platform/backend/backend/copilot/sdk/cli_openrouter_compat_test.py b/autogpt_platform/backend/backend/copilot/sdk/cli_openrouter_compat_test.py index 7605c39172..20c40cc850 100644 --- a/autogpt_platform/backend/backend/copilot/sdk/cli_openrouter_compat_test.py +++ b/autogpt_platform/backend/backend/copilot/sdk/cli_openrouter_compat_test.py @@ -460,7 +460,7 @@ def _assert_no_forbidden_patterns( "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1. This is expected — the env " "var guard in test_disable_experimental_betas_env_var_strips_headers " "is the real regression test.", - strict=False, + strict=True, ) async def test_bare_cli_does_not_send_openrouter_incompatible_features(): """Bare CLI reproduction (no env var workaround). diff --git a/autogpt_platform/backend/backend/copilot/sdk/env.py b/autogpt_platform/backend/backend/copilot/sdk/env.py index 27470c9d05..d8d1561eea 100644 --- a/autogpt_platform/backend/backend/copilot/sdk/env.py +++ b/autogpt_platform/backend/backend/copilot/sdk/env.py @@ -96,5 +96,8 @@ def build_sdk_env( env["CLAUDE_CODE_DISABLE_CLAUDE_MDS"] = "1" env["CLAUDE_CODE_DISABLE_AUTO_MEMORY"] = "1" env["CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"] = "1" + # Strip Anthropic-specific beta headers (e.g. context-management-2025-06-27) + # that OpenRouter rejects. Safe for all modes — direct Anthropic ignores it. + env["CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS"] = "1" return env diff --git a/autogpt_platform/backend/backend/copilot/sdk/service.py b/autogpt_platform/backend/backend/copilot/sdk/service.py index d8b164091e..35b87cd40c 100644 --- a/autogpt_platform/backend/backend/copilot/sdk/service.py +++ b/autogpt_platform/backend/backend/copilot/sdk/service.py @@ -2242,15 +2242,6 @@ async def stream_chat_completion_sdk( if sdk_model: sdk_options_kwargs["model"] = sdk_model - # Tell the CLI to strip experimental betas (e.g. - # ``context-management-2025-06-27``) and ``tool_reference`` - # content blocks so newer SDK / CLI versions work with - # OpenRouter's stricter validation. This single env var - # replaces the old in-process compat proxy. - if sdk_env is None: - sdk_env = {} - sdk_env["CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS"] = "1" - if sdk_env: sdk_options_kwargs["env"] = sdk_env if use_resume and resume_file: