By default, Clanka operates as a task-completion agent: it keeps running until the agent callsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Effectful-Tech/clanka/llms.txt
Use this file to discover all available pages before exploring further.
taskComplete with a final summary. Conversation mode changes that behaviour so the agent exits a turn as soon as it produces a reply that contains no tool calls. This makes it natural to build interactive REPLs and chat-style interfaces where the user sends messages and reads responses in a loop.
Task mode vs conversation mode
| Task mode (default) | Conversation mode | |
|---|---|---|
| Turn ends when | Agent calls taskComplete | Agent replies with no tool calls |
| System prompt | Includes taskComplete instructions | Omits taskComplete instructions |
| Use case | Autonomous coding tasks | Interactive chat / REPL |
taskComplete instruction is removed from the system prompt, so the agent is not prompted to call it. The turn ends naturally as soon as the model produces a text reply without invoking any tools.
Enabling conversation mode
ProvideAgent.ConversationMode.layer(true) anywhere in your Effect layer stack.
ConversationMode is a Context.Reference with a default value of false, so omitting the layer is equivalent to Agent.ConversationMode.layer(false).
Building an interactive REPL
The CLI built into Clanka usesAgent.ConversationMode together with Prompt.text to create a simple read-eval-print loop. Here is the pattern drawn directly from src/cli.ts:
- Reads a line of input from the terminal.
- Sends the prompt to the agent with
agent.send. - Streams formatted output to stdout until the turn ends.
- Returns control to the loop so the user can type the next message.
Maintaining history across turns
Agent exposes a history field typed as MutableRef.MutableRef<Prompt.Prompt>. It accumulates the full conversation — both user messages and assistant responses — across every agent.send call.
Clearing history resets the conversation context completely. The agent will
not remember anything from previous turns after a reset.
Steering the agent mid-turn
agent.steer(message) injects a user message into an ongoing turn without waiting for the current response to finish. This is useful for providing feedback or corrections while the agent is still thinking.
steer effect completes once the message has been accepted. Interrupting the effect withdraws the message before it is delivered.
Choosing the right mode
When to use conversation mode
When to use conversation mode
- Building a terminal REPL or chat interface
- When users ask short questions and expect immediate replies
- When you want natural back-and-forth without requiring
taskComplete - When prompts in the CLI are provided interactively (
Option.isNone(prompt)incli.ts)
When to use task mode (default)
When to use task mode (default)
- Running autonomous coding tasks (
examples/cli.tspasses a prompt via argv) - When the agent needs to complete multi-step work before surfacing a result
- When you want a definitive final summary returned via
taskComplete
Wiring conversation mode in the CLI
The Clanka CLI enables conversation mode only when no--prompt flag is provided, so non-interactive invocations still run in task mode: