Topic

Pi coding agent

All digests tagged Pi coding agent

Prompt Caching Explained: Stop Overpaying for AI Agents thumbnail

· 17:16

Prompt Caching Explained: Stop Overpaying for AI Agents

Prompt caching is essential for managing costs in long-running AI agent sessions. Instead of paying full price for re-sending entire conversation histories (context windows) on every turn—which can lead to exponential cost increases—proper prompt caching ensures that the LLM only charges a discounted rate for tokens it has seen before. This requires designing an agent harness that correctly preserves reusable prompt prefixes and understands provider-specific API behaviors.

Key takeaways

  1. Cache Inputs, Not Outputs

    Prompt caching stores and reuses inputs (the conversation history/prompt), not the LLM's outputs. Caching outputs is generally not useful for LLMs.

  2. Cost Escalation Risk 0:23

    Without caching, sending a growing context window (e.g., 51k tokens, then 55k tokens) repeatedly leads to exponentially increasing costs, making long sessions prohibitively expensive.

  3. Cache Expiry is Critical 2:03

    The cache has an expiration time (e.g., OpenAI OAuth API: one hour; Anthropic: five minutes by default). The agent harness must account for this expiry to avoid paying full price again.

  4. System Prompts Must Be Static 8:00

    To prevent cache invalidation, do not include dynamic elements like timestamps or current working directories within the system prompt. Keep conversation history append-only.

Watch on YouTube Full article

Tau Crash Course: The Python Port of Pi thumbnail

· 25:04

Tau Crash Course: The Python Port of Pi

Tau is a Python-based coding agent harness designed as an architectural port of Pi, aimed at standardizing and enhancing reliable AI workflow development. It features a Textual TUI for interaction and maintains core functionality like session management, tool calling (read, write, edit, bash), and skill invocation. Key technical aspects include the ability to store sessions in a JSONL format for easy analysis and integration into larger build pipelines.

Key takeaways

  1. Architectural Porting

    Tau is a coding harness developed entirely in Python and functions as an architectural port of Pi, ensuring core functionality remains consistent while updating the user interface.

  2. TUI Framework

    The Terminal User Interface (TUI) for Tau is built using Textual, which results in some differences from Pi's native TUI but maintains similar command structures.

  3. Session Management and Tree Structure 13:39

    Sessions are stored as a tree structure, where every message points to its parent ID. This allows users to fork conversations or navigate history using the `/tree` command.

  4. Data Export for Analysis

    Sessions can be exported into a JSONL format (JSON Lines), making them easily parsable for external analysis, skill testing, and integration with other agents.

Watch on YouTube Full article