From 8b6a65fc4beb412d3c0948398ee7daec84045c6f Mon Sep 17 00:00:00 2001 From: ciregenz Date: Sat, 13 Jun 2026 16:03:02 -0700 Subject: [PATCH] [eric] free-trial: tag free-lane calls with the session id so 1 task = 1 run --- backend/apps/agents/agent_manager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/apps/agents/agent_manager.py b/backend/apps/agents/agent_manager.py index 68d35c58..f1bf5c98 100644 --- a/backend/apps/agents/agent_manager.py +++ b/backend/apps/agents/agent_manager.py @@ -1650,6 +1650,11 @@ class AgentManager: "ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4-5-20251001", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5-20251001", } + # Free lane meters one run per agent session: tag every call to the cloud with the + # session id so 1 task = 1 run (without it the cloud falls back to token-coarse runs). + # The base goes straight to the cloud here (no 9Router), so the header rides through. + if getattr(global_settings, "connection_mode", "own_key") == "free-trial": + options_kwargs["env"]["ANTHROPIC_CUSTOM_HEADERS"] = f"X-Openswarm-Task-Id: {session.id}" logger.info(f"[MCP-DEBUG] Using OpenSwarm cloud proxy at {proxy_url}") elif api_type == "anthropic" and not resolved_is_9router and global_settings.anthropic_api_key: options_kwargs["env"] = {"ANTHROPIC_API_KEY": global_settings.anthropic_api_key}