Pi Agent: Interactive Mode

Last updated: 2026-08-31

Interactive mode is like chatting face-to-face with AI — ask, get answers, follow up, switch topics anytime.


1. Starting Interactive Mode

BASH
pi-agent chat

Enter the interactive REPL:

TEXT 📖 Display only
Pi Agent v0.8.0
Provider: deepseek (deepseek-chat)
Interactive mode started. Type a message to begin, /help for commands

you>

(1) Launch with Parameters

BASH
pi-agent chat --provider openai --model gpt-4o --system "You are a code review expert"

(2) Load Context from File

BASH
pi-agent chat --context ./project_context.json

2. Basic Operations

(1) Send Messages

Type text and press Enter:

TEXT 📖 Display only
you> Help me explain what decorators are
Decorators are a syntactic sugar in Python, using the @ symbol...

(2) Multi-line Input

Wrap content in triple quotes:

TEXT 📖 Display only
you> """
Please review the following code:
def add(a, b):
    return a + b
"""

(3) Exit

TEXT 📖 Display only
you> /exit
Goodbye!

Or press Ctrl+C / Ctrl+D.


3. Slash Commands

Interactive mode has built-in commands starting with /:

Command Description
/help Show help
/exit Exit interactive mode
/clear Clear conversation history
/model Switch model
/provider Switch provider
/tools List available tools
/use Enable a tool
/unuse Disable a tool
/skill Load a skill
/save Save conversation to file
/load Load conversation file
/context Show current context info
/history Show conversation history
/retry Regenerate last response
/edit Edit last user message

Example 1: In-Session Model Switching (Difficulty: ⭐)

TEXT 📖 Display only
you> /model deepseek-reasoner
Model switched to deepseek-reasoner

you> Prove there are infinitely many primes
[Reasoning...] Assume primes are finite, let the largest be p...

you> /model deepseek-chat
Model switched to deepseek-chat

you> Say it simply
Simply put, primes are infinite...

4. Tool Interaction

Dynamically enable/disable tools in interactive mode:

TEXT 📖 Display only
you> /tools
Available tools:
  [ON]  calculator  - Math calculations
  [ON]  search      - Web search
  [OFF] file_reader - File reading
  [OFF] shell       - System commands

you> /use file_reader
Tool enabled: file_reader

you> /use shell
Tool enabled: shell

you> Read main.py and run it
[Calling file_reader] -> Reading main.py
[Calling shell] -> Executing python main.py
main.py output: Hello, World!

5. Conversation Management

(1) Save Conversation

TEXT 📖 Display only
you> /save chat_20260828.json
Conversation saved to chat_20260828.json

(2) Load Conversation

TEXT 📖 Display only
you> /load chat_20260828.json
Loaded conversation (8 messages)

you> /history
[1] user: Help me explain decorators
[2] assistant: Decorators are...
[3] user: Give an example
...

(3) Edit and Retry

TEXT 📖 Display only
you> Write a sorting algorithm
[Gave bubble sort]

you> /edit
Edit your message: Write a quicksort algorithm
[Regenerated] Quicksort's core idea is divide-and-conquer...

FAQ

Q How to input long code in interactive mode?
A Wrap in triple quotes """, or use /load to load a code file, then ask the Agent to analyze it.
Q Does /retry consume extra tokens?
A Yes. Each retry is a new API call. Previous messages remain in context.
Q Can I run multiple interactive sessions simultaneously?
A Yes. Each terminal window is an independent session.

Summary


Exercises

  1. Basic (Difficulty: ⭐): Start interactive mode, have 3 rounds of conversation, use /history to review.
  2. Intermediate (Difficulty: ⭐⭐): Switch models and tools within a session, complete a "search + calculate" combined task.
  3. Advanced (Difficulty: ⭐⭐⭐): Complete a full code review workflow: load code → review → modify → verify.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏