honcho/tests/bench
doria f988aae996
create Representation class and use it to unify all formatting (#214)
* feat: add optional JWT and webhook secrets to honcho instance creation

* chore: ignore spurious warnings

* feat: add response format if using gpt-5 model family

* feat: add response models to all apis except anthropic

* fix: raise NotImplementedError for response models in AsyncAnthropic client

* chore: address review

* [WIP] representation structure + deriver cleanup

* chore: add tests, cleanup

* feat: [WIP: semi-working] representation object

* fix: alignment

* fix: make observations hashable for dedup

* fix: datetime formatting, observation counting

* fix: switch to int for message id, clean up representation

* feat: remove need for metadata working rep

* chore: cleanup

* fix: use tenacity instead of custom fns

* feat: add representation and card to context if desired

* feat: add semantically relevant observations

* fix: pass all params to streaming, nonblocking streaming

* feat: consolidate document saving, make working representation fetching much smarter

* chore: add 100% test coverage of representation util

* feat: basic dream infra

* feat: dream queue item first pass

* chore: fixes & cleanup from coderabbit

* fix: dreams scheduled when new document count reaches a certain threshold

* feat: wip: timed dreams (not working)

* fix: test

* fix: remove useless pyright ignore

* fix: executing dreams

* feat: dreaming

* feat: [WIP] longmemeval bench

* feat: add USE_PEER_CARD setting, fix longmem test driver

* feat: get full working rep for dialectic in one swoop -- fix representation_from_documents to use the proper timestamp!

* fix: timestamps for real, handle assistant qs in longmem

* fix: remove old client, add batching to longmem

* perf: remove duplicate detection, will move to background task

* feat: track perf metrics on evals

* feat: adjust deriver prompt to use peer_id, add question date to question, clean up deriver

* fix: label metrics by task for better perf trace

* chore: code review

* feat: add efficiency score to longmem bench

* chore: tuning and cleaning up eval

* chore: bring in the big prompts

* feat: add support for vllm client

* feat: perf: bundle db calls in deriver and dialectic, increase max conns in docker db

* feat: add merge-sessions flag to longmemeval, add SUMMARY_ENABLED flag

* fix: COLLECT_METRICS default false

* chore: display start/end message ids, don't include in metrics

* fix: break large messages apart for eval

* fix: only get/create collection when needed

* feat: properly attribute documents with message id ranges and add session name column to documents

* fix: revert move of get_or_create_collection (need for fkey)

* fix: always get collection with peer name even if it's none

* chore: coderabbit

* fix: give peer card its own config, expand document schema, refactor get_context to be parallel, various cleanup chores and bugfixes

* chore: refactor: reify observer/observed system across entire codebase, including db migration

* refactor: cleanup code organization, make singletons where desired

* refactor: replace embeddings store with representation manager

* chore: coderabbit cleanup

* chore: update migration to non-null session param in documents, general review and cleanup

* chore: merge branch 'main' into ben/deriver-tidy

* chore: review fixes
2025-10-07 15:28:44 -04:00
..
peer_card_tests Peer Cards (#180) 2025-08-12 17:39:08 -04:00
tests Peer Cards (#180) 2025-08-12 17:39:08 -04:00
.gitignore create Representation class and use it to unify all formatting (#214) 2025-10-07 15:28:44 -04:00
README.md Peer Cards (#180) 2025-08-12 17:39:08 -04:00
harness.py SDK Changes (#223) 2025-10-01 16:25:30 -04:00
longmem.py create Representation class and use it to unify all formatting (#214) 2025-10-07 15:28:44 -04:00
peer_card_bench.py create Representation class and use it to unify all formatting (#214) 2025-10-07 15:28:44 -04:00
run_tests.py create Representation class and use it to unify all formatting (#214) 2025-10-07 15:28:44 -04:00

README.md

Honcho Development Harness

This directory contains a development harness script that makes it easy to run Honcho locally with a Docker database.

Overview

The harness.py script orchestrates the complete Honcho development environment:

  1. Database Setup: Starts a PostgreSQL database in Docker with a configurable port
  2. Database Provisioning: Runs Alembic migrations to set up the database schema
  3. Configuration: Uses environment variables to configure Honcho's database connection
  4. Service Startup: Starts both the FastAPI server and deriver process
  5. Configuration Verification: Prints the actual configuration that Honcho is using
  6. Monitoring: Provides real-time logs from all services
  7. Cleanup: Gracefully shuts down all services when stopped

Prerequisites

  • Python 3.11+
  • Docker and Docker Compose
  • Honcho project dependencies installed (uv sync)

Usage

Basic Usage

Run the harness with default settings (database on port 5433):

python tests/bench/harness.py

Custom Database Port

Run with a custom database port:

python tests/bench/harness.py --port 5434

Custom Project Root

If running from a different directory:

python tests/bench/harness.py --project-root /path/to/honcho

Command Line Options

  • --port: Port for the PostgreSQL database (default: 5433)
  • --project-root: Path to the Honcho project root (default: current directory)

What Gets Started

When you run the harness, it will start:

  1. PostgreSQL Database: Running in Docker on the specified port
  2. FastAPI Server: Available at http://localhost:8000
  3. API Documentation: Available at http://localhost:8000/docs
  4. Deriver Process: Background worker for processing messages

Configuration

The harness uses environment variables to configure Honcho's database connection:

  • DB_CONNECTION_URI: Set to postgresql+psycopg://testuser:testpwd@localhost:{port}/honcho

The script will print the actual configuration that Honcho is using after the FastAPI server starts. This gives you complete visibility into how Honcho's configuration system resolved the settings from environment variables, config files, and defaults.

Stopping the Services

Press Ctrl+C to gracefully stop all services. The harness will:

  1. Stop the FastAPI server and deriver processes
  2. Stop the Docker database container
  3. Clean up temporary files (Docker Compose configuration)

Troubleshooting

Database Connection Issues

If the database fails to start or connect:

  1. Check if port 5433 (or your custom port) is already in use
  2. Ensure Docker is running
  3. Try a different port: --port 5434

Configuration Issues

The script will print the actual configuration being used. If you see unexpected values:

  1. Check if you have a config.toml file that might be overriding environment variables
  2. Verify that the environment variables are being set correctly
  3. Check the Honcho configuration documentation for precedence rules

Integration with CI/CD

This harness can be used in CI/CD pipelines for integration testing. The script will:

  • Use temporary directories for isolation
  • Clean up all resources on exit
  • Provide clear error messages for debugging
  • Exit with appropriate status codes
  • Use environment variables for configuration (no file conflicts)

Test Runner

The run_tests.py script executes JSON-formatted tests against a running Honcho instance. The harness must be running.

Running Tests

  1. Start Honcho using the harness:

    python tests/bench/harness.py
    
  2. In another terminal, run the tests:

    # Run all tests
    python tests/bench/run_tests.py
    
    # Run a specific test
    # Test judge uses claude 3.5 sonnet
    python tests/bench/run_tests.py --test 1.json
    

Test Workflow

For each test, the runner:

  1. Creates a workspace for the test
  2. Adds all messages from the JSON to sessions
  3. Waits for deriver queue to be empty
  4. Executes queries as .chat() calls
  5. Judges responses using expected_response field

Test JSON Format

Tests are defined in JSON files with this structure:

{
    "sessions": {
        "session1": {
            "messages": [
                {
                    "peer": "alice",
                    "content": "Hello, how are you?"
                },
                {
                    "peer": "bob",
                    "content": "I'm good, thank you!"
                }
            ]
        }
    },
    "queries": [
        {
            "query": "How is Bob doing?",
            "expected_response": "Good",
            "session": "session1",  // optional
            "peer": "alice"         // optional
        }
    ]
}

Command Line Options

  • --tests-dir: Directory containing JSON test files (default: tests/bench/tests)
  • --test: Run a specific test file
  • --honcho-url: URL of running Honcho instance (default: http://localhost:8000)
  • --anthropic-api-key: Anthropic API key for response judging, uses LLM_ANTHROPIC_API_KEY if not given
  • --timeout: Timeout for deriver queue to empty (default: 60 seconds)