feat: add configurable agent ID support#3
Merged
techartdev merged 3 commits intotechartdev:mainfrom Mar 7, 2026
Merged
Conversation
Allow users to configure which OpenClaw agent the integration communicates with, instead of always defaulting to the implicit 'main' agent. Changes: - const.py: add CONF_AGENT_ID, DEFAULT_AGENT_ID='main', ATTR_AGENT_ID - api.py: accept agent_id in constructor; _headers() now includes the x-openclaw-agent-id header on every request; async_send_message and async_stream_message accept an optional per-call agent_id override - config_flow.py: expose agent_id as a text field in both the manual setup step and the options flow (Settings → Integrations → Configure) - __init__.py: read agent_id from options/data and pass it to the API client; add optional agent_id field to the send_message service schema so automations can address a specific agent per-call - services.yaml: document the new agent_id field on send_message - strings.json / translations/en.json: add UI labels for the new option The gateway routing header x-openclaw-agent-id is always sent; when agent_id is 'main' (the default) the gateway behaviour is unchanged. A per-call override on send_message takes precedence over the config. Implemented with assistance from an AI coding agent (BMO) with human review. Bot-assisted contribution reviewed by a human before submission.
Removed redundant assignment of agent_id from options.
Owner
|
Hi @bmobytes ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for configuring which OpenClaw agent the integration communicates with, rather than always defaulting to the implicit
mainagent.The OpenClaw gateway already supports routing requests to specific agents via the
x-openclaw-agent-idheader. This PR wires that capability through the full HA integration stack.Changes
const.pyCONF_AGENT_ID = "agent_id"DEFAULT_AGENT_ID = "main"ATTR_AGENT_ID = "agent_id"(for service calls)api.pyOpenClawApiClient.__init__now acceptsagent_id: str = "main"_headers()always includesx-openclaw-agent-id(gateway is unaffected when value is"main")async_send_messageandasync_stream_messageeach accept an optional per-callagent_idoverrideconfig_flow.pyAgent IDtext field (defaults to"main")Agent IDfield appears at the top of the options form so it can be changed at any time via Settings → Integrations → OpenClaw → Configure__init__.pyasync_setup_entryreadsagent_idfrom options (preferred) or config data, and passes it to the API clientSEND_MESSAGE_SCHEMAgains an optionalagent_idfield so individual automation service calls can address a specific agent, overriding the configured defaultservices.yamlsend_messageservice now documents the new optionalagent_idfieldstrings.json/translations/en.jsonagent_idoption in both the manual config step and options flowBehaviour
agent_idnot set / set to"main"agent_idset to"wish-bmo"in optionsx-openclaw-agent-id: wish-bmoagent_id: "other-agent"insend_messageservice callTesting
mainto another agent nameopenclaw.send_messageservice — it should route to the configured agentagent_idin a service call to override per-message