Wasabi is a Python-first terminal coding agent I built to understand the engineering behind agentic systems, secure agent execution, code intelligence, and efficient context management.
The project is primarily a hands-on exploration of how coding agents work internally: how an LLM reasons through multi-step tool workflows, interacts with a real repository, executes actions under controlled permissions, understands source code structurally, and remains observable and testable.
Wasabi implements advanced file mutation tools that significantly enhance the editing and writing capabilities of the agent. Here's how these features contribute to improved token usage efficiency:
-
Surgical Edits: By allowing precise modifications without reading entire files, Wasabi reduces unnecessary token usage and focuses on quality content updates.
-
Atomic Operations: Ensures that changes are applied in a single operation, preventing partial updates that could require additional tokens to correct.
-
File Integrity Checks: By validating files before mutations, Wasabi avoids staleness and ensures that edits are relevant, which maintains the quality of output without wasting tokens on invalid transformations.
-
Dynamic Context Management: This feature allows the agent to adapt content actively based on current requirements, leading to more meaningful text generation with fewer tokens.
-
Enhanced Interaction: With the capability to manage both text and structure, agents can execute complex edits that optimize content for clarity and relevance, improving the overall quality-to-token ratio.
By maintaining a high-quality output while minimizing token usage, Wasabi enhances productivity and reduces API costs associated with language model interactions.
- Completion Testing — testing the ability to replace and insert commands.
Wasabi explores:
- Agentic workflows — designing tools that an LLM can combine and reason over to complete multi-step software engineering tasks.
- Controlled agent execution — giving an agent useful filesystem, Git, dependency, search, and execution capabilities without unrestricted access to the host system.
- Agent security — project-root isolation, user permissions for sensitive operations, prompt-injection checks, execution restrictions, and protection against indirect attempts to bypass denied actions.
- Code intelligence — using Tree-sitter, AST-based code analysis, symbol indexing, dependency graphs, and LSP integration to help the agent understand code beyond raw text.
- Efficient context management — precise reads, surgical edits, persistent project context, and context compaction to reduce unnecessary token usage and API cost.
- Monitoring and evaluation — understanding how to observe agent actions, trace tool usage, evaluate task outcomes, measure failures, and test agent behavior under normal and adversarial conditions.
- Agent security research — studying vulnerabilities that real-world agentic products face, including prompt injection, tool misuse, excessive agency, indirect execution bypasses, malicious repository content, unsafe code execution, and confused-deputy-style behavior.
- lesser tokens used and more efficient and accurate editing.
- Core agent loop with OpenAI tool calling
- Tool execution layer
- System information tools
- Filesystem tools
- Project-root protection
- Soft deletion and file restoration
- Git tools
- Prompt-injection check during initialization
- User permission mechanism for destructive and sensitive operations
- System prompt security hardening
-
uvtooling- Version
- Sync
- Dependency tree
- Add packages
- Remove packages
- Run scripts
- Run modules
- Run commands
- Ripgrep-based text search
- Search with surrounding context
- File discovery
- Minimal clean TUI
- Read exact line ranges with line numbers
- Replace exact code blocks
- Replace specific line ranges
- Insert before an exact anchor
- Insert after an exact anchor
- Atomic writes
- File-hash validation for stale edits
- Tree-sitter integration
- Extract functions, classes, methods and imports
- Build a global symbol index
- Read code by symbol
- Precise symbol-level edits
- Generate persistent
WASABI.mdproject context - Keep architecture, important modules, dependencies and project decisions in context
- Update only affected sections when the project changes
- Build internal module dependency relationships
- Identify reverse dependencies and affected modules
- Implement LSP client
- Maintain persistent language-server process
- Definitions
- References
- Diagnostics
- Validation loop after edits
- Track token usage from OpenAI API responses
- Compact old context when a threshold is reached
- Preserve active task, important project context, unresolved errors and recent actions
- Create distributable Python package
- Add CLI entry point
- Final integration testing
- Final adversarial security testing
- README cleanup
