Skip to content

Commit fe99abe

Browse files
committed
add purpose field to tool specs
1 parent f144124 commit fe99abe

File tree

12 files changed

+277
-145
lines changed

12 files changed

+277
-145
lines changed

crates/agent/src/agent/agent_config/parse.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::str::FromStr;
66
use crate::agent::agent_loop::types::ToolUseBlock;
77
use crate::agent::protocol::AgentError;
88
use crate::agent::tools::BuiltInToolName;
9-
use crate::agent::util::path::canonicalize_path_impl;
9+
use crate::agent::util::path::canonicalize_path_sys;
1010
use crate::agent::util::providers::{
1111
RealProvider,
1212
SystemProvider,
@@ -32,7 +32,7 @@ impl<'a> ResourceKind<'a> {
3232

3333
let file_path = value.trim_start_matches("file://");
3434
if file_path.contains('*') || file_path.contains('?') {
35-
let canon = canonicalize_path_impl(file_path, sys, sys, sys)
35+
let canon = canonicalize_path_sys(file_path, sys)
3636
.map_err(|err| format!("Failed to canonicalize path for {}: {}", file_path, err))?;
3737
let pattern = glob::Pattern::new(canon.as_str())
3838
.map_err(|err| format!("Failed to create glob for {}: {}", canon, err))?;
@@ -258,7 +258,7 @@ impl FromStr for CanonicalToolName {
258258
#[cfg(test)]
259259
mod tests {
260260
use super::*;
261-
use crate::agent::util::test::TestSystem;
261+
use crate::agent::util::test::TestProvider;
262262

263263
#[test]
264264
fn test_resource_kind_parse_nonfile() {
@@ -270,7 +270,7 @@ mod tests {
270270

271271
#[test]
272272
fn test_resource_kind_parse_file_scheme() {
273-
let sys = TestSystem::new();
273+
let sys = TestProvider::new();
274274

275275
let resource = "file://project/README.md";
276276
assert_eq!(ResourceKind::parse_impl(resource, &sys).unwrap(), ResourceKind::File {

crates/agent/src/agent/consts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ pub const MAX_TOOL_SPEC_DESCRIPTION_LEN: usize = 10_004;
1515

1616
/// 10 MB
1717
pub const MAX_IMAGE_SIZE_BYTES: u64 = 10 * 1024 * 1024;
18+
19+
pub const TOOL_USE_PURPOSE_FIELD_NAME: &str = "__tool_use_purpose";
20+
pub const TOOL_USE_PURPOSE_FIELD_DESCRIPTION: &str = "A brief explanation why you are making this tool use.";

crates/agent/src/agent/mcp/service.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use crate::agent::agent_config::definitions::McpServerConfig;
4545
use crate::agent::agent_loop::types::ToolSpec;
4646
use crate::agent::util::expand_env_vars;
4747
use crate::agent::util::path::expand_path;
48+
use crate::util::providers::RealProvider;
4849

4950
/// This struct is consumed by the [rmcp] crate on server launch. The only purpose of this struct
5051
/// is to handle server-to-client requests. Client-side code will own a [RunningMcpService]
@@ -71,7 +72,9 @@ impl McpService {
7172
pub async fn launch(self) -> eyre::Result<(RunningMcpService, LaunchMetadata)> {
7273
match &self.config {
7374
McpServerConfig::Local(config) => {
74-
let cmd = expand_path(&config.command)?;
75+
// TODO - don't use real provider
76+
let cmd = expand_path(&config.command, &RealProvider)?;
77+
7578
let mut env_vars = config.env.clone();
7679
let cmd = Command::new(cmd.as_ref() as &str).configure(|cmd| {
7780
if let Some(envs) = &mut env_vars {

0 commit comments

Comments
 (0)