Package: gptr 1.0.0

Wanjun Gu

gptr: Language Model Agents in Live 'R' Sessions

Runs language model agents in an existing 'R' session, where generated code can inspect and modify objects already in memory. The peter() function supports interactive chat and programmatic calls. Conversational models use tools and return session objects; typed decision models return logical, character or numeric vectors with associated model probabilities. Supports the 'Anthropic' <https://platform.claude.com/docs/en/api/overview>, 'OpenAI' <https://developers.openai.com/api/reference/overview> and 'Google Gemini' <https://ai.google.dev/gemini-api/docs> APIs, 'OpenAI'-compatible endpoints, local 'Ollama' <https://ollama.com> models, and the 'Claude Code' and 'Codex' command line tools. Decision models include 'Jev', hosted by 'TypeSafe AI' <https://docs.typesafe.ai/introduction>, and the local 'Clef'. Top-level agent calls and their executed code can be recorded in 'R' scripts, 'R Markdown' and 'Quarto' documents, or 'Jupyter' notebooks. Recorded 'R' scripts can be replayed without model calls when the required inputs and packages are available.

Authors:Wanjun Gu [aut, cre, cph], Tianlu Zhu [ctb], Gianmarco Bellucci [ctb]

gptr_1.0.0.tar.gz
gptr_1.0.0.zip(r-4.7-any)gptr_1.0.0.zip(r-4.6-any)
gptr_1.0.0.tar.gz(r-4.7-any)gptr_1.0.0.tar.gz(r-4.6-any)
gptr_1.0.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
gptr/json (API)

# Install 'gptr' in R:
install.packages('gptr', repos = c('https://cran.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/broccolito/gptr/issues

Pkgdown/docs site:https://broccolito.github.io

On CRAN:

Conda:

4.80 score 84 scripts 252 downloads 66 exports 8 dependencies

Last updated from:9e80ed4c4f. Checks:6 OK. Indexed: no.

TargetResultTimeFilesSyslog
linux-develOK335
source / vignettesOK288
linux-releaseOK301
windows-develOK365
windows-releaseOK297
wasm-releaseOK150

Exports:gptr_adaptergptr_agentgptr_agentsgptr_apigptr_artifactsgptr_backendgptr_blocksgptr_cachegptr_cancelgptr_checkgptr_checkpointsgptr_coachgptr_commandgptr_configgptr_context_blockgptr_describegptr_docgptr_envgptr_exportgptr_fake_providergptr_forkgptr_hookgptr_initgptr_jobsgptr_lastgptr_logingptr_logoutgptr_mcpgptr_mcp_addgptr_mcp_removegptr_mcp_servegptr_modelsgptr_ongptr_parallelgptr_permissionsgptr_pluginsgptr_policygptr_preimagegptr_probgptr_promptgptr_prompt_sectiongptr_providergptr_providersgptr_redactgptr_registergptr_registrygptr_reloadgptr_resumegptr_returngptr_rewindgptr_riskgptr_routergptr_scrubgptr_sessionsgptr_skillsgptr_sourcegptr_specgptr_steergptr_stepgptr_tailorgptr_toolgptr_tool_resultgptr_trustgptr_usagegptr_waitpeter

Dependencies:clicurljsonliteprocessxpsR6rlangyaml

Configuration
Scope and precedence | Settings by purpose | R options | Environment and credentials

Last update: 2026-11-01
Started: 2026-11-01

Execution model
One language model turn | Where objects live | What the session retains | Permissions and concurrency

Last update: 2026-11-01
Started: 2026-11-01

Extending gptr
A tool the model calls as an R function | A permission policy | A hook on a session | Prompt sections, context blocks and commands | Other kinds | Extensions and plugins

Last update: 2026-11-01
Started: 2026-11-01

Getting started
A first call | Try it offline | The pipe steers one session | Stopping instead of guessing | At the console | Connecting a real model | Where to go next

Last update: 2026-11-01
Started: 2026-11-01

Harnesses and coaching
Tailor a harness by hand | Call and change it | Coach a harness | Coach on a Claude Code or Codex plan | Save, share and reuse | Safety | Recording coaching in a script | Read more

Last update: 2026-11-01
Started: 2026-11-01

Interactive console
Enter prompts, objects and your own R | Commands | Approve changes | Type while Peter works | Pause, continue and leave

Last update: 2026-11-01
Started: 2026-11-01

Language models
Choose and connect a model | API providers | Azure OpenAI and Amazon Bedrock | Subscription command-line tools | Local Ollama models | Work with a session | Put calls in functions and scripts

Last update: 2026-11-01
Started: 2026-11-01

MCP
List first, connect when needed | Register a server | Call tools as R functions | Authenticate an HTTP server | Serve your R session

Last update: 2026-11-01
Started: 2026-11-01

Record, replay and export
Program in natural language, then use ordinary R | Calls inside functions | Recording a designated R script | Inspecting and replaying | R Markdown, Quarto and Jupyter | Harness calls and coaching calls | Exporting a recorded script | Asking Peter to summarize a completed workflow

Last update: 2026-11-01
Started: 2026-11-01

Skills and plugins
Find and use skills | Write a skill | Skills and rules in a harness | Prompt templates and project instructions | Agent definition files | Package a plugin | Trust and precedence

Last update: 2026-11-01
Started: 2026-11-01

Teams and background work
A team of named roles | A fan-out over input elements | Independent calls with gptr_parallel() | Coaching runs many sessions | Deferred sessions and SDK control | Experimental background work | Checkpoints, usage and durable history

Last update: 2026-11-01
Started: 2026-11-01

Token efficiency
Inspecting the prompt | Object descriptions and result size | Reported usage and estimated components | Budgets and partial results | Compaction | Three different caches | Explicit ways to reduce context

Last update: 2026-11-01
Started: 2026-11-01

Tools and artifacts
Inspect objects, files and output | Shell commands and scripts | Background programs | Python, SQL and other engines | Build a versioned artifact | Inspect, reopen and stop artifacts

Last update: 2026-11-01
Started: 2026-11-01

Typed decisions
Logical decisions and probabilities | Structured inputs and batch shape | Uncertainty in filters, functions and loops | Choices and fractional scores | Provenance and caching | System 1 routes or judges System 2 | Native Jev, local Ollama and explicit emulation

Last update: 2026-11-01
Started: 2026-11-01

Why Peter?
Peter Naur: make the program readable | Peter Cathcart Wason: examine the reasoning | Two ideas in one R workflow

Last update: 2026-11-01
Started: 2026-11-01

Readme and manuals

Help Manual

Help pageTopics
Convert a session summary to a data frameas.data.frame.gptr_session_summary
Format a risk classificationformat.gptr_risk print.gptr_risk
Format a session as its textas.character.gptr_session format.gptr_session
Define a wire adaptergptr_adapter
Define a sub-agentgptr_agent
Extension API version and featuresgptr_api
List, open, relaunch and stop artifactsgptr_artifacts
Define a sub-agent backendgptr_backend
List the agent blocks of a documentgptr_blocks
Inspect, prune or clear gptr's cachesgptr_cache
Cancel running sessionsgptr_cancel
Check an extension for conformancegptr_check
Coach a harness by running your taskgptr_coach
Define a slash commandgptr_command
Show or change gptr's settingsgptr_config
Define a context blockgptr_context_block
Compact, budgeted description of an R objectgptr_describe gptr_describe.ArrowTabular gptr_describe.data.frame gptr_describe.Dataset gptr_describe.DBIConnection gptr_describe.default gptr_describe.dgCMatrix gptr_describe.environment gptr_describe.formula gptr_describe.function gptr_describe.ggplot gptr_describe.gptr_session gptr_describe.list gptr_describe.lm gptr_describe.matrix gptr_describe.Seurat gptr_describe.SingleCellExperiment
Bind this R process to a history documentgptr_doc
Data egress: what gptr sends to model providersgptr_egress
Load keys from a .env filegptr_env
Export a recorded R document as ordinary R or a clean Peter scriptgptr_export
A scripted, offline fake model providergptr_fake_provider
Fork a sessiongptr_fork
Define an event hookgptr_hook
Create the project workspace .gptr/gptr_init
List or stop gptr's background jobs and child processesgptr_jobs
Sign in to a model provider or an MCP servergptr_login gptr_logout
List MCP servers and their toolsgptr_mcp
Add or remove an MCP server in gptr's configurationgptr_mcp_add gptr_mcp_remove
Serve the live R session to other agents over MCPgptr_mcp_serve
List models from the model cataloggptr_models
Listen to a session's eventsgptr_on
Options that control gptrgptr_options
Run several agent calls concurrentlygptr_parallel
Manage permission rulesgptr_permissions
Plugins known to this sessiongptr_plugins
Define a permission policygptr_policy
Tell the object checkpointer how to capture an objectgptr_preimage gptr_preimage.data.table gptr_preimage.default
Probabilities and confidence of System 1 answersgptr_prob
Show the frozen system prompt, tool array and first messagegptr_prompt print.gptr_prompt_view
Define a system-prompt sectiongptr_prompt_section
Define a model providergptr_provider
List the configured model providersgptr_providers
Redact secrets from text or from a nested listgptr_redact
Register a capability specgptr_register
List the extension registrygptr_registry
Reload extensionsgptr_reload
Designate the result of an agent rungptr_return
Rewind a session: undo turns, restore objects and files, move the conversationgptr_checkpoints gptr_rewind
Classify the risk of R code without running itgptr_risk
Define a model routergptr_router
Find, and optionally remove, registered secrets in persisted filesgptr_scrub
Security considerationsgptr_security
Stored and live sessionsgptr_last gptr_resume gptr_sessions
Discovered skills and agentsgptr_agents gptr_skills
Source a history document, regenerating stale blocks without running the old codegptr_source
Build a spec of any registered kindgptr_spec
Steer a sessiongptr_steer
Advance a sessiongptr_step
Build a harness: peter with your own fixed arguments and coachinggptr_tailor
Define a toolgptr_tool
Build a tool resultgptr_tool_result
Record or read whether a project is trustedgptr_trust
Token usage and costgptr_usage
Wait for sessions to settlegptr_wait
Background sessions (experimental)background-sessions gptr-background
Run an agent in this R sessionpeter
Print a sessionprint.gptr_session
Print a session summaryprint.gptr_session_summary
Show a session's structurestr.gptr_session
Summarize a session as its historysummary.gptr_session