From bc3d6ba92f7cf302b09096f010a9db5ff5862176 Mon Sep 17 00:00:00 2001 From: RockChinQ Date: Fri, 13 Mar 2026 11:31:51 -0400 Subject: [PATCH] feat: support instance_id in system config Add instance_id field to system section in config.yaml. Can be set via SYSTEM__INSTANCE_ID env var (auto-mapped). Falls back to data/labels/instance_id.json if not set. --- src/langbot/pkg/core/stages/load_config.py | 10 +++++++++- src/langbot/templates/config.yaml | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/langbot/pkg/core/stages/load_config.py b/src/langbot/pkg/core/stages/load_config.py index 43933def..6e196d8b 100644 --- a/src/langbot/pkg/core/stages/load_config.py +++ b/src/langbot/pkg/core/stages/load_config.py @@ -146,6 +146,8 @@ class LoadConfigStage(stage.BootingStage): await ap.instance_config.dump_config() # load or generate instance id + # Priority: system.instance_id from config.yaml (can be set via env var + # SYSTEM__INSTANCE_ID which is auto-mapped) > data/labels/instance_id.json > generate new ap.instance_id = await config.load_json_config( 'data/labels/instance_id.json', template_data={ @@ -155,7 +157,13 @@ class LoadConfigStage(stage.BootingStage): completion=False, ) - constants.instance_id = ap.instance_id.data['instance_id'] + config_instance_id = ap.instance_config.data.get('system', {}).get('instance_id', '') + if config_instance_id: + # Use the instance_id from config.yaml (e.g. injected via SYSTEM__INSTANCE_ID env var) + constants.instance_id = config_instance_id + else: + # Fall back to the file-based instance id + constants.instance_id = ap.instance_id.data['instance_id'] constants.edition = ap.instance_config.data.get('system', {}).get('edition', 'community') print(f'LangBot instance id: {constants.instance_id}') diff --git a/src/langbot/templates/config.yaml b/src/langbot/templates/config.yaml index 98d0d01a..a75a32fc 100644 --- a/src/langbot/templates/config.yaml +++ b/src/langbot/templates/config.yaml @@ -16,6 +16,7 @@ proxy: http: '' https: '' system: + instance_id: '' edition: community recovery_key: '' allow_modify_login_info: true