Skip to content

fix(feishu): resolve correct accountId for subagent group replies#60634

Closed
EronFan wants to merge 4 commits into
openclaw:mainfrom
EronFan:fix/feishu-multi-agent-account-resolution
Closed

fix(feishu): resolve correct accountId for subagent group replies#60634
EronFan wants to merge 4 commits into
openclaw:mainfrom
EronFan:fix/feishu-multi-agent-account-resolution

Conversation

@EronFan

@EronFan EronFan commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #58107

Updated after review:

  • Remove channel.ts.backup development artefact
  • Fix effectiveAccountId scope error in startAccount (was causing ReferenceError)
  • Fix update-startup.ts JSON path parsed.afterVersion -> parsed.after.version

Original description:
When multiple Feishu group agents (xixi, ling, aoao, weiwei) send messages in a group chat, only the main agent's messages are delivered correctly. Subagents were using the wrong accountId ('default') instead of their assigned accountId.

aoao and others added 4 commits March 31, 2026 10:27
… flag

Before writing autoLastSuccessVersion, parse afterVersion from the JSON
stdout of 'openclaw update --json' and verify it matches the resolved
version AND differs from the current running VERSION.

This prevents a crash loop where:
1. npm install exits 0 but binary is not actually updated
2. autoLastSuccessVersion is written anyway
3. Gateway restarts, plugin version checks fail due to
   minGatewayVersion mismatch, all plugins skip loading

fix openclaw#58041
Fixes openclaw#58107 by ensuring subagents use their own accountId when sending
Feishu group messages. Previously, subagents would use the default
accountId ('default') instead of their assigned accountId, causing
messages to be sent from the wrong account.

The fix prioritizes agentAccountId from the tool execution context
(available for subagents) over the channel's accountId.
…kup removal)

1. Remove channel.ts.backup development artefact
2. Fix effectiveAccountId scope error in startAccount: declare local
   startEffectiveAccountId instead of referencing out-of-scope variable
3. Fix update-startup.ts JSON path: parsed.afterVersion ->
   parsed.after.version
@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: S r: too-many-prs Auto-close: author has more than twenty active PRs. labels Apr 4, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because the author has more than 10 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit.

@openclaw-barnacle openclaw-barnacle Bot closed this Apr 4, 2026
@greptile-apps

greptile-apps Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes three bugs introduced in an earlier change: subagents in Feishu group chats now use their assigned agentAccountId instead of defaulting to 'default'; a ReferenceError in startAccount caused by referencing a variable scoped to handleAction is resolved with a locally-scoped startEffectiveAccountId; and the JSON path for reading the post-update version (parsed.afterVersionparsed.after.version) is corrected to match UpdateRunResult.after.version, so auto-update success is now actually persisted.

Confidence Score: 5/5

Safe to merge; all three bug fixes are logically correct and the only remaining finding is a P2 style concern.

All P0/P1 bugs are resolved. The sole remaining finding — using (ctx as any).agentAccountId rather than a properly typed extension of the context — is a P2 style concern that doesn't affect runtime correctness.

extensions/feishu/src/channel.ts — the two (ctx as any) casts at lines 621 and 1139 should eventually be replaced with a typed context extension.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/feishu/src/channel.ts
Line: 621

Comment:
**`any` cast to access `agentAccountId`**

`(ctx as any).agentAccountId` bypasses TypeScript's type system and will silently produce `undefined` if the field name ever changes. The project guideline explicitly avoids `no-explicit-any`. The same pattern is repeated in `startAccount` (line 1139). A narrower typed extension of the action/gateway context (e.g. `interface FeishuCtx { agentAccountId?: string }` combined with a type-guard or a typed intersection) would give the compiler visibility into this path and keep the type safety the rest of the file relies on.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix: resolve 3 P1 bugs in #58228 (scope ..." | Re-trigger Greptile

describeMessageTool: describeFeishuMessageTool,
handleAction: async (ctx) => {
// Use agentAccountId if available (for subagents), otherwise fall back to ctx.accountId
const effectiveAccountId = (ctx as any).agentAccountId ?? ctx.accountId ?? undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 any cast to access agentAccountId

(ctx as any).agentAccountId bypasses TypeScript's type system and will silently produce undefined if the field name ever changes. The project guideline explicitly avoids no-explicit-any. The same pattern is repeated in startAccount (line 1139). A narrower typed extension of the action/gateway context (e.g. interface FeishuCtx { agentAccountId?: string } combined with a type-guard or a typed intersection) would give the compiler visibility into this path and keep the type safety the rest of the file relies on.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/channel.ts
Line: 621

Comment:
**`any` cast to access `agentAccountId`**

`(ctx as any).agentAccountId` bypasses TypeScript's type system and will silently produce `undefined` if the field name ever changes. The project guideline explicitly avoids `no-explicit-any`. The same pattern is repeated in `startAccount` (line 1139). A narrower typed extension of the action/gateway context (e.g. `interface FeishuCtx { agentAccountId?: string }` combined with a type-guard or a typed intersection) would give the compiler visibility into this path and keep the type safety the rest of the file relies on.

How can I resolve this? If you propose a fix, please make it concise.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e9202c861

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


// Parse version from output (format: "openclaw 2026.3.28")
const versionOutput = versionCheckStep.stdoutTail || "";
const versionMatch = versionOutput.match(/openclaw\s+(\d+\.\d+\.\d+)/);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Parse version output using the real CLI format

The regex versionOutput.match(/openclaw\s+(\d+\.\d+\.\d+)/) does not match what --version actually prints (OpenClaw <version> with capitalized name, optional commit hash, and possible prerelease suffixes), so versionMatch can be null on healthy builds. In that case runGatewayUpdate exits with version-parse-failed before running doctor, which blocks git-based updates even when the binary and package are aligned.

Useful? React with 👍 / 👎.

if (!trimmed.startsWith("{")) {
continue;
}
const parsed = JSON.parse(trimmed);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse full JSON stdout before checking after.version

This logic parses outcome.stdout one line at a time and JSON.parses any line starting with {, but openclaw update --json emits pretty-printed multi-line JSON, so the first matching line is usually just { and parsing fails immediately. That leaves afterVersion null and causes successful auto-update runs to be logged as skipped, so success metadata is never recorded.

Useful? React with 👍 / 👎.

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

Labels

channel: feishu Channel integration: feishu r: too-many-prs Auto-close: author has more than twenty active PRs. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Multiple Feishu group agents - only main reply delivered, other agents' replies silently dropped

1 participant