inspect-scout

0.4.25 · active · verified Thu Apr 16

inspect-scout is a Python library for transcript analysis of AI agents, providing tools to capture and analyze agent interactions. It is currently at version 0.4.25 and sees frequent updates, with the latest release on March 27, 2024.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `inspect-scout` to automatically capture transcripts of an AI agent's interactions using the `@inspect` decorator. It also shows the `transcript_session` context manager for manual tracing of code blocks and how to configure the output directory.

import inspect_scout
import os
import tempfile
import shutil

# Configure inspect-scout to save transcripts to a temporary directory
temp_dir = tempfile.mkdtemp()
inspect_scout.configure(output_dir=temp_dir, print_transcript_on_exit=False)
print(f"Transcripts will be saved to: {temp_dir}")

# Define a simple agent function
def my_agent_logic(input_text: str):
    if "hello" in input_text.lower():
        return "Hello there! How can I help you?"
    elif "tool" in input_text.lower():
        return "Simulating tool use..."
    return "I am a generic agent."

# Use the @inspect decorator to capture the agent's transcript
@inspect_scout.inspect(name="MyTestAgent")
def my_inspected_agent(input_text: str):
    print(f"Agent received: {input_text}")
    response = my_agent_logic(input_text)
    print(f"Agent responded: {response}")
    return response

if __name__ == "__main__":
    print("\n--- Running inspected agent ---")
    result1 = my_inspected_agent("Hello agent!")
    print(f"First call result: {result1}")

    result2 = my_inspected_agent("Tell me about tool use.")
    print(f"Second call result: {result2}")

    print("\n--- Running inspected block ---")
    with inspect_scout.transcript_session(name="ManualBlockSession"):
        print("Inside a manually traced block.")
        block_result = my_agent_logic("What's up?")
        print(f"Block agent result: {block_result}")

    # Clean up the temporary directory
    shutil.rmtree(temp_dir)
    print(f"\nCleaned up temporary directory: {temp_dir}")

view raw JSON →