Conversation
|
I was having troubles withe push flow, so I just pushed all as no verify to get initial feedback, also the app suddenly looses the ability to access Xcode workspace which makes a bit hard to test this reliable. Maybe we can have a quick chat to debug. |
|
|
||
| do { | ||
| // Request approval before executing the tool | ||
| try await context.requestToolApproval(toolUse) |
| public enum LLMServiceError: Error { | ||
| case toolUsageDenied | ||
| } | ||
|
|
||
| extension LLMServiceError: LocalizedError { | ||
| public var errorDescription: String? { | ||
| switch self { | ||
| case .toolUsageDenied: | ||
| return "User denied permission to execute this tool. Please suggest an alternative approach or ask for clarification." | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
nit: if you don't care about having a specific error type and just want a localized error, you can use AppFoundation.AppError
There was a problem hiding this comment.
I think this is relevant as we are sending this message in to the chat conversation history so the LLM knows what to do next, the LLM has no concept of our UX so we need to give it hints about what is happening and how to recover
There was a problem hiding this comment.
I meant that AppError can preserve your message without requiring a dedicated type, but you would not be able to do something like
catch error as LLMServiceError {
} catch {
}There was a problem hiding this comment.
Oh so you already have a custom error? yeah I can use that I guess
app/modules/features/Chat/Sources/Input/ChatInputViewModel.swift
Outdated
Show resolved
Hide resolved
| enum ApprovalResult { | ||
| case approved | ||
| case denied | ||
| case alwaysApprove(toolName: String) |
There was a problem hiding this comment.
maybe also "toolUseCancel" ?
There was a problem hiding this comment.
instead of denied?
|
|
||
| // MARK: - ToolApprovalRequest | ||
|
|
||
| // TODO: james - should move this `ToolFoundation`? |
There was a problem hiding this comment.
As long as we're not using this outside of Chat I'd say no, but if we do yes
| } | ||
|
|
||
| private func storeAlwaysApprovePreference(for toolName: String) { | ||
| userDefaults.set(true, forKey: "\(Self.userDefaultsAlwaysApproveKey)\(toolName)") |
There was a problem hiding this comment.
👍 using user default is ok for now. I think eventually we'll want to move this to the Setting, so that we can display this in the settings and users can also update them from there.
There was a problem hiding this comment.
yeah I can se this moving there eventually.
|
(just pushed a merge commit to make changes easier to review) |
| Task { [weak self] in | ||
| guard let self else { return } | ||
| do { | ||
| try await self.context.requestToolApproval(toolUse) |
There was a problem hiding this comment.
you made a good point about the tool use showing up in the UI. If we don't want to show it, we could ask for approval before inserting the tool use in the chat history (here and here).
But I can see this being an issue because we likely want to keep the tool use in the history, even if it is rejected, so that the next message has the rejection and the LLM can continue based of that.
What do you think of instead modifying the Tool protocol to better describe the pending approval / rejected status? We could then have a standard UI for a rejected tool use. We can do this in a follow up PR.
There was a problem hiding this comment.
What do you think of instead modifying the Tool protocol to better describe the pending approval / rejected status? We could then have a standard UI for a rejected tool use. We can do this in a follow up PR.
I think this is the correct move yes.
Co-authored-by: Guillaume Sabran <sabranguillaume@gmail.com>
Co-authored-by: Guillaume Sabran <sabranguillaume@gmail.com>
8d8b39a to
2fb5933
Compare
|
2 pending jobs Failing I am also getting this error locally. cc @gsabran |
|
oh I got some CI credits back. Yeah! No worries about CI. Could you actually comment out pull_request: So that I keep my CI credits to test automating releasing the app? |
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] |
| } | ||
|
|
||
| close_xcode() { | ||
| if pgrep -x "Xcode" > /dev/null; then |
| # So we need to exit with a non-zero exit code to indicate that the build needs to be restarted with the correct files. | ||
| echo "The local server has been updated. Please restart the build." >&2 | ||
| exit 1 | ||
| fi |
| name: "Bash", | ||
| parameters: { | ||
| command: "cd /Users/me/command/app/modules && swift test 2>&1 | head -100", | ||
| command: "cd /Users/guigui/dev/Xcompanion/app/modules && swift test 2>&1 | head -100", |
There was a problem hiding this comment.
oh really? Weird I'll look into it
|
I pushed some changes made by the linter, tagged you on those in case you want to take a look. Thanks! |
| let action: () -> Void | ||
| let systemNames: [String] | ||
| let label: String | ||
| let onHoverColor: Color | ||
| let padding: CGFloat | ||
| let cornerRadius: CGFloat |
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] |





Added approval flow.
TODO: