HKUDS/Vibe-Trading · error · ValueError
local connection profile does not match the requested plugin
Error message
local connection profile does not match the requested plugin
What it means
This error is thrown by _local_plugin_call when routing a trading operation to a local connector plugin. Before invoking the plugin adapter, the service verifies that the resolved connection (looked up via connection_id from the overrides) belongs to the same connector profile that the plugin was resolved from. If connection.profile_id differs from profile.id, the call is rejected because the plugin would operate with another profile's credentials/settings.
Source
Thrown at agent/src/trading/service.py:59
def _local_plugin_call(
profile: TradingProfile,
operation: str,
overrides: dict[str, Any],
*args: Any,
**kwargs: Any,
) -> dict[str, Any]:
"""Call a read operation on a user-installed local connector adapter."""
from src.trading.connections import ConnectionStore, credential_fields
from src.trading.local_plugins import load_adapter, plugin_by_profile_id
connection_id = str(overrides.get("connection_id") or "").strip().lower()
if not connection_id:
raise ValueError("local connector plugins require a connection_id")
store = ConnectionStore()
connection = store.get(connection_id)
if connection.profile_id != profile.id:
raise ValueError("local connection profile does not match the requested plugin")
plugin = plugin_by_profile_id(profile.id)
adapter = load_adapter(plugin)
function = getattr(adapter, operation, None)
if not callable(function):
return _unsupported(profile, operation)
credentials = store.credentials.load(connection.id, credential_fields(profile.id))
return function(
*args,
credentials=credentials,
config=dict(profile.config),
**kwargs,
)
def check_connection(profile_id: str | None = None, **overrides: Any) -> dict[str, Any]:
"""Check a connector profile without mutating broker state."""
profile = profile_by_id(profile_id)
if profile.transport == "local_tws":View on GitHub (pinned to 80ffdda44c)
Solutions
- Verify the connection_id in overrides corresponds to a connection whose profile_id matches the plugin's profile (print store.get(connection_id).profile_id and compare to profile.id)
- If the profile was recreated or renamed, create a new connection under the current profile and use its connection_id
- Audit ConnectionStore contents and delete/prune connections that reference defunct profile ids
- Ensure your broker/environment routing logic passes a connection_id from the same profile family as the requested plugin
Example fix
# before
result = service.get_account(profile, "get_account", {"connection_id": "old-paper-conn"})
# after
store = ConnectionStore()
conn = store.get("my-connection")
assert conn.profile_id == profile.id, f"connection belongs to {conn.profile_id}, plugin is {profile.id}"
result = service.get_account(profile, "get_account", {"connection_id": conn.id}) Defensive patterns
Strategy: validation
Validate before calling
from agent.src.trading.service import plugin_by_profile_id
from agent.src.trading.store import ConnectionStore
def assert_connection_matches(profile, overrides):
cid = str(overrides.get("connection_id") or "").strip().lower()
if not cid:
raise ValueError("connection_id required for local plugins")
conn = ConnectionStore().get(cid)
if conn.profile_id != profile.id:
raise ValueError(f"connection {cid} belongs to profile {conn.profile_id}, expected {profile.id}")
return conn Type guard
def connection_matches_profile(store, connection_id: str, profile) -> bool:
try:
return store.get(connection_id).profile_id == profile.id
except KeyError:
return False Prevention
- Always source connection_id from the same profile object you pass to the trading call
- Regenerate connections whenever a connector profile is recreated or its id changes
- Periodically prune ConnectionStore entries whose profile_id no longer resolves
When it happens
Trigger: Calling any of check_connection, get_account, get_positions, get_open_orders, get_quote, or get_history with overrides whose connection_id points to a ConnectionStore connection created under a different profile than the plugin being invoked (e.g. mixing a paper-connection id with a live profile, or a connection made for a different broker adapter).
Common situations: Stale connection ids persisted from a previous profile configuration, copying connection ids between environments (paper vs live), renaming/recreating connector profiles so old connections keep pointing at old profile ids, or passing the wrong connection_id in multi-broker setups.
Related errors
- unknown universe {universe!r}; expected one of {sorted(_VALI
- local connection {existing.id} already uses profile {existin
- broker must not be blank
- unknown zoo {v!r}; expected one of {sorted(_VALID_ZOOS)}
- unknown universe {v!r}; expected one of {sorted(_BENCH_UNIVE
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/0cb8d8e785f9a3bc.
Report an issue: GitHub.