-
-
Notifications
You must be signed in to change notification settings - Fork 2
REPL
In addition to being a CLI, Loki also has a built-in REPL (Read-Execute-Print-Loop). This enables users to quickly try out prompts, commands, configurations, and everything in between without having to modify the same command every time.
You can enter the REPL by simply typing loki without any follow-up flags or arguments.
The REPL has features that are intended to make your Loki experience as easy and as enjoyable as possible! This includes things like
-
Tab Autocompletion: Every command in the REPL (i.e. everything that starts with a
.) has fuzzy search auto completions.-
.<tab>to complete REPL commands -
.model <tab>to complete chat models -
.set <tab>to complete configuration keys -
.set key <tab>to complete configuration values
-
-
Multi-Line Prompts: You can also type prompts that span more than one line to help organize your thoughts. This
can be done in the following ways:
-
Ctrl-oto open the current input buffer in your preferred editor (either the value ofeditoror$EDITOR) - You can paste multi-line text
- You can type
:::to start multi-line editing, and use:::to finish it. - And finally, you can use hotkeys like
{ctrl/shift/alt}+enterorctrl-jto insert a new line directly in the REPL.
-
-
History Search Press
ctrl+rto search the REPL history, and navigate it with↑↓ -
Configurable Keybindings: You can switch between
emacsstyle keybindings orvistyle keybindings - Custom REPL Prompt: You can even customize the REPL prompt to display information about the current context in the prompt
-
Built-in user interaction tools: When function calling is enabled in the REPL, the
user__ask,user__confirm,user__input, anduser__checkboxtools are always available for interactive prompts. These are not injected in the one-shot CLI mode.
All REPL commands begin with a . to indicate that they're not part of a prompt. The following list details the
commands available in Loki:
When browsing models in the REPL, use the following legend to understand the purpose of each column in the model table:
openai:gpt-4o 128000 / 4096 | 5 / 15 👁 ⚒
| | | | | | └─ supports function calling
| | | | | └─ support vision (multi-modal)
| | | | └─ output price ($/1M)
| | | └─ input price ($/1M)
| | |
| | └─ max output tokens
| └─ max input tokens
└─ model id

For more information about how to add models to Loki, refer to the clients documentation.
Loki offers the following commands to manage your roles:
| Command | Description |
|---|---|
.role |
Create or switch to a role |
.info role |
Show information about the active role |
.edit role |
Open the active role's configuration file in your preferred text editor |
.save role |
Save the active role and its configurations to a configuration file |
.exit role |
Exit the active role |

For more information about roles in Loki and how to build them, refer to the roles documentation.
If you need to create a temporary role that you want to discard after use, you use .prompt. .prompt-based roles
cannot be persisted to a file and saved.

Use the following commands to manage sessions in Loki:
| Command | Description |
|---|---|
.session |
Start or switch to a session |
.empty session |
Clear all messages for the active session |
.compress session |
Compress the session messages using the summarization_prompt setting in the global config |
.info session |
Display information about the active session |
.edit session |
Open the active session's configuration in your preferred text editor |
.save session |
Save the active session to a session configuration file |
.exit session |
Exit the active session |

For more information on sessions and how to use them in Loki, refer to the sessions documentation.
Loki lets you build OpenAI GPT-style agents. The following commands let you interact with and manage your agents in Loki:
| Command | Description |
|---|---|
.agent |
Use an agent |
.starter |
Display and use conversation starters for the active agent |
.edit agent-config |
Open the agent configuration in your preferred text editor |
.info agent |
Display information about the active agent |
.exit agent |
Leave the active agent |

For more information on agents in Loki and how to create them, refer to the agents documentation.
Clears the todo list and stops auto-continuation. This command is available in any context (agents, sessions,
roles, or bare mode) as long as auto_continue is enabled.
This is useful when:
- You gave a custom response that changes or cancels the current task
- The model is stuck in auto-continuation with stale todos
- You want to start fresh
For more information, see the Todo System documentation.
RAG (Retrieval Augmented Generation) enables you to load documents into the LLM so you can ask questions about it or complete tasks using the documents as additional context.
| Command | Description |
|---|---|
.rag |
Initialize or access a RAG |
.edit rag-docs |
Add or remove documents from the active RAG using your preferred text editor |
.rebuild rag |
Rebuild the active RAG to accommodate document changes |
.sources rag |
Show a works-cited of the sources used in the last query |
.info rag |
Display information about the active RAG |
.exit rag |
Exit the active RAG |

For more information about RAG in Loki and how to utilize it, refer to the rag documentation.
Macros in Loki are like "scripts" of commands that can be run in isolated environments; that means they do not use any
active settings and use the same settings they had when written. They are created/executed using the .macro <name>
command.

For more information on macros in Loki and how to create them, refer to the macros documentation.
Loki lets you specify any number of documents that you can load and use as ephemeral RAG to chat with the LLM. To see
what files or values you can pass to it, simply run the command .file with no arguments:
openai:gpt-4o)> .file
Usage: .file <file|dir|url|%%|cmd>... [-- <text>...]
For more information about ephemeral RAG, refer to the ephemeral RAG documentation.
The Loki vault lets users store sensitive secrets and credentials securely so that there's no plaintext secrets anywhere in your configurations.

For more information about the Loki vault, refer to the vault documentation.
When you have a response that exceeds the context length, you can use the .continue command to continue the generation
of the last response.

If ever your response is interrupted, or you want to try generating it again, you can use the .regenerate command to do
this without having to retype your query:

If you're trying to copy the last response (like copying some code), you can use the .copy command to copy the entire
last response to your system clipboard:

You can use .set to adjust select settings at runtime. This is useful when you're experimenting with settings and want
to know how they'll affect Loki. To persist the changes you make, be sure to update them in the global configuration
file.
The following settings can be adjusted at runtime:
| Setting | Type | Description |
|---|---|---|
auto_continue |
boolean | Enable/disable the Todo System auto-continuation |
max_auto_continues |
integer | Maximum number of automatic continuations |
inject_todo_instructions |
boolean | Inject default todo instructions into the system prompt |
continuation_prompt |
string | Custom continuation prompt (supports multi-word values; null to reset) |
temperature |
float | Model temperature parameter |
top_p |
float | Model top-p parameter |
enabled_tools |
string | Comma-separated list of enabled tools |
enabled_mcp_servers |
string | Comma-separated list of enabled MCP servers |
save_session |
boolean | Whether to auto-save sessions |
compression_threshold |
integer | Token threshold for session compression |
max_output_tokens |
integer | Maximum output tokens for the current model |
dry_run |
boolean | Enable/disable dry run mode |
function_calling_support |
boolean | Enable/disable function calling |
mcp_server_support |
boolean | Enable/disable MCP server support |
stream |
boolean | Enable/disable streaming |
save |
boolean | Enable/disable saving responses |
highlight |
boolean | Enable/disable syntax highlighting |

The .edit command lets you modify configuration files for the current mode of the REPL. It will open the selected
configuration in your preferred text editor. It lets you modify the following configurations:
-
.edit config- Modify the global configuration -
.edit role- Modify the active role's configuration -
.edit session- Modify the active session's configuration -
.edit agent-config- Modify the active agent's configuration -
.edit rag-docs- Add or remove documents from the active RAG
The .delete command allows you to delete entities in Loki without having to directly run rm -rf on the configuration
directory or file corresponding to the target entity. You can use it to delete the following entities:
-
.delete role- Delete select roles -
.delete session- Delete select sessions -
.delete macro- Delete select macros -
.delete rag- Delete select RAGs -
.delete agent-data- Delete select agent's configurations and all tools
Loki's built-in agents, macros, and tool functions (and an MCP config template) are written to your configuration
directory on first run and are not overwritten afterward, so your local edits survive Loki updates. The .install
command force-overwrites a category of bundled assets with the versions packaged in the current Loki build. This is useful
when an update ships improved built-ins you want to adopt.
| Command | Description |
|---|---|
.install agents |
Reinstall the built-in agents |
.install macros |
Reinstall the built-in macros |
.install functions |
Reinstall the built-in tool functions (leaves your mcp.json alone) |
.install mcp_config |
Replace mcp.json with the bundled template (see warning below) |
The same operation is available from the command line: loki --install <category> (e.g. loki --install agents).
.install prompts for confirmation before overwriting anything. Assets you created yourself are never touched. Only
Loki's own bundled assets are replaced.
Warning: .install mcp_config is destructive in a way the others are not. It replaces your entire mcp.json
(your configured MCP servers and any secret references in them) with Loki's bundled template. The other categories
only overwrite Loki's built-in assets and leave your custom ones alone.
The .info command provides useful information about different modes that Loki may be operating in. It's helpful if you
want a quick understanding of the system info, a role's configuration, an agent's configuration, etc.
The following entities are supported:
| Command | Description |
|---|---|
.info |
Display system information (identical to the --info flag) |
.info role |
Display information about the active role |
.info session |
Display information about the active session |
.info agent |
Display information about the active agent |
.info rag |
Display information about the active RAG |
The .authenticate command will start the OAuth flow for the current model client if
- The client supports OAuth (See the clients documentation for supported clients)
- The client is configured in your Loki configuration to use OAuth via the
auth: oauthproperty
The .exit command is used to move between modes in the Loki REPL.
| Command | Description |
|---|---|
.exit role |
Exit the active role |
.exit session |
Exit the active session |
.exit agent |
Exit the active agent |
.exit rag |
Exit the active RAG |
.exit |
Exit the Loki REPL |
Just like with any shell or REPL, you sometimes need a little help and want to know what commands are available to you.
That's when you use the .help command.