Last active
July 11, 2025 03:11
-
-
Save kishikawakatsumi/c07e5ecc2d0811cd8b530d0fb7e2bd01 to your computer and use it in GitHub Desktop.
[FB18767141] The argument (date) passed to tool calling is incorrect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am trying tool calling with the following code. When I give the prompt “Add a meeting to the schedule for next Wednesday at 10:00 a.m.”, the CalendarTool is called, but the date argument passed is incorrect. Since I am expecting next Wednesday, the expected behavior is for it to return “Jul 15th, 2025,” but it returns “2024-10-23T10:00:00.” | |
Also attach the actual project. | |
```swift | |
import Cocoa | |
import FoundationModels | |
import EventKit | |
@main | |
class AppDelegate: NSObject, NSApplicationDelegate { | |
func applicationDidFinishLaunching(_ aNotification: Notification) { | |
Task { | |
let session = LanguageModelSession( | |
tools: [CalendarTool()], | |
instructions: "You are a secretary. Select one action to execute from ‘create’, ‘query’, ‘read’, or ‘update’ from the prompt, and pass the processing to CalendarTool." | |
) | |
let response = try await session.respond(to: Prompt("Add a meeting to the schedule for next Wednesday at 10:00 a.m.")) | |
print(response.content) | |
} | |
} | |
} | |
public struct CalendarTool: Tool { | |
public let name = "CalendarTool" | |
public let description = "Create, read, and query calendar events" | |
@Generable | |
public struct Arguments { | |
@Guide(description: "The action to perform: 'create', 'query', 'read', 'update'") | |
public var action: String | |
@Guide(description: "Event title for creating or updating") | |
public var title: String? | |
@Guide(description: "Start date in ISO format (YYYY-MM-DD HH:mm:ss)") | |
public var startDate: String? | |
@Guide(description: "End date in ISO format (YYYY-MM-DD HH:mm:ss)") | |
public var endDate: String? | |
@Guide(description: "Location for the event") | |
public var location: String? | |
@Guide(description: "Notes for the event") | |
public var notes: String? | |
@Guide(description: "Calendar name to use (defaults to default calendar)") | |
public var calendarName: String? | |
@Guide(description: "Number of days to query (for query action)") | |
public var daysAhead: Int? | |
@Guide(description: "Event identifier for reading or updating specific event") | |
public var eventId: String? | |
public init( | |
action: String = "", | |
title: String? = nil, | |
startDate: String? = nil, | |
endDate: String? = nil, | |
location: String? = nil, | |
notes: String? = nil, | |
calendarName: String? = nil, | |
daysAhead: Int? = nil, | |
eventId: String? = nil | |
) { | |
self.action = action | |
self.title = title | |
self.startDate = startDate | |
self.endDate = endDate | |
self.location = location | |
self.notes = notes | |
self.calendarName = calendarName | |
self.daysAhead = daysAhead | |
self.eventId = eventId | |
} | |
} | |
public init() {} | |
public func call(arguments: Arguments) async throws -> ToolOutput { | |
print(arguments.startDate) | |
print(arguments.endDate) | |
return ToolOutput("") | |
} | |
} | |
``` |
Author
kishikawakatsumi
commented
Jul 11, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment