🤯 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(agent-runtime): honor auto-run for dynamic approvals (#16844)
Arvin Xu325cc1b9064d
diff --git a/packages/agent-runtime/src/agents/GeneralChatAgent.ts b/packages/agent-runtime/src/agents/GeneralChatAgent.tsindex d47360711fd..203409b3f73 100644--- a/packages/agent-runtime/src/agents/GeneralChatAgent.ts+++ b/packages/agent-runtime/src/agents/GeneralChatAgent.ts@@ -187,7 +187,10 @@ export class GeneralChatAgent implements Agent {if (dynamicPolicy !== undefined) {if (dynamicPolicy === 'never') {toolsToExecute.push(toolCalling);- } else if (approvalMode === 'headless' && dynamicPolicy !== 'always') {+ } else if (+ (approvalMode === 'auto-run' || approvalMode === 'headless') &&+ dynamicPolicy !== 'always'+ ) {toolsToExecute.push(toolCalling);} else {toolsNeedingIntervention.push(toolCalling);diff --git a/packages/agent-runtime/src/agents/__tests__/GeneralChatAgent.test.ts b/packages/agent-runtime/src/agents/__tests__/GeneralChatAgent.test.tsindex 6a1afd43845..16345a72ce2 100644--- a/packages/agent-runtime/src/agents/__tests__/GeneralChatAgent.test.ts+++ b/packages/agent-runtime/src/agents/__tests__/GeneralChatAgent.test.ts@@ -2043,6 +2043,73 @@ describe('GeneralChatAgent', () => {]);});+ it('should execute dynamic required tools when user approvalMode is auto-run', async () => {+ const agent = new GeneralChatAgent({+ agentConfig: { maxSteps: 100 },+ dynamicInterventionAudits: {+ pathScopeAudit: async (toolArgs, metadata) => {+ const workingDirectory = metadata?.workingDirectory as string | undefined;+ if (!workingDirectory) return false;+ const path = toolArgs.path as string;+ return !path.startsWith(workingDirectory);+ },+ },+ operationId: 'test-session',+ modelRuntimeConfig: mockModelRuntimeConfig,+ });++ const toolCall: ChatToolPayload = {+ id: 'call-1',+ identifier: 'local-system',+ apiName: 'readLocalFile',+ arguments: '{"path":"/etc/passwd"}',+ type: 'builtin',+ };++ const state = createMockState({+ metadata: { workingDirectory: '/workspace' },+ toolManifestMap: {+ 'local-system': {+ identifier: 'local-system',+ api: [+ {+ name: 'readLocalFile',+ humanIntervention: {+ dynamic: {+ default: 'never',+ policy: 'required',+ type: 'pathScopeAudit',+ },+ },+ },+ ],+ },+ },+ userInterventionConfig: {+ approvalMode: 'auto-run',+ allowList: [],+ },+ });++ const context = createMockContext('llm_result', {+ hasToolsCalling: true,+ toolsCalling: [toolCall],+ parentMessageId: 'msg-1',+ });++ const result = await agent.runner(context, state);++ expect(result).toEqual([+ {+ type: 'call_tool',+ payload: {+ parentMessageId: 'msg-1',+ toolCalling: toolCall,+ },+ },+ ]);+ });+it('should execute tool when dynamic policy resolves to never', async () => {const agent = new GeneralChatAgent({agentConfig: { maxSteps: 100 },