From d677c98f437c920fd954d166b0d7dd01b7b489d2 Mon Sep 17 00:00:00 2001 From: Francis <75153730+fbo25@users.noreply.github.com> Date: Thu, 4 Sep 2025 07:39:55 +0200 Subject: [PATCH] agent2: Use inline enums in `now` and `edit_file` tools JSON schema (#37397) Added schemars annotations to generate inline enums instead of references ($ref) in the JSON schema passed to LLMs. Concerns : - "timezeone" parameter for "now" tool function - "mode" parameter for "edit_file" tool function Should be the same for futures tools/functions enums. This is easier for LLMs to understand the schema since many of them don't use JSON references correctly. Tested with : - local GPT-OSS-120b with llama.cpp server (openai compatible) - remote Claude Sonnet 4.0 with Zed pro subscription Thanks in advance for the merge. (notice this is my first PR ever on Github, I hope I'm doing things well, please let me know if you have any comment - edit: just noticed my username/email were not correctly setup on my local git, sorry, it's been 5 years I've not used git) Closes #37389 Release Notes: - agent: Improve "now" and "edit_file" tool schemas to work with more models. --- crates/agent2/src/tools/edit_file_tool.rs | 1 + crates/agent2/src/tools/now_tool.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/crates/agent2/src/tools/edit_file_tool.rs b/crates/agent2/src/tools/edit_file_tool.rs index f86bfd25f74556118c827050837ec5beda37d471..ae37dc1f1340f9aa25789930b8f792ed8c3c8356 100644 --- a/crates/agent2/src/tools/edit_file_tool.rs +++ b/crates/agent2/src/tools/edit_file_tool.rs @@ -83,6 +83,7 @@ struct EditFileToolPartialInput { #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "lowercase")] +#[schemars(inline)] pub enum EditFileMode { Edit, Create, diff --git a/crates/agent2/src/tools/now_tool.rs b/crates/agent2/src/tools/now_tool.rs index 9467e7db68b7338d2f0ccd941aeaa551368eb1e1..49068be0dd91993ae7cc4d866617d399d754d529 100644 --- a/crates/agent2/src/tools/now_tool.rs +++ b/crates/agent2/src/tools/now_tool.rs @@ -11,6 +11,7 @@ use crate::{AgentTool, ToolCallEventStream}; #[derive(Debug, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "snake_case")] +#[schemars(inline)] pub enum Timezone { /// Use UTC for the datetime. Utc,