Skip to main content

codetether_agent/session/helper/runtime/
prompt.rs

1/// Return whether the tool requires interactive user input.
2///
3/// # Examples
4///
5/// ```rust
6/// use codetether_agent::session::helper::runtime::is_interactive_tool;
7///
8/// assert!(is_interactive_tool("question"));
9/// assert!(!is_interactive_tool("read"));
10/// ```
11pub fn is_interactive_tool(tool_name: &str) -> bool {
12    matches!(tool_name, "question")
13}
14
15/// Return whether a provider name refers to a local CUDA-backed provider.
16///
17/// # Examples
18///
19/// ```rust
20/// use codetether_agent::session::helper::runtime::is_local_cuda_provider;
21///
22/// assert!(is_local_cuda_provider("local_cuda"));
23/// assert!(is_local_cuda_provider("local-cuda"));
24/// assert!(!is_local_cuda_provider("openai"));
25/// ```
26pub fn is_local_cuda_provider(provider: &str) -> bool {
27    matches!(provider, "local-cuda" | "local_cuda" | "localcuda")
28}
29
30/// Return the lightweight system prompt used for local CUDA providers.
31///
32/// # Examples
33///
34/// ```rust
35/// use codetether_agent::session::helper::runtime::local_cuda_light_system_prompt;
36///
37/// let prompt = local_cuda_light_system_prompt();
38/// assert!(prompt.contains("local CUDA assistant"));
39/// ```
40pub fn local_cuda_light_system_prompt() -> String {
41    std::env::var("CODETETHER_LOCAL_CUDA_SYSTEM_PROMPT").unwrap_or_else(|_| {
42        "You are CodeTether local CUDA assistant. Be concise and execution-focused. \
43Use tools only when needed. For tool discovery, call list_tools first, then call specific tools with valid JSON arguments. \
44Do not invent tool outputs."
45            .to_string()
46    })
47}
48
49/// Return whether a successful codesearch result represents a no-match response.
50///
51/// # Examples
52///
53/// ```rust
54/// use codetether_agent::session::helper::runtime::is_codesearch_no_match_output;
55///
56/// assert!(is_codesearch_no_match_output(
57///     "codesearch",
58///     true,
59///     "No matches found for pattern: example",
60/// ));
61/// assert!(!is_codesearch_no_match_output("read", true, "No matches found"));
62/// ```
63pub fn is_codesearch_no_match_output(tool_name: &str, success: bool, output: &str) -> bool {
64    tool_name == "codesearch"
65        && success
66        && output
67            .to_ascii_lowercase()
68            .contains("no matches found for pattern:")
69}