-
Notifications
You must be signed in to change notification settings - Fork 5
EN Course 00 Overview
This course explains bash-agent by rebuilding its architecture from a small Bash agent loop. The goal is not to teach every line of agent.sh at once. Each chapter adds one runtime capability and connects it back to the implementation.
After finishing the course, you should be able to:
- explain the end-to-end runtime path from user input to assistant output
- map major runtime responsibilities to
agent.shsections - reason about long-session compaction as a cache-and-cost decision
- understand tool dispatch boundaries, permission checks, and failure handling
- use plan/todo/sub-agent mechanisms with correct lifecycle ordering
- evaluate runtime parity requirements across Bash, C, Go, and Rust
-
Minimal Agent Loop
Accept user input, build a request, call the model, and print assistant text. -
Streaming Transport
Read provider SSE streams and normalize text, thinking, usage, tool calls, and stop reasons. -
Message Protocol and Display
Separate internal events from human rendering andstream-jsonoutput. -
Session Store
Persist conversation, events, stats, plans, and summaries as durable session state. -
System Prompt Builder
Compose instructions, skills, plans, summaries, environment metadata, and tool guidance. -
Compaction and Long Sessions
Keep long sessions usable with cache-aligned summarization and dynamic compaction decisions. -
Tool Calling
Convert model tool requests into dispatcher calls and persist tool results. -
Bash Tool Permission Mode
Classify shell commands withsystem/external/network/workspacescopes andread/write/executebits. -
Plan and Todo Workflow
Separate draft plans, locked plans, and progress tracking so planning does not constantly invalidate the prompt cache. -
Sub-Agent Runtime
Treat sub-agents as restricted child runtime instances that run the same agent loop and report results asynchronously. -
Runtime Parity
Keep Bash, C, Go, and Rust implementations aligned at the behavioral boundary.
Use this as a lightweight self-check after each chapter:
- Chapter 01: can describe one full request/response loop
- Chapter 02: can explain streamed event normalization
- Chapter 03: can distinguish protocol events from display rendering
- Chapter 04: can name persisted session artifacts and why they matter
- Chapter 05: can explain prompt section composition and ordering
- Chapter 06: can explain when and why compaction should happen
- Chapter 07: can trace model tool calls to runtime execution and persisted results
- Chapter 08: can reason about permission classification outcomes
- Chapter 09: can apply draft/confirm/execute/clear lifecycle correctly
- Chapter 10: can explain async child result injection and parent follow-up turn
- Chapter 11: can articulate parity boundaries across runtimes
If you can complete these checks, you can read and modify the runtime with predictable behavior impact.
The Bash runtime is the reference implementation. Its major sections map directly to the course:
agent.sh Section |
Course Area |
|---|---|
util_* |
message framing, escaping, prompt sections |
store_* |
sessions, events, stats, plans, summaries |
llm_* |
transport and provider calls |
tool_* |
tool schema, dispatch, result formatting |
display_* |
human display and stream events |
agent_* |
prompt building, loop control, compaction, sub-agents |
cli |
configuration and interactive mode |
The course introduces concepts in order. The design notes keep deeper explanations for specific subsystems:
- Cache-Aligned Summarization
- Dynamic Compaction Decision
- Bash Tool Permission Mode