fix(telegram): make buttons schema optional in message tool

The Telegram plugin injects a `buttons` property into the message tool
schema via `createMessageToolButtonsSchema()`, but without wrapping it
in `Type.Optional()`. This causes TypeBox to include `buttons` in the
JSON Schema `required` array.

In isolated sessions (e.g. cron jobs) where no `currentChannel` is set,
all plugin schemas are merged into the message tool. When the LLM calls
the message tool without a `buttons` parameter, AJV validation fails
with: `buttons: must have required property 'buttons'`.

Wrap the buttons schema in `Type.Optional()` so it is not required.
This commit is contained in:
liuyang
2026-03-23 10:45:43 +08:00
committed by Ayaan Zaidi
parent a835c200f3
commit bf12835995

View File

@@ -1,3 +1,4 @@
import { Type } from "@sinclair/typebox";
import {
createUnionActionGate,
listTokenSourcedAccounts,
@@ -110,7 +111,7 @@ function describeTelegramMessageTool({
if (discovery.buttonsEnabled) {
schema.push({
properties: {
buttons: createMessageToolButtonsSchema(),
buttons: Type.Optional(createMessageToolButtonsSchema()),
},
});
}