Skip to content

fix: fallback to global inboundMeta.sender_id when LarkTicket unavailable#425

Open
subaochen wants to merge 1 commit into
larksuite:mainfrom
subaochen:fix/sender-openid-fallback
Open

fix: fallback to global inboundMeta.sender_id when LarkTicket unavailable#425
subaochen wants to merge 1 commit into
larksuite:mainfrom
subaochen:fix/sender-openid-fallback

Conversation

@subaochen
Copy link
Copy Markdown

Summary

When ToolClient is created in sub-agent scheduling scenarios (e.g. PA dispatching), the AsyncLocalStorage (LarkTicket) context is lost, causing ticket.senderOpenId to be undefined. This triggers unnecessary fallback to the app owner and generates excessive "Using app owner as fallback user" logs.

Fix

Adds a secondary fallback path that reads sender_id from global.openclaw.inboundMeta (set by the OpenClaw runtime), ensuring correct user identity is used even when LarkTicket context is missing.

Changes

  • src/core/tool-client.ts: In createToolClient(), added fallback to global.openclaw.inboundMeta.sender_id when ticket.senderOpenId is unavailable
  • Type-safe: uses (global as any).openclaw?.inboundMeta?.sender_id to avoid TypeScript type dependency on OpenClaw internals

Testing

Verified locally: after restart, no new "Using app owner as fallback user" logs appear in sub-agent scenarios.

Fixes: excessive fallback logs in sub-agent scheduling

…ailable

When ToolClient is created in sub-agent scheduling scenarios (e.g. PA
dispatching), the AsyncLocalStorage context is lost, causing
ticket.senderOpenId to be undefined. This triggers unnecessary
fallback to the app owner.

This fix adds a secondary fallback path that reads sender_id from
global.openclaw.inboundMeta (set by the OpenClaw runtime), ensuring
correct user identity is used even when LarkTicket context is missing.

Fixes: excessive "Using app owner as fallback user" logs in
sub-agent scenarios.
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants