Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/slack/src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export const createTools = ({
}: CreateToolsOptions) => {
const sendMessageDescription =
"The timestamp of the message to send in response to.";
let sendMessageTs = z
// Use coerce.string() to handle LLMs that pass timestamps as numbers
let sendMessageTs = z.coerce
.string()
.describe(sendMessageDescription) as unknown as z.ZodOptional<z.ZodString>;
if (!disableMessagingInChannels) {
Expand Down Expand Up @@ -170,7 +171,9 @@ ${formattingRules}`
Prefer reacting to the most recent messages in a thread.`,
inputSchema: z.object({
channel: z.string().describe("The channel to react to the message in."),
ts: z.string().describe("The timestamp of the message to react to."),
ts: z.coerce
.string()
.describe("The timestamp of the message to react to."),
reaction: z.string().describe(`The Slack reaction to add to the message.

Reactions:
Expand Down Expand Up @@ -260,7 +263,7 @@ IMPORTANT: This MUST be text, not an emoji.`),
"Read a message from a channel by ID. This reads attachments as well.",
inputSchema: z.object({
channel: z.string().describe("The channel to read the message from."),
ts: z.string().describe("The timestamp of the message to read."),
ts: z.coerce.string().describe("The timestamp of the message to read."),
}),
execute: async (args) => {
const messages = await client.conversations.history({
Expand Down Expand Up @@ -340,7 +343,7 @@ IMPORTANT: This MUST be text, not an emoji.`),
channel: z
.string()
.describe("The channel to read the thread replies from."),
ts: z
ts: z.coerce
.string()
.describe(
"The timestamp of the message to read the thread replies from."
Expand Down Expand Up @@ -455,7 +458,7 @@ Clear the status by passing an empty string.`,
"A short present-participle verb + brief user-facing update. NEVER use underscores or non-natural language words. Keep it short - under 100 characters."
),
channel: z.string().describe("The channel to report your status to."),
thread_ts: z
thread_ts: z.coerce
.string()
.describe("The timestamp of the thread to report your status to."),
}),
Expand Down
Loading