multi-turn

multi-turn is an agent for coding agents from cubeplexai/cubepi. It costs 17 tokens per session (1,353 once invoked), scanned A, original, MIT.

A guide for building conversational agents that remember earlier messages across multiple rounds. CubePi is the agent framework described here, and a turn means one cycle of user input, model replies, and possible tool results.

In plain words
What is it for?
Use it to build agents that answer follow-up questions, remember earlier context, or accept corrections during an active response.
Why use it?
It explains how to preserve conversation history and handle changes while the agent is still responding.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/cubeplexai/cubepi/multi-turn
Clone the repo
git clone --depth 1 https://github.com/cubeplexai/cubepi

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for multi-turn

README.md
[![agentmods](https://agentmods.dev/badge/agents/cubeplexai/cubepi/multi-turn.svg)](https://agentmods.dev/agents/cubeplexai/cubepi/multi-turn)
Your own site
<a href="https://agentmods.dev/agents/cubeplexai/cubepi/multi-turn"><img src="https://agentmods.dev/badge/agents/cubeplexai/cubepi/multi-turn.svg" alt="Measured on agentmods" height="20"></a>
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,353 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00017 $0.01353
Opus 5 $0.00009 $0.00677
Sonnet 5 $0.00003 $0.00271
Haiku 4.5 $0.00002 $0.00135

Measured 5d ago against content hash 08e74d132041, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

multi-turn scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

website/docs/guides/agents/multi-turn.md · 164 lines

How it starts

The opening of the file, as written. The whole thing — 164 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Multi-turn Conversations

A "turn" in CubePi is one round of: user input → model response (and maybe tools) → optional more model responses to tool results. The agent's _messages list grows across turns; this guide covers how to drive multi-turn flows correctly and how to inject input while the agent is mid-thought.

The basic pattern

Just call prompt again after the previous call returns:

await agent.prompt("Hi, my name is Sam.")
await agent.prompt("What's my name?")
# → "Your name is Sam."

History lives on agent.state.messages. CubePi appends each user message, each assistant message, and each tool result. The provider gets the full list every time, so context windows matter (see Context Management below).

In-flight steering: agent.steer()

Sometimes the user has a correction or extra context while the model is still mid-turn. Use steer():

import asyncio

async def main():
    task = asyncio.create_task(agent.prompt("Plan a 5-day trip to Kyoto."))
    await asyncio.sleep(2)
    # User changed their mind:
    agent.steer(UserMessage(content=[TextContent(text="Make it 3 days, not 5.")]))
    await task

A steering message is enqueued; the loop picks it up between turns (in practice, between a tool batch and the next model call). The agent sees it before its next response — it's not lost.

steering_mode on Agent controls drain behaviour:

  • "one-at-a-time" (default) — one queued message per pickup point.
  • "all" — every queued message is drained at once.

Queued follow-ups: agent.follow_up()

follow_up is for "after the current run, start a new turn with this." It's the typical pattern for a chat UI: the user types while the assistant is still responding.

agent.follow_up(UserMessage(content=[TextContent(text="And what about Osaka?")]))
# When the current prompt() finishes, the loop picks this up
# automatically and starts a new turn.

If the agent is idle when you call follow_up, you still need to trigger a run — most apps call await agent.resume() once prompt() returns, to drain the queue.

Read the full file on GitHub · 164 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 164 lines · 17 tokens per session scan A 08e74d132041

Subscribe to this mod's changes

multi-turn is an agent published in the GitHub repository cubeplexai/cubepi (46 stars, last pushed 3d ago), licensed MIT. It adds 17 tokens to every session and 1,353 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.