Skip to content

feat(feishu): feishu-local-cli-agent-bridge-design#209

Merged
RussellLuo merged 4 commits into
OpenCSGs:mainfrom
GatewayJ:feishu-local-cli-agent-bridge
Jun 17, 2026
Merged

feat(feishu): feishu-local-cli-agent-bridge-design#209
RussellLuo merged 4 commits into
OpenCSGs:mainfrom
GatewayJ:feishu-local-cli-agent-bridge

Conversation

@GatewayJ

@GatewayJ GatewayJ commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator
  • feishu local cli agent bridge

Comment thread docs/feishu-local-cli-agent-bridge-design.zh.md
Comment thread docs/feishu-local-cli-agent-bridge-design.zh.md
@GatewayJ GatewayJ force-pushed the feishu-local-cli-agent-bridge branch from 2c38ea0 to e3357a8 Compare June 16, 2026 07:03
@GatewayJ GatewayJ changed the title doc(feishu): feishu-local-cli-agent-bridge-design feat(feishu): feishu-local-cli-agent-bridge-design Jun 17, 2026
@GatewayJ GatewayJ force-pushed the feishu-local-cli-agent-bridge branch 2 times, most recently from c58a169 to b6c67d1 Compare June 17, 2026 02:58
@GatewayJ GatewayJ force-pushed the feishu-local-cli-agent-bridge branch from b6c67d1 to 22405ca Compare June 17, 2026 03:37
Comment thread cli/serve/serve.go Outdated
}

func (m *serveFeishuCodexBridgeManager) StopAgent(agentID string) {
participantID := strings.TrimSpace(feishuParticipantIDForAgent(agent.Agent{ID: agentID}, m.provider))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This only looks up the current agent->Feishu participant mapping. If an agent used to run with participant A and this update removes the Feishu binding or rebinds it to participant B, EnsureAgent() will call StopAgent(a.ID) but this code can no longer recover participant A, so the old stream keeps running under the stale participant. Consider tracking the active participant ID per agent (or stopping the previous binding before applying the new one) so rebinding/removal tears down the old bridge reliably.

Comment thread cli/serve/serve.go Outdated
return runtimecodex.NewPermissionActivityDecider(csgclawchannel.ChannelID, decider)
}

type multiCodexBridgeManager struct {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This new multiCodexBridgeManager path feels a bit too heavy for cli/serve now.

At this point serve.go is no longer just wiring dependencies and deciding what to start. It also owns bridge orchestration details such as:

  • combining multiple bridge managers
  • deciding start/restore behavior
  • coordinating Start / EnsureAgent / StopAgent / Close
  • resolving channel-specific bindings like the Feishu participant ID
  • repairing missing Codex sessions by stopping and restarting the agent runtime

That is bridge-domain logic, not just server bootstrap logic. Keeping it here makes serve.go the place that knows both runtime wiring and per-channel bridge behavior, which will get harder to maintain as more bridge types are added.

I think a cleaner split would be to keep only the top-level assembly in cli/serve and move the manager/orchestration layer into internal/channelbridge (for example internal/channelbridge/manager.go or a small subpackage there). Then serve.go would just build a channelbridge manager from its dependencies, while the bridge package owns:

  • multiCodexBridgeManager
  • the CSGClaw/Feishu manager implementations
  • binding resolution helpers
  • start/restore policy helpers

The only part I would keep watching during that move is the current ensureSession() behavior, because it reaches into agent lifecycle (svc.Stop / svc.Start). If this gets extracted, it would be cleaner to pass that capability in as an explicit dependency instead of letting channelbridge depend on broad agent.Service details directly.

So I do think this should be pushed down, but with the dependency boundary tightened at the same time; otherwise it is only moving code out of serve.go without really reducing coupling.

@RussellLuo RussellLuo merged commit 0a07e7d into OpenCSGs:main Jun 17, 2026
1 check passed
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