Skip to content

Conversation

mattgodbolt
Copy link
Member

Summary

Adds haiku explanation type and flexible prompt composition system that allows explanation types to override audience-specific guidance.

Changes Made

Core Implementation

  • Added ExplanationType.HAIKU enum value
  • Implemented explanation-type audience overrides in prompt system
  • Created haiku-specific prompt configuration that bypasses assembly guidance

Testing & Evaluation

  • Added prompt_testing/test_cases/haiku_tests.yaml with test scenarios
  • Enhanced claude_reviewer.py with haiku-specific evaluation criteria
  • Updated prompt_advisor.py to handle nested audience configurations

Code Quality & Reuse

  • Added structure-aware class methods to Prompt class:
    • get_audience_metadata_from_dict() - Works with raw prompt dictionaries
    • has_audience_override() - Checks for explanation-specific overrides
    • get_all_audience_locations() - Finds all audience guidance locations
  • Prevents duplication between runtime and testing framework

Debug Support

  • Added configurable logging via LOG_LEVEL environment variable
  • Debug logging shows actual prompts sent to Claude

Documentation

  • Updated claude_explain.md with flexible prompt system documentation

Test Plan

  • All existing tests pass
  • Haiku test cases added covering simple to complex algorithms
  • Prompt testing framework handles new structure
  • Debug logging works for both assembly and haiku modes

mattgodbolt and others added 3 commits August 23, 2025 18:36
…mpt composition

- Add haiku-specific test cases covering simple to complex algorithms
- Implement structure-aware methods in Prompt class for better code reuse
- Update prompt_advisor.py to handle nested audience_levels in explanation types
- Add haiku-specific evaluation criteria in claude_reviewer.py
- Update documentation to explain flexible prompt composition system
- Support explanation-type overrides for audience guidance (enables haiku to bypass assembly-specific instructions)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove duplication between get_audience_metadata methods - implement instance method in terms of class method
- Remove overly complex get_all_audience_locations method, add comment about future needs
- Remove hardcoded haiku-specific evaluation criteria - use same criteria for all explanation types
- Remove magic string detection for haiku targeting - explanation types should be explicitly specified
- Simplify prompt_advisor.py to directly check both audience locations without complex abstractions
- Fix test to check audience information in user prompt where it actually appears
- Use .values() instead of .items() when we don't need the keys

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@mattgodbolt mattgodbolt requested a review from Copilot August 24, 2025 14:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a haiku explanation type to the Claude assembly explanation service with a flexible prompt composition system that allows explanation types to override audience-specific guidance. This enables poetic explanations that bypass technical assembly guidance while maintaining audience differentiation for assembly explanations.

  • Added ExplanationType.HAIKU enum value and haiku-specific prompt configuration
  • Implemented explanation-type audience overrides in prompt system with structure-aware class methods
  • Enhanced testing framework with haiku test cases and Claude evaluation criteria

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
prompt_testing/test_cases/haiku_tests.yaml Comprehensive haiku test cases covering various algorithm complexities
prompt_testing/evaluation/prompt_advisor.py Enhanced to handle nested explanation-specific audience configurations
prompt_testing/evaluation/claude_reviewer.py Added haiku-specific evaluation criteria
claude_explain.md Updated documentation with flexible prompt system details
app/test_explain.py Fixed test to check audience guidance in user message instead of system prompt
app/prompt.yaml Added haiku configuration with audience overrides and restructured prompts
app/prompt.py Added structure-aware class methods for prompt composition
app/main.py Added configurable logging via LOG_LEVEL environment variable
app/explanation_types.py Added HAIKU enum value
app/explain.py Added debug logging for actual prompts sent to Claude
app/config.py Added log_level configuration setting

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

- Replace module-level resource initialization with lifespan context manager
- Create configure_logging() function for proper logging setup
- Move shared resources (anthropic_client, prompt, settings) to app.state
- Update endpoints to access resources from app.state via Request object
- Eliminate multiple get_settings() calls at module import time
- Use proper FastAPI 2024 best practices for resource management
- Maintain backward compatibility and all tests pass

This fixes the issue where settings were locked at import time and makes
testing much easier since settings can now be mocked before app creation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@mattgodbolt mattgodbolt requested a review from Copilot August 24, 2025 15:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mattgodbolt mattgodbolt merged commit 8134808 into main Aug 24, 2025
2 checks passed
@mattgodbolt mattgodbolt deleted the mg/haiku branch August 24, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant