You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#' An agent that researches R packages and provides example code for specific R
4
+
#' tasks. This agent is designed to help users find the best R packages for
5
+
#' specific tasks, list key functions and arguments, and return runnable
6
+
#' example code.
7
+
#'
8
+
#' @param client An [ellmer::Chat] client, defaults to [btw_client()].
9
+
#' @inheritParams btw_tool_agent
10
+
#'
11
+
#' @returns Returns an aync [ellmer::tool()] that can be used to invoke the
12
+
#' R task research agent.
13
+
#'
14
+
#' @family agents
15
+
#' @export
16
+
btw_agent_researcher_r_task<-function(
17
+
client= btw_client(tools=FALSE),
18
+
tools= c("docs", "search", "session")
19
+
) {
20
+
btw_tool_agent(
21
+
client=client,
22
+
tools=tools,
23
+
turns=FALSE, # Don't use initial turns, this agent is stateless
24
+
name="btw_agent_researcher_r_task",
25
+
title="R Task Research Agent",
26
+
description=r"(Research an R programming task.
27
+
28
+
Rapidly researches a single, narrowly-scoped R-programming task. Finds the best CRAN (or locally installed) package(s), lists key functions/arguments, and returns runnable example code.
29
+
30
+
INPUT
31
+
A unique, non-overlapping question such as "Drawaclusteredheat-map", "Fitabeta-regression", or "Readaparquetfile".
32
+
33
+
PARALLEL TASKS
34
+
Prefer batching distinct research tasks only when they are clearly orthogonal.
35
+
36
+
GUIDELINES
37
+
* Break the user's goal into the small, independent R tasks.
38
+
* Avoid issuing more than one call for the same or highly similar question.
39
+
* Limit parallel calls to reduce duplication and API load.
40
+
* Do not use this tool for broad or overlapping questions.
41
+
* Only use this tool when you do not already know the answer.
42
+
)",
43
+
system_prompt=r"---(
44
+
MISSION
45
+
Treat the input as an explicit research question about R packages.
46
+
Search CRAN docs, vignettes, help pages, and other provided tools to answer that question.
47
+
Return the answer in a compact format that explains your findings and provides example code that can be run in R.
48
+
49
+
RESPONSE FORMAT
50
+
Your response should include (one block per topic or package)
51
+
52
+
* Task
53
+
* Package(s): pkg1, pkg2, ...
54
+
* Why these packages? 1-sentence rationale.
55
+
* Key functions & arguments related to the task as a bullet list.
56
+
* Example code in a fenced R snippet that can be run as-is.
57
+
* Citations: minimal list of URLs or help files consulted.
58
+
59
+
GUIDELINES
60
+
* Be factual; no speculation.
61
+
* Prefer base CRAN packages unless the question implies otherwise.
62
+
* Keep prose succinct; let code illustrate usage.
63
+
* If multiple packages solve the task, list the best 2-3 and show code for the top choice.
64
+
* If no suitable package exists, say so and suggest an alternative strategy.
0 commit comments