Creates a serializable configuration template for isolated Finn Agent sessions. Unlike an ellmer Chat, this adapter replays system instructions and conversation history as text on each request. Finn remains responsible for tools, proposal validation, and retries.

chat_copilot(model = "auto", command = "copilot", timeout = 120)

Arguments

model

A nonempty Copilot model identifier available to your account. Defaults to "auto", letting Copilot select the model for each request.

command

Copilot executable name or path. Defaults to "copilot". On Windows, prefer the standalone copilot.exe rather than an npm .cmd shim.

timeout

Positive finite timeout in seconds for each CLI request.

Value

A finnts_copilot_chat environment with $chat(prompt, echo = FALSE), $chat_structured(prompt, type, echo = "none", convert = FALSE), $set_system_prompt(prompt), $get_system_prompt(), $get_model(), and $get_turns() methods. $chat() returns one character string. $chat_structured() accepts ellmer basic, enum, array and object types and returns parsed JSON without vector/data-frame simplification. It supports only convert = FALSE; echo is "none", "text", "output" or "all". Raw JSON Schema and ignored-field types are not supported. Successful exchanges update in-memory history; failed requests do not.

Details

Requires GitHub Copilot CLI 1.0.93 or later, an entitled GitHub account, and the optional processx package. Authentication uses COPILOT_GITHUB_TOKEN, GH_TOKEN, or GITHUB_TOKEN (in that order), or credentials retrieved privately with gh auth token. Tokens are resolved in the process making the request, not stored in the template.

Every request uses a new CLI home and working directory under tempdir(). The CLI saves local configuration, transcripts, and session state there; these can contain sensitive prompt and response data. Only use data approved for GitHub Copilot. Repository instructions, hooks, IDE connections, built-in MCP servers, and model tools are disabled. Cached Copilot-only logins are not copied into the isolated home; use an environment token or gh auth login instead.

Use this template with create_custom_model() as well as Agent workflows. Custom-model authoring also requires ellmer >= 0.4.0 and S7 for response types. The adapter requests JSON and checks its shape locally; Copilot CLI does not enforce the schema. Invalid responses raise finnts_copilot_structured_error without committing history or retrying. The usual custom-model approval and numerical validation gates still apply.

Examples

if (FALSE) { # \dontrun{
llm <- chat_copilot()
agent <- set_agent_info(
  project_info = project, llm = llm,
  input_data = hist_data, forecast_horizon = 6
)
} # }