🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(hetero): stop sending the GitHub credential to devices (#23225)
Innei92b4cb396435
diff --git a/apps/server/src/services/aiAgent/pipeline/heteroDispatch/device.ts b/apps/server/src/services/aiAgent/pipeline/heteroDispatch/device.tsindex 03e54376182..247bd25e285 100644--- a/apps/server/src/services/aiAgent/pipeline/heteroDispatch/device.ts+++ b/apps/server/src/services/aiAgent/pipeline/heteroDispatch/device.ts@@ -124,6 +124,8 @@ export const dispatchToCliDevice = async (topicRepos,unansweredUserTurns,} = prepared;+ // The resolved GitHub credential is for the cloud sandbox only: a device may belong to another member.+ const { githubToken: _sandboxGithubToken, ...deviceHeteroParams } = heteroParams;const { agentId: resolvedAgentId, operationId, topicId } = run;const dispatchDeviceId = heteroPlan.kind === 'device' ? heteroPlan.deviceId : undefined;@@ -281,7 +283,7 @@ export const dispatchToCliDevice = async (? { error: 'DEVICE_NOT_FOUND', errorData: authorizationError, success: false }: await traceHeteroStage('device gateway_dispatch', () =>deviceGateway.dispatchAgentRun({- ...heteroParams,+ ...deviceHeteroParams,agentId: resolvedAgentId,// Only a live client advertising the native protocol receives these wrapper flags.args: nativeCodex ? [...(heteroExecArgs ?? []), ...nativeCodex.args] : heteroExecArgs,diff --git a/apps/server/src/services/aiAgent/pipeline/heteroDispatch/device.wake.test.ts b/apps/server/src/services/aiAgent/pipeline/heteroDispatch/device.wake.test.tsindex 8800f59d707..54a6b6b48f1 100644--- a/apps/server/src/services/aiAgent/pipeline/heteroDispatch/device.wake.test.ts+++ b/apps/server/src/services/aiAgent/pipeline/heteroDispatch/device.wake.test.ts@@ -97,7 +97,10 @@ const createDeps = () => {return { deps, topicModel };};-const dispatch = (deps: HeteroDispatchDeps) =>+const dispatch = (+ deps: HeteroDispatchDeps,+ heteroParams: Partial<PreparedHeteroRun['heteroParams']> = {},+) =>dispatchToWakingCliDevice(deps, run, {agentConfig: { agencyConfig: {}, id: 'agent-1' } as unknown as ExecRunContext['agentConfig'],appContext: undefined,@@ -105,7 +108,7 @@ const dispatch = (deps: HeteroDispatchDeps) =>heteroPlan: { deviceId: 'managed-a', kind: 'device-wakeable', target: 'device' },heteroType: 'claude-code',heterogeneousProvider: { type: 'claude-code' },- prepared: { heteroParams: {} } as unknown as PreparedHeteroRun,+ prepared: { heteroParams } as unknown as PreparedHeteroRun,});const runScheduledWork = async () => {@@ -204,6 +207,18 @@ describe('dispatchToWakingCliDevice', () => {expect(mocks.finalizeHeteroDispatchError).not.toHaveBeenCalled();});+ it('never sends the resolved GitHub credential to the device', async () => {+ const { deps } = createDeps();++ await dispatch(deps, { githubToken: 'gh-org-token', jwt: 'operation-jwt' });+ await runScheduledWork();++ expect(mocks.dispatchAgentRun).toHaveBeenCalledTimes(1);+ const params = mocks.dispatchAgentRun.mock.calls[0][0];+ expect(params).toMatchObject({ jwt: 'operation-jwt' });+ expect(params).not.toHaveProperty('githubToken');+ });+it('settles the run when the background dispatch throws', async () => {const error = vi.spyOn(console, 'error').mockImplementation(() => {});mocks.selectCodexDeviceDispatch.mockRejectedValue(new Error('db down'));