Feature-rich interactive CLI for AI agents with token tracking, prompt templates, aliases, and configuration
Project description
Basic Agent Chat Loop
A feature-rich, interactive CLI for AI agents with token tracking, prompt templates, agent aliases, and extensive configuration options.
Features
- ๐ท๏ธ Agent Aliases - Save agents as short names (
chat_loop peteinstead of full paths) - ๐ Command History - Navigate previous queries with โโ arrows (persisted to
~/.chat_history) - โ๏ธ Multi-line Input - Type
\\to enter multi-line mode for code blocks - ๐ฐ Token Tracking - Track tokens and costs per query and session
- ๐ Prompt Templates - Reusable prompts from
~/.prompts/ - โ๏ธ Configuration - YAML-based config with per-agent overrides
- ๐ Status Bar - Real-time metrics (queries, tokens, duration)
- ๐ Session Summary - Full statistics displayed on exit
- ๐จ Rich Formatting - Enhanced markdown rendering with syntax highlighting
- ๐ Error Recovery - Automatic retry logic with exponential backoff
- ๐ Agent Metadata - Display model, tools, and capabilities
Installation
PyPI Install (Coming Soon)
pip install basic-agent-chat-loop
From Source
Recommended (editable install):
git clone <repo-url> Basic-Agent-Chat-Loop
cd Basic-Agent-Chat-Loop
pip install -e .
Windows users (for command history support):
pip install -e ".[windows]"
Development install:
pip install -e ".[dev]"
See docs/INSTALL.md for detailed installation instructions.
Quick Start
Basic Usage
# Run with agent path
chat_loop AWS_Strands/Product_Pete/agent.py
# Run with alias (after saving)
chat_loop pete
Agent Aliases
Save frequently used agents for quick access:
# Save aliases
chat_loop --save-alias pete AWS_Strands/Product_Pete/agent.py
chat_loop --save-alias clara AWS_Strands/Complex_Coding_Clara/agent.py
# Use aliases from anywhere
chat_loop pete
chat_loop clara
# List all aliases
chat_loop --list-aliases
# Remove an alias
chat_loop --remove-alias pete
Aliases are stored in ~/.chat_aliases and work from any directory.
Prompt Templates
Create reusable prompt templates:
# Create template directory
mkdir -p ~/.prompts
# Create a code review template
cat > ~/.prompts/review.md <<'EOF'
# Code review
Please review the following code for:
- Best practices and design patterns
- Potential bugs or edge cases
{input}
EOF
# Use template in chat
chat_loop pete
You: /review my_code.py
Configuration
Create a configuration file at ~/.chatrc:
cp .chatrc.example ~/.chatrc
Example configuration:
features:
show_tokens: true # Display token counts
show_metadata: true # Show agent model/tools info
rich_enabled: true # Enhanced formatting
ui:
show_status_bar: true # Top status bar
show_duration: true # Query duration
behavior:
max_retries: 3 # Retry attempts on failure
timeout: 120.0 # Request timeout (seconds)
# Per-agent overrides
agents:
'Product Pete':
features:
show_tokens: false
See CONFIG.md for full configuration options.
Commands
| Command | Description |
|---|---|
help |
Show help message |
info |
Show agent details (model, tools) |
templates |
List available prompt templates |
/name |
Use prompt template from ~/.prompts/name.md |
clear |
Clear screen and reset agent session |
exit, quit |
Exit chat (shows session summary) |
Multi-line Input
Press \\ to enter multi-line mode:
You: \\
... def factorial(n):
... if n <= 1:
... return 1
... return n * factorial(n - 1)
...
[Press Enter on empty line to submit]
Token Tracking
During Chat
When show_tokens: true in config:
------------------------------------------------------------
Time: 6.3s โ 1 cycle โ Tokens: 4.6K (in: 4.4K, out: 237) โ Cost: $0.017
Session Summary
Always shown on exit:
============================================================
Session Summary
------------------------------------------------------------
Duration: 12m 34s
Queries: 15
Tokens: 67.8K (in: 45.2K, out: 22.6K)
Total Cost: $0.475
============================================================
Programmatic Usage
from basic_agent_chat_loop import ChatLoop
# Create chat interface
chat = ChatLoop(
agent=your_agent,
name="My Agent",
description="Agent description",
config_path=Path("~/.chatrc") # Optional
)
# Run interactive loop
chat.run()
Requirements
Core Dependencies
anthropic-bedrock>=0.8.0- AWS Bedrock integrationpyyaml>=6.0.1- Configuration file parsing
Optional (Recommended)
rich>=13.7.0- Enhanced terminal renderingreadline(built-in on Unix) - Command historypyreadline3(Windows only) - Command history support
Platform Support
- โ macOS - Full support with native readline
- โ Linux - Full support with native readline
- โ
Windows - Full support (install via
install.batorinstall.py)
Architecture
src/basic_agent_chat_loop/
โโโ chat_loop.py # Main orchestration
โโโ chat_config.py # Configuration management
โโโ cli.py # CLI entry point
โโโ components/ # Modular components
โ โโโ ui_components.py # Colors, StatusBar
โ โโโ token_tracker.py # Token/cost tracking
โ โโโ template_manager.py # Prompt templates
โ โโโ display_manager.py # Display formatting
โ โโโ agent_loader.py # Agent loading
โ โโโ alias_manager.py # Alias management
docs/
โโโ ALIASES.md # Alias system guide
โโโ CONFIG.md # Configuration reference
โโโ INSTALL.md # Installation instructions
โโโ Chat_TODO.md # Roadmap and future features
Documentation
- docs/ALIASES.md - Agent alias system guide
- docs/CONFIG.md - Configuration reference
- docs/INSTALL.md - Installation instructions
- docs/Chat_TODO.md - Roadmap and future features
Development
Running Tests
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
Code Quality
# Format code
black src/ tests/
# Lint
ruff check src/ tests/
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Changelog
v1.0.0 (2025-10-08)
- โจ Initial release
- ๐ท๏ธ Agent alias system
- ๐ Prompt templates
- ๐ฐ Token tracking and cost estimation
- โ๏ธ YAML configuration with per-agent overrides
- ๐ Status bar and session summaries
- ๐จ Rich markdown rendering
- ๐ Automatic error recovery
- ๐ Persistent command history
- ๐ Cross-platform installers (macOS, Linux, Windows)
Support
For issues, questions, or contributions, please visit the repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file basic_agent_chat_loop-0.1.0.tar.gz.
File metadata
- Download URL: basic_agent_chat_loop-0.1.0.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd19f9788b0f751e6c81e6c51c24e52fdcb1c70b4061bd91caf016b989ea638b
|
|
| MD5 |
21b8f08bcbbbbf6ff285c0342110a378
|
|
| BLAKE2b-256 |
d591ba61360873be3f74edf1e7a386dc7daed823cd33c4f6716a6edc202231db
|
Provenance
The following attestation bundles were made for basic_agent_chat_loop-0.1.0.tar.gz:
Publisher:
publish.yml on Open-Agent-Tools/Basic-Agent-Chat-Loop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
basic_agent_chat_loop-0.1.0.tar.gz -
Subject digest:
dd19f9788b0f751e6c81e6c51c24e52fdcb1c70b4061bd91caf016b989ea638b - Sigstore transparency entry: 597673078
- Sigstore integration time:
-
Permalink:
Open-Agent-Tools/Basic-Agent-Chat-Loop@5bcbf5623b9a29b0046a4ebba098e299850be3dc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Open-Agent-Tools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5bcbf5623b9a29b0046a4ebba098e299850be3dc -
Trigger Event:
release
-
Statement type:
File details
Details for the file basic_agent_chat_loop-0.1.0-py3-none-any.whl.
File metadata
- Download URL: basic_agent_chat_loop-0.1.0-py3-none-any.whl
- Upload date:
- Size: 33.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7cc63e8e831ffd7beac493dd83d32e059b8e8aa824f3247f3d63caf63760768
|
|
| MD5 |
c3945315065a4ddb2a3b41925c8b6ae6
|
|
| BLAKE2b-256 |
bf18ad5b4c0a49be9d61268a5dc05955135981c214f3c7a583bb30bd4157a896
|
Provenance
The following attestation bundles were made for basic_agent_chat_loop-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Open-Agent-Tools/Basic-Agent-Chat-Loop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
basic_agent_chat_loop-0.1.0-py3-none-any.whl -
Subject digest:
b7cc63e8e831ffd7beac493dd83d32e059b8e8aa824f3247f3d63caf63760768 - Sigstore transparency entry: 597673084
- Sigstore integration time:
-
Permalink:
Open-Agent-Tools/Basic-Agent-Chat-Loop@5bcbf5623b9a29b0046a4ebba098e299850be3dc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Open-Agent-Tools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5bcbf5623b9a29b0046a4ebba098e299850be3dc -
Trigger Event:
release
-
Statement type: