Skip to content

The agent that grows with you

feat(connectors): connector results name the account they ran under

Siddharth Balyan8c86e112f717
diff --git a/tools/connectors/dispatch.py b/tools/connectors/dispatch.py
index b3d97aadb48..f00b4f9af17 100644
--- a/tools/connectors/dispatch.py
+++ b/tools/connectors/dispatch.py
@@ -14,7 +14,7 @@ def dispatch_connector_call(name, arguments, tool_call_id):
partition = partition_calls([{"name": name, "arguments": arguments}])
entries = run_remote(partition.remote, tool_call_id, availability=None, client_factory=None)
entry = entries[0]
- return json.dumps({key: value for key, value in entry.items() if key in {"response", "error"}},
+ return json.dumps({key: value for key, value in entry.items() if key in {"response", "error", "account"}},
ensure_ascii=False)
@@ -56,5 +56,7 @@ def dispatch_connector_batch(calls, ids, *, user_task, enabled_tools,
entry["error"] = error if isinstance(error, dict) else {"code": "TOOL_ERROR", "message": str(error)}
else:
entry["response"] = value.get("response", value) if isinstance(value, dict) else value
+ if isinstance(value, dict) and value.get("account"):
+ entry["account"] = value["account"]
entries.append(entry)
return json.dumps(assemble_results(len(calls), entries), ensure_ascii=False)
diff --git a/tools/connectors/gateway/client.py b/tools/connectors/gateway/client.py
index 8657e902892..2fdd7bdd1ed 100644
--- a/tools/connectors/gateway/client.py
+++ b/tools/connectors/gateway/client.py
@@ -279,7 +279,10 @@ def _result_dict(result: wire.ConnectorExecuteResult) -> dict[str, Any]:
error["connection_id"] = result.error.connection_id
if result.error.hint:
error["hint"] = result.error.hint
- return {"data": result.data, "error": error}
+ entry = {"data": result.data, "error": error}
+ if result.account:
+ entry["account"] = result.account
+ return entry
def _safe_json(response: Any) -> Any:
diff --git a/tools/connectors/gateway/merge.py b/tools/connectors/gateway/merge.py
index eb9efceee8d..4f39e9b19db 100644
--- a/tools/connectors/gateway/merge.py
+++ b/tools/connectors/gateway/merge.py
@@ -82,9 +82,10 @@ def partition_calls(calls: Sequence[Any]) -> Partition:
def render_remote_entry(planned: PlannedCall, remote: Mapping[str, Any]) -> dict[str, Any]:
"""Use the shared CONNECTION_REQUIRED shape so links render consistently."""
error = remote.get("error") if isinstance(remote, Mapping) else None
+ account = _opt_str(remote.get("account")) if isinstance(remote, Mapping) else None
if not isinstance(error, Mapping):
data = remote.get("data") if isinstance(remote, Mapping) else None
- return {"index": planned.position, "name": planned.name, "response": data}
+ return _with_account({"index": planned.position, "name": planned.name, "response": data}, account)
code = str(error.get("code") or "PROVIDER_ERROR")
message = str(error.get("message") or "The gateway reported an error.")
@@ -104,7 +105,13 @@ def render_remote_entry(planned: PlannedCall, remote: Mapping[str, Any]) -> dict
hint = _opt_str(error.get("hint"))
if hint:
payload["hint"] = hint
- return {"index": planned.position, "name": planned.name, "error": payload}
+ return _with_account({"index": planned.position, "name": planned.name, "error": payload}, account)
+
+
+def _with_account(entry: dict[str, Any], account: Optional[str]) -> dict[str, Any]:
+ if account:
+ entry["account"] = account
+ return entry
def splice_remote_results(
diff --git a/tools/connectors/gateway/wire.py b/tools/connectors/gateway/wire.py
index 73168b9bab1..3b1f5bb2952 100644
--- a/tools/connectors/gateway/wire.py
+++ b/tools/connectors/gateway/wire.py
@@ -106,8 +106,8 @@ class ConnectorExecuteCall(_Wire):
connector: str
tool: str
arguments: dict[str, Any] = Field(default_factory=dict)
- # On the wire for the multi-account switch; never sent by hermes today, because the vendor answers
- # 400 to any value while multi-account is off (contract probe F2).
+ # Never sent by hermes: the model picks an account with the ``connector_alias`` argument, which
+ # the gateway strips and resolves itself.
account: Optional[str] = None
@@ -125,6 +125,8 @@ class ConnectorExecuteResult(_Wire):
tool: str = ""
data: Any = None
error: Optional[ConnectorToolError] = None
+ # The alias of the account the call ran under; null when that account has no alias.
+ account: Optional[str] = None
class ConnectorExecuteResponse(_Wire):
diff --git a/tools/tool_labels.py b/tools/tool_labels.py
index a4895fb6c7c..d14229d7cb6 100644
--- a/tools/tool_labels.py
+++ b/tools/tool_labels.py
@@ -116,8 +116,11 @@ def label_for_tool_name(name: str, arguments: Any = None) -> Optional[ToolLabel]
return None
connector = parse_connector_name(name)
if connector is not None:
- return ToolLabel(kind="connector", app=app_title(connector.connector),
- action=_action_phrase(connector.tool, connector.connector),
+ action = _action_phrase(connector.tool, connector.connector)
+ alias = arguments.get("connector_alias") if isinstance(arguments, dict) else None
+ if isinstance(alias, str) and alias.strip():
+ action = f"{action} ({alias.strip()})"
+ return ToolLabel(kind="connector", app=app_title(connector.connector), action=action,
emoji=CONNECTOR_EMOJI, name=name, preview=_arg_preview(name, arguments))
if name.startswith(MCP_TOOL_NAME_PREFIX):
server, _, tool = name[len(MCP_TOOL_NAME_PREFIX):].partition("__")