You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(feishu): re-resolve route when dynamic agent binding already exists in runtime config (fixes#42837) (#92814)
* fix(feishu): re-resolve route when dynamic agent binding already exists in runtime config
When dynamicAgentCreation is enabled and a binding was previously written
to the config file (e.g. from a prior message), the in-memory cfg may be
stale and not contain the binding. Previously, maybeCreateDynamicAgent
returned { created: false, updatedCfg: cfg } with the stale cfg, and
bot.ts only re-resolved the route when created === true. This caused
subsequent messages to still route to agent:main.
Fix: check runtime.config.current() for the binding when it is missing
from the in-memory cfg. When found, return the runtime's current config
so the caller can re-resolve the route with up-to-date bindings.
Fixes#42837
* fix(feishu): serialize dynamic agent config updates
* fix(feishu): route with refreshed runtime config
* fix(feishu): use current dynamic-agent policy
* fix(feishu): reauthorize refreshed dynamic routes
* fix(feishu): authorize dynamic agent mutations
* fix(feishu): complete account-scoped dynamic routing
* fix(feishu): revalidate current direct routes
* fix(feishu): isolate named-account dynamic agents
* fix(feishu): bound named dynamic agent ids
* docs(feishu): explain legacy dynamic agent cap
* test(feishu): fix dynamic routing check types
---------
Co-authored-by: Vincent Koc <[email protected]>
This is essential for public bots where you want each user to have their own private AI assistant experience.
417
417
418
418
<Note>
419
-
**Account limitation**: `dynamicAgentCreation` currently works with the **default Feishu account only**. Named/multi-account setups are not yet fully supported — dynamic bindings are created without `accountId`, so messages to named accounts may still route to `agent:main`. Track progress in [Issue #42837](https://github.com/openclaw/openclaw/issues/42837).
419
+
Dynamic bindings include the normalized Feishu `accountId`, so default and named accounts route each sender to the correct dynamic agent.
420
+
421
+
If a named account created an unscoped dynamic agent on an older release, that legacy agent still counts toward `maxAgents`. Confirm that it is not used by the default account before removing it, or temporarily increase `maxAgents`; OpenClaw cannot safely infer which account owns ambiguous legacy state.
420
422
</Note>
421
423
422
424
### Quick setup
@@ -447,7 +449,7 @@ This is essential for public bots where you want each user to have their own pri
447
449
448
450
When a new user sends their first DM:
449
451
450
-
1. The channel generates a unique `agentId` = `feishu-{user_open_id}`
452
+
1. The channel generates a unique `agentId`: `feishu-{user_open_id}` for the default account, or a bounded account-prefixed identity digest for a named account
451
453
2. Creates a new workspace at `workspaceTemplate` path
452
454
3. Registers the agent and creates a binding for this user
453
455
4. The workspace helper ensures bootstrap files (`AGENTS.md`, `SOUL.md`, `USER.md`, etc.) on first access
@@ -464,22 +466,23 @@ When a new user sends their first DM:
464
466
465
467
Template variables:
466
468
467
-
-`{agentId}` - the generated agent ID (e.g., `feishu-ou_xxxxxx`)
469
+
-`{agentId}` - the generated agent ID (e.g., `feishu-ou_xxxxxx` or `feishu-support-<identity_digest>`)
468
470
-`{userId}` - the sender's Feishu open_id (e.g., `ou_xxxxxx`)
469
471
470
472
### Session scope
471
473
472
474
`session.dmScope` controls how direct messages are mapped to agent sessions. This is a **global setting** that affects all channels.
|`"main"`| Each user's DM maps to their agent's main session | Single-user bots where you want `USER.md` / `SOUL.md` to auto-load |
479
+
|`"per-channel-peer"`| Each (channel + user) combination gets a separate session | Public multi-user bots needing stronger isolation |
480
+
|`"per-account-channel-peer"`| Each (account + channel + user) combination gets a separate session | Multi-account bots needing account-level session isolation |
478
481
479
482
**Tradeoff**: Using `"main"` enables automatic bootstrap file loading (`USER.md`, `SOUL.md`, `MEMORY.md`), but means all DMs across all channels share the same session key pattern. For public multi-user bots where isolation matters more than bootstrap auto-loading, consider `"per-channel-peer"` and manage bootstrap files manually.
480
483
481
484
<Note>
482
-
`"per-account-channel-peer"`is not recommended with `dynamicAgentCreation` because dynamic bindings are created without `accountId`. Use it only with manual bindings.
485
+
Use `"per-account-channel-peer"`when named Feishu accounts should keep separate sessions for the same sender. Dynamic bindings preserve the account scope.
0 commit comments