Skip to content

Commit 40fe5d4

Browse files
committed
Update AgentExecutor
1 parent 8334ce8 commit 40fe5d4

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

Tool/Sources/LangChain/Agent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public extension CallbackEvents {
4747

4848
struct AgentFunctionCallingToolReportProgress: CallbackEvent {
4949
public struct Info {
50-
let functionName: String
51-
let progress: String
50+
public let functionName: String
51+
public let progress: String
5252
}
5353

5454
public let info: Info

Tool/Sources/LangChain/AgentExecutor.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,13 @@ extension AgentExecutor {
158158
}
159159
guard let tool = tools[action.toolName] else { throw InvalidToolError() }
160160
taskGroup.addTask {
161-
let observation = try await tool.run(input: action.toolInput)
162-
return action.observationAvailable(observation)
161+
do {
162+
let observation = try await tool.run(input: action.toolInput)
163+
return action.observationAvailable(observation)
164+
} catch {
165+
let observation = error.localizedDescription
166+
return action.observationAvailable(observation)
167+
}
163168
}
164169
}
165170
var completedActions = [AgentAction]()

0 commit comments

Comments
 (0)