# Specification: API Usage Audit and Alignment

## Overview
This track involves a comprehensive audit of the "Manual Slop" codebase to ensure that the integration with Google Gemini (`google-genai`) and Anthropic Claude (`anthropic`) SDKs aligns perfectly with their latest official documentation and best practices. The goal is to identify discrepancies, performance bottlenecks, or deprecated patterns and implement the necessary fixes.

## Scope
- **Target:** Full codebase audit, with primary focus on `ai_client.py`, `mcp_client.py`, and any other modules interacting with AI SDKs.
- **Key Areas:**
    - **Caching Mechanisms:** Verify Gemini context caching and Anthropic prompt caching implementation.
    - **Tool Calling:** Audit function declarations, parameter schemas, and result handling.
    - **History & Tokens:** Review message history management, token estimation accuracy, and context window handling.

## Functional Requirements
1. **SDK Audit:** Compare existing code patterns against the latest official Python SDK documentation for Gemini and Anthropic.
2. **Feature Validation:**
    - Ensure `google-genai` usage follows the latest `Client` and `types` patterns.
    - Ensure `anthropic` usage utilizes `cache_control` correctly for optimal performance.
3. **Discrepancy Remediation:** Implement code changes to align the implementation with documented standards.
4. **Validation:** Execute tests to ensure that API interactions remain functional and improved.

## Acceptance Criteria
- Full audit completed for all AI SDK interactions.
- Identified discrepancies are documented and fixed.
- Caching, tool calling, and history management logic are verified against latest SDK standards.
- All existing and new tests pass successfully.

## Out of Scope
- Adding support for new AI providers not already in the project.
- Major UI refactoring unless directly required by API changes.
