Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 18 additions & 7 deletions crates/jp_cli/src/cmd/query/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,7 @@ impl StreamEventHandler {
};

self.tool_call_responses.push(response.clone());
return build_tool_call_response(
&cfg.style,
&response,
&tool_config,
handler,
);
return Ok(None);
}
}
}
Expand Down Expand Up @@ -205,6 +200,20 @@ impl StreamEventHandler {
self.tool_call_responses.push(result.clone());
return build_tool_call_response(&cfg.style, &result, &tool_config, handler);
}
Err(ToolError::Skipped { reason }) => {
self.tool_call_responses.push(ToolCallResponse {
id: call.id.clone(),
result: {
let mut msg = "Tool execution skipped by user.".to_string();
if let Some(reason) = reason {
msg.push_str(&format!("\n\n{reason}"));
}
Ok(msg)
},
});

return Ok(None);
}
Err(ToolError::NeedsInput { question }) => {
// Check answers in priority order:
// 1. Turn-level persisted answers
Expand Down Expand Up @@ -353,7 +362,9 @@ fn build_tool_call_response(
_ => content.lines().count(),
};

if handler.render_tool_calls {
if handler.render_tool_calls
&& !matches!(tool_config.style().inline_results, InlineResults::Off)
{
let mut intro = "\nTool call result".to_owned();
match tool_config.style().inline_results {
InlineResults::Truncate(TruncateLines { lines }) if lines < content.lines().count() => {
Expand Down
6 changes: 6 additions & 0 deletions crates/jp_config/src/conversation/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,9 @@ pub enum RunMode {

/// Open an editor to edit the tool call before running it.
Edit,

/// Skip running the tool.
Skip,
}

/// How to deliver the results of the tool to the assistant.
Expand All @@ -887,6 +890,9 @@ pub enum ResultMode {

/// Open an editor to edit the tool call result before delivering it.
Edit,

/// Skip delivering the results of the tool call.
Skip,
}

/// Tool configuration with global defaults.
Expand Down
6 changes: 6 additions & 0 deletions crates/jp_llm/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ pub enum ToolError {
error: serde_json::Error,
},

#[error("Tool call failed: {0}")]
ToolCallFailed(String),

#[error("Failed to open editor to edit tool call")]
OpenEditorError {
arguments: serde_json::Value,
Expand Down Expand Up @@ -183,6 +186,9 @@ pub enum ToolError {
#[error("Needs input: {question:?}")]
NeedsInput { question: jp_tool::Question },

#[error("Skipped tool execution")]
Skipped { reason: Option<String> },

#[error("Serialization error")]
Serde(#[from] serde_json::Error),

Expand Down
Loading