π€― 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
β‘οΈ perf(agent): freeze the run's credential list instead of reading it per step (#19717)
Arvin Xuf80a310b16ac
diff --git a/apps/server/src/modules/Mecha/ContextEngineering/providers/index.ts b/apps/server/src/modules/Mecha/ContextEngineering/providers/index.tsindex 320b30e3aad..b1863706ad7 100644--- a/apps/server/src/modules/Mecha/ContextEngineering/providers/index.ts+++ b/apps/server/src/modules/Mecha/ContextEngineering/providers/index.ts@@ -199,6 +199,12 @@ export const createServerContextFactProviders = ({},listCredentials: async ({ workspaceId: scopeWorkspaceId }) => {+ // Frozen when the operation was created, so a run renders {{CREDS_LIST}}+ // without a Market round trip per step. The scope must match: inside a+ // workspace the agent only sees that workspace's shared credentials.+ const frozen = state.operationCredentials;+ if (frozen && frozen.workspaceId === scopeWorkspaceId) return frozen.credentials;+// Read market accessToken from DB so the server-side runtime can// authenticate with the Market API instead of falling back to an// anonymous trustedClientToken (which 401s on creds endpoints).diff --git a/apps/server/src/modules/Mecha/ContextEngineering/providers/serverContextFactProviders.test.ts b/apps/server/src/modules/Mecha/ContextEngineering/providers/serverContextFactProviders.test.tsindex fc674491cca..a83424fc8c5 100644--- a/apps/server/src/modules/Mecha/ContextEngineering/providers/serverContextFactProviders.test.ts+++ b/apps/server/src/modules/Mecha/ContextEngineering/providers/serverContextFactProviders.test.ts@@ -3,14 +3,21 @@ import { describe, expect, it, vi } from 'vitest';import { createServerContextFactProviders } from './index';-const { findById, getInfoForAIGeneration, getUserSettings, loadConnectedComposioIds, pluginQuery } =- vi.hoisted(() => ({- findById: vi.fn(),- getInfoForAIGeneration: vi.fn(),- getUserSettings: vi.fn(),- loadConnectedComposioIds: vi.fn(),- pluginQuery: vi.fn(),- }));+const {+ credsList,+ findById,+ getInfoForAIGeneration,+ getUserSettings,+ loadConnectedComposioIds,+ pluginQuery,+} = vi.hoisted(() => ({+ credsList: vi.fn(),+ findById: vi.fn(),+ getInfoForAIGeneration: vi.fn(),+ getUserSettings: vi.fn(),+ loadConnectedComposioIds: vi.fn(),+ pluginQuery: vi.fn(),+}));vi.mock('@/database/models/user', () => ({UserModel: Object.assign(@@ -34,6 +41,14 @@ vi.mock('@/server/modules/AgentRuntime/adapters/composioConnectedIds', () => ({loadConnectedComposioIds,}));vi.mock('@/envs/app', () => ({ appEnv: { APP_URL: 'https://app.test' } }));+vi.mock('@/server/services/market', () => ({+ MarketService: class {+ market = {+ creds: { list: credsList },+ organizations: { creds: () => ({ list: credsList }) },+ };+ },+}));const source = (state: Record<string, unknown> = {}) => ({ctx: { serverDB: {}, userId: 'owner-1', workspaceId: 'ws-1' } as never,@@ -41,6 +56,42 @@ const source = (state: Record<string, unknown> = {}) => ({});describe('createServerContextFactProviders', () => {+ describe('listCredentials', () => {+ const frozen = {+ credentials: [{ key: 'OPENAI', name: 'OpenAI', type: 'apiKey' }],+ workspaceId: 'ws-1',+ };++ it('answers from the run snapshot without asking the Market API', async () => {+ const providers = createServerContextFactProviders(source({ operationCredentials: frozen }));++ await expect(providers.listCredentials!({ workspaceId: 'ws-1' })).resolves.toEqual(+ frozen.credentials,+ );+ expect(credsList).not.toHaveBeenCalled();+ expect(getUserSettings).not.toHaveBeenCalled();+ });++ it('reads live when the snapshot was taken in another scope', async () => {+ getUserSettings.mockResolvedValue({ market: { accessToken: 't' } });+ credsList.mockResolvedValue({ data: [{ key: 'LIVE', name: 'Live', type: 'apiKey' }] });+ const providers = createServerContextFactProviders(source({ operationCredentials: frozen }));++ await expect(providers.listCredentials!({ workspaceId: undefined })).resolves.toEqual([+ expect.objectContaining({ key: 'LIVE' }),+ ]);+ expect(credsList).toHaveBeenCalledTimes(1);+ });++ it('reads live when the run has no snapshot', async () => {+ credsList.mockResolvedValue({ data: [] });+ const providers = createServerContextFactProviders(source());++ await expect(providers.listCredentials!({ workspaceId: 'ws-1' })).resolves.toEqual([]);+ expect(credsList).toHaveBeenCalled();+ });+ });+it('answers nothing without a database or user', () => {expect(createServerContextFactProviders({ ctx: {} as never, state: {} as never })).toEqual({});});diff --git a/apps/server/src/services/agentRuntime/AgentRuntimeService.test.ts b/apps/server/src/services/agentRuntime/AgentRuntimeService.test.tsindex 66ca79ac352..70b2eff30fd 100644--- a/apps/server/src/services/agentRuntime/AgentRuntimeService.test.ts+++ b/apps/server/src/services/agentRuntime/AgentRuntimeService.test.ts@@ -1138,6 +1138,59 @@ describe('AgentRuntimeService', () => {expect(mockQueueService.scheduleMessage).toHaveBeenCalled();});+ describe('frozen credential snapshot', () => {+ const frozen = {+ credentials: [{ key: 'OPENAI', name: 'OpenAI', type: 'apiKey' }],+ workspaceId: undefined,+ };++ /**+ * Snapshot the state AT the save, not the object afterwards: the runtime+ * keeps mutating `newState`, so a later clear would otherwise read back as+ * if it had been persisted.+ */+ const runStepWithToolCall = async (apiName: string) => {+ const stateWithSnapshot = { ...mockState, operationCredentials: frozen };+ mockCoordinator.loadAgentState.mockResolvedValue(stateWithSnapshot);++ let persisted: string | undefined;+ mockCoordinator.saveStepResult.mockImplementationOnce(async (_id: string, result: any) => {+ persisted = JSON.stringify(result.newState);+ });++ const mockRuntime = {+ step: vi.fn().mockResolvedValue({+ events: [],+ newState: { ...stateWithSnapshot, status: 'running', stepCount: 2 },+ nextContext: {+ payload: { toolCall: { apiName, identifier: 'lobe-creds' } },+ phase: 'tool_result',+ },+ }),+ };+ vi.spyOn(service as any, 'createAgentRuntime').mockReturnValue({ runtime: mockRuntime });++ await service.executeStep(mockParams);++ expect(persisted).toBeDefined();+ return JSON.parse(persisted!);+ };++ it('drops the snapshot in the state it persists after the run saves a credential', async () => {+ const persistedState = await runStepWithToolCall('saveCreds');++ expect(persistedState.operationCredentials).toBeUndefined();+ });++ it('keeps the snapshot when the creds call only read', async () => {+ const persistedState = await runStepWithToolCall('injectCredsToSandbox');++ expect(persistedState.operationCredentials).toEqual({+ credentials: frozen.credentials,+ });+ });+ });+it('should resume async tools with the last pending tool result as parentMessageId', async () => {const pendingTools = [{diff --git a/apps/server/src/services/agentRuntime/AgentRuntimeService.ts b/apps/server/src/services/agentRuntime/AgentRuntimeService.tsindex ee53944d76e..c168c48145d 100644--- a/apps/server/src/services/agentRuntime/AgentRuntimeService.ts+++ b/apps/server/src/services/agentRuntime/AgentRuntimeService.ts@@ -87,6 +87,7 @@ import {isSuccessLikeCompletionReason,normalizeCompletionMessages,} from './CompletionLifecycle';+import { stepChangedCredentials } from './credentialFacts';import { logToolCallPc } from './formalObservation';import { type AgentHook, hookDispatcher } from './hooks';import { HumanInterventionHandler } from './HumanInterventionHandler';@@ -930,6 +931,7 @@ export class AgentRuntimeService {agentGroup,agentShareVisitor,modelRuntimeConfig,+ operationCredentials,userId,autoStart = true,stream,@@ -1113,6 +1115,9 @@ export class AgentRuntimeService {maxSteps,// modelRuntimeConfig at state level for executor fallbackmodelRuntimeConfig,+ // Read once during discovery; dropped again as soon as the run changes+ // its own credentials (see the creds invalidation after a step).+ operationCredentials,operationId,// The run's only copy of its tool set. The manifest map is the heaviest// thing on the state and the state is re-serialized at every step, so the@@ -2005,6 +2010,10 @@ export class AgentRuntimeService {currentState.pendingToolsCalling = [];currentState.status = 'running';currentState.interruption = undefined;+ // Whatever ran while this operation was parked is invisible from+ // here: a sub-agent that saved a credential cleared its own snapshot,+ // not this one. Drop ours rather than render a list that predates it.+ currentState.operationCredentials = undefined;currentState.lastModified = new Date().toISOString();currentContext = {payload: { parentMessageId: resumeParentMessageId },@@ -2222,6 +2231,18 @@ export class AgentRuntimeService {}}+ // A credential the run just saved or connected changes the list the next+ // step must show, so the snapshot frozen at creation no longer holds.+ // Dropped before the save below β that write is what the next step+ // reloads, and nothing else persists the state on a plain step.+ if (+ stepChangedCredentials(stepResult.nextContext) &&+ stepResult.newState.operationCredentials+ ) {+ stepResult.newState.operationCredentials = undefined;+ log('[%s][%d] Credentials changed in-run; dropped the snapshot', operationId, stepIndex);+ }+// Save state, coordinator will handle event sending automaticallyawait this.coordinator.saveStepResult(operationId, {...stepResult,diff --git a/apps/server/src/services/agentRuntime/credentialFacts.test.ts b/apps/server/src/services/agentRuntime/credentialFacts.test.tsnew file mode 100644index 00000000000..b542080427c--- /dev/null+++ b/apps/server/src/services/agentRuntime/credentialFacts.test.ts@@ -0,0 +1,59 @@+import { describe, expect, it } from 'vitest';++import { stepChangedCredentials } from './credentialFacts';++const singleCall = (identifier: string, apiName: string) => ({+ payload: { toolCall: { apiName, identifier } },+ phase: 'tool_result',+});++const batch = (calls: { apiName: string; identifier: string }[]) => ({+ payload: { toolResults: calls.map((toolCall) => ({ toolCall })) },+ phase: 'tools_batch_result',+});++describe('stepChangedCredentials', () => {+ it('is false for a step that ran no tools', () => {+ expect(stepChangedCredentials(undefined)).toBe(false);+ expect(stepChangedCredentials({ payload: { message: 'hi' }, phase: 'user_input' })).toBe(false);+ });++ it.each(['saveCreds', 'initiateOAuthConnect', 'connectComposioService'])(+ 'is true after %s',+ (apiName) => {+ expect(stepChangedCredentials(singleCall('lobe-creds', apiName))).toBe(true);+ },+ );++ it('is false for a creds call that only reads', () => {+ expect(stepChangedCredentials(singleCall('lobe-creds', 'injectCredsToSandbox'))).toBe(false);+ });++ it('is false for another tool that happens to share an api name', () => {+ expect(stepChangedCredentials(singleCall('lobe-web-browsing', 'saveCreds'))).toBe(false);+ });++ it.each(['lobe-agent', 'lobe-group-management'])(+ 'is true after %s, because a nested run may have saved one',+ (identifier) => {+ expect(stepChangedCredentials(singleCall(identifier, 'anything'))).toBe(true);+ },+ );++ it('finds a mutating call anywhere in a batch', () => {+ expect(+ stepChangedCredentials(+ batch([+ { apiName: 'injectCredsToSandbox', identifier: 'lobe-creds' },+ { apiName: 'saveCreds', identifier: 'lobe-creds' },+ ]),+ ),+ ).toBe(true);++ expect(+ stepChangedCredentials(+ batch([{ apiName: 'injectCredsToSandbox', identifier: 'lobe-creds' }]),+ ),+ ).toBe(false);+ });+});diff --git a/apps/server/src/services/agentRuntime/credentialFacts.ts b/apps/server/src/services/agentRuntime/credentialFacts.tsnew file mode 100644index 00000000000..70bdb0a3eb2--- /dev/null+++ b/apps/server/src/services/agentRuntime/credentialFacts.ts@@ -0,0 +1,57 @@+import { CredsApiName, CredsIdentifier } from '@lobechat/builtin-tool-creds';+import { GroupManagementIdentifier } from '@lobechat/builtin-tool-group-management';+import { LobeAgentIdentifier } from '@lobechat/builtin-tool-lobe-agent';++/**+ * Creds APIs that change what the credential list contains.+ * `injectCredsToSandbox` only reads, so a coding run that injects on every step+ * keeps the snapshot frozen when its operation was created.+ */+const MUTATING_API_NAMES = new Set<string>([+ CredsApiName.connectComposioService,+ CredsApiName.initiateOAuthConnect,+ CredsApiName.saveCreds,+]);++/**+ * Tools that run another agent. Its steps are a separate operation with its own+ * snapshot, so a credential it saves clears only its own β nothing tells this+ * run what the nested one did. Assume the worst and read the list live again.+ */+const NESTED_RUN_IDENTIFIERS = new Set<string>([GroupManagementIdentifier, LobeAgentIdentifier]);++interface ToolCallRef {+ apiName?: string;+ identifier?: string;+}++/**+ * Whether the step that produced this context changed the run's own+ * credentials. The list the next step renders would then differ from the+ * snapshot frozen at creation, so the run goes back to reading it live.+ *+ * Reads the tool calls off the step's next context β the same source+ * `buildStepPresentation` uses, but available before the step's state is+ * persisted, which is where the snapshot has to be dropped for the next step to+ * see it gone.+ */+export const stepChangedCredentials = (nextContext?: {+ payload?: unknown;+ phase?: string;+}): boolean => {+ const payload = nextContext?.payload as+ | { toolCall?: ToolCallRef; toolResults?: ({ toolCall?: ToolCallRef } | undefined)[] }+ | undefined;+ if (!payload) return false;++ // A batch step carries one entry per call; a single tool step carries the call itself.+ const calls = payload.toolResults+ ? payload.toolResults.map((result) => result?.toolCall)+ : [payload.toolCall];++ return calls.some(+ (call) =>+ (call?.identifier === CredsIdentifier && MUTATING_API_NAMES.has(call?.apiName ?? '')) ||+ NESTED_RUN_IDENTIFIERS.has(call?.identifier ?? ''),+ );+};diff --git a/apps/server/src/services/agentRuntime/types.ts b/apps/server/src/services/agentRuntime/types.tsindex 63ebddec929..ef7c957b71e 100644--- a/apps/server/src/services/agentRuntime/types.ts+++ b/apps/server/src/services/agentRuntime/types.ts@@ -13,6 +13,7 @@ import type {ChatTopicBotContext,EvalToolForwardingConfig,ExpertiseContextSnapshot,+ FrozenCredentialFacts,UserInterventionConfig,} from '@lobechat/types';import type { SearchDecision } from 'model-bank';@@ -533,6 +534,8 @@ export interface OperationCreationParams {modelRuntimeConfig?: any;/** Marks the source claim non-rollbackable once deterministic runtime state is durable. */onInterventionPrepared?: () => void;+ /** Credentials frozen for the run; see {@link FrozenCredentialFacts}. */+ operationCredentials?: FrozenCredentialFacts;operationId: string;/** Operation-level skill set for SkillResolver */operationSkillSet?: OperationSkillSet;diff --git a/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.shareGate.test.ts b/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.shareGate.test.tsindex ed7bb006a9c..a1a3c4614d2 100644--- a/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.shareGate.test.ts+++ b/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.shareGate.test.ts@@ -1,6 +1,8 @@import type * as ModelBankModule from 'model-bank';import { beforeEach, describe, expect, it, vi } from 'vitest';+import { createServerAgentToolsEngine } from '@/server/modules/Mecha';+import { AiAgentService } from '../../index';// The share-gate filter now runs at the top of `discoverTools`, before@@ -234,6 +236,17 @@ describe('discoverTools - share gate blocks ungranted connectors early', () => {service = new AiAgentService(mockDb, 'creator-1');});+ it('starts an operation even when the tools engine reports no enabled tool ids', async () => {+ // `generateToolsDetailed` is not contractually obliged to return the field,+ // and the credential-snapshot read used to assume it was always an array.+ vi.mocked(createServerAgentToolsEngine).mockReturnValueOnce({+ generateToolsDetailed: vi.fn().mockReturnValue({ tools: [] }),+ getEnabledPluginManifests: vi.fn().mockReturnValue(new Map()),+ } as never);++ await expect(service.execAgent({ agentId: 'agent-1', prompt: 'Hello' })).resolves.toBeDefined();+ });+it('does not resolve or schedule refresh for a pinned connector missing from toolGrants', async () => {await service.execAgent({agentId: 'agent-1',diff --git a/apps/server/src/services/aiAgent/pipeline/startOperation.ts b/apps/server/src/services/aiAgent/pipeline/startOperation.tsindex eace1cccaf8..f97d1d1e20e 100644--- a/apps/server/src/services/aiAgent/pipeline/startOperation.ts+++ b/apps/server/src/services/aiAgent/pipeline/startOperation.ts@@ -282,6 +282,10 @@ export const startOperation = async (provider,},hooks,+ // Listed once during discovery: every step renders {{CREDS_LIST}} from+ // here instead of asking the Market API again. Awaited only now, so the+ // read overlapped with the operation preparation that ran in between.+ operationCredentials: await discovery.credentialFactsPromise,operationId,parentOperationId,signal,diff --git a/apps/server/src/services/aiAgent/pipeline/toolDiscovery.ts b/apps/server/src/services/aiAgent/pipeline/toolDiscovery.tsindex 8bbeaff5138..f4c05b2c146 100644--- a/apps/server/src/services/aiAgent/pipeline/toolDiscovery.ts+++ b/apps/server/src/services/aiAgent/pipeline/toolDiscovery.ts@@ -1,3 +1,4 @@+import { CredsIdentifier } from '@lobechat/builtin-tool-creds';import { GoalIdentifier, isGoalPrompt } from '@lobechat/builtin-tool-goal';import { LobeAgentManifest } from '@lobechat/builtin-tool-lobe-agent';import { MessageToolIdentifier } from '@lobechat/builtin-tool-message';@@ -23,7 +24,12 @@ import {resolveDiscoveryPool,resolveInvocationToolIds,} from '@lobechat/mecha';-import type { ChatTopicBotContext, FrozenModelFacts, RequestTrigger } from '@lobechat/types';+import type {+ ChatTopicBotContext,+ FrozenCredentialFacts,+ FrozenModelFacts,+ RequestTrigger,+} from '@lobechat/types';import {agentShareFileAccessScope,getActivePluginIds,@@ -144,6 +150,18 @@ export interface ToolDiscoveryResult {* context: it travels on the operation and the context engine injects it.*/connectorOwnershipNote?: string;+ /**+ * Credentials listed once for the whole operation; see+ * {@link FrozenCredentialFacts}. Absent when the run cannot inject+ * credentials.+ *+ * Deliberately still a promise: awaiting it here would put a Market round+ * trip between tool discovery and operation preparation, on the path to the+ * first token. The caller awaits it once the preparation it overlaps with is+ * done. Never rejects β a failed read resolves to `undefined` and the run+ * reads the list live, as it did before the snapshot existed.+ */+ credentialFactsPromise?: Promise<FrozenCredentialFacts | undefined>;executionPlan?: ExecutionPlan;hasAgentDocuments: boolean;hasEnabledKnowledgeBases: boolean;@@ -178,6 +196,41 @@ export interface ToolDiscoveryResult {* Returns the connector credential ownership note as run context when the run* borrows connectors other members authorized; the context engine injects it.*/+/**+ * The credentials the run may reference, read once. Inside a workspace an agent+ * only sees the workspace's shared organization credentials, never the+ * operator's personal ones β the scope is recorded on the snapshot so a step in+ * another scope falls back to a live read.+ *+ * Never fails the turn: without an answer the steps read the list live, exactly+ * as they did before the snapshot existed.+ */+const readCredentialFacts = async (+ deps: ToolDiscoveryDeps,+): Promise<FrozenCredentialFacts | undefined> => {+ try {+ const marketService = await deps.getMarketService();+ const result = deps.workspaceId+ ? await marketService.market.organizations.creds({ workspaceId: deps.workspaceId }).list()+ : await marketService.market.creds.list();+ const creds = (result as any)?.data ?? [];+ return {+ credentials: creds.map((cred: any) => ({+ description: cred.description,+ key: cred.key,+ name: cred.name,+ ownerDisplayName: cred.ownerDisplayName,+ ownerType: cred.ownerType,+ type: cred.type,+ })),+ workspaceId: deps.workspaceId,+ };+ } catch (error) {+ log('execAgent: failed to freeze credential facts: %O', error);+ return undefined;+ }+};+export const discoverTools = async (deps: ToolDiscoveryDeps,ctx: ExecRunContext,@@ -223,6 +276,8 @@ export const discoverTools = async (} = input;let tools: any[] | undefined;+ /** Started once the tool set is known; awaited at the return. */+ let credentialFactsPromise: Promise<FrozenCredentialFacts | undefined> | undefined;let toolsResult: { enabledToolIds: string[]; tools?: any[] | undefined } = {enabledToolIds: [],tools: undefined,@@ -989,6 +1044,14 @@ export const discoverTools = async (tools = toolsResult.tools;log('execAgent: enabled tool ids: %O', toolsResult.enabledToolIds);+ // Only a run that can inject credentials renders {{CREDS_LIST}}. Kick the+ // read off here and await it at the end: it is one Market round trip, and+ // every step of the run reads the answer back off the operation instead of+ // asking again.+ if (toolsResult.enabledToolIds?.includes(CredsIdentifier)) {+ credentialFactsPromise = readCredentialFacts(deps);+ }+// Start with the scoped manifest map (pluginIds + defaultToolIds)const manifestMap = toolsEngine.getEnabledPluginManifests(pluginIds);const discovery = resolveDiscoveryPool({@@ -1128,6 +1191,7 @@ export const discoverTools = async (connectorOwnershipNote,executionPlan,hasAgentDocuments,+ credentialFactsPromise,hasEnabledKnowledgeBases,lobehubSkillManifests,modelFacts,diff --git a/packages/agent-runtime/src/types/state.ts b/packages/agent-runtime/src/types/state.tsindex c57bd18adcd..51196b142e8 100644--- a/packages/agent-runtime/src/types/state.ts+++ b/packages/agent-runtime/src/types/state.ts@@ -20,6 +20,7 @@ import type {EvalToolForwardingConfig,ExecutionPlan,ExpertiseContextSnapshot,+ FrozenCredentialFacts,FrozenModelFacts,LobeAgentChatConfig,LobeAgentConfig,@@ -380,6 +381,13 @@ export interface AgentState {};};+ /**+ * Credentials this run listed once when it was created. A step renders+ * `{{CREDS_LIST}}` from here instead of asking the Market API again; absent+ * when the run has changed its own credentials since, and the steps after+ * that read the list live.+ */+ operationCredentials?: FrozenCredentialFacts;operationId: string;/** Operation-level tool set snapshot (immutable after creation) */operationToolSet?: OperationToolSet;diff --git a/packages/types/src/agentExecution/credentialFacts.ts b/packages/types/src/agentExecution/credentialFacts.tsnew file mode 100644index 00000000000..27e91163bf2--- /dev/null+++ b/packages/types/src/agentExecution/credentialFacts.ts@@ -0,0 +1,36 @@+import type { CredType } from '../creds';++/**+ * One credential as the run's prompt lists it. Structurally the `CredSummary`+ * the creds tool renders, redeclared here so the state type does not depend on+ * a builtin-tool package.+ */+export interface CredentialFact {+ description?: string;+ key: string;+ name: string;+ /** Present only for a workspace's merged view: who the credential belongs to. */+ ownerDisplayName?: string;+ ownerType?: 'organization' | 'user';+ type: CredType;+}++/**+ * The credentials an operation listed once when it was created, carried on+ * `AgentState` so a step renders `{{CREDS_LIST}}` from the snapshot instead of+ * asking the Market API again on every LLM attempt.+ *+ * Dropped the moment the run itself saves or connects a credential: from there+ * the list can change between two steps, so the remaining steps read it live.+ * Absent on operations created before the snapshot existed, and on runs that+ * activated the creds tool after they started.+ */+export interface FrozenCredentialFacts {+ credentials: CredentialFact[];+ /**+ * The scope the list was read in. Inside a workspace an agent only sees the+ * workspace's shared credentials, so a snapshot taken in another scope must+ * not be reused.+ */+ workspaceId?: string;+}diff --git a/packages/types/src/agentExecution/index.ts b/packages/types/src/agentExecution/index.tsindex e6b3cee0dee..0981921bc3b 100644--- a/packages/types/src/agentExecution/index.ts+++ b/packages/types/src/agentExecution/index.ts@@ -4,6 +4,7 @@ import type { DeviceUnavailableErrorData, WorkingDirConfig } from '../device';import type { TaskDetail, UIChatMessage } from '../message';import type { ChatTopic } from '../topic';+export * from './credentialFacts';export * from './modelFacts';export type AgentSignalOperationKind =