Troubleshooting¶
Common problems and their solutions.
API key errors¶
AuthenticationError / 401 Unauthorized¶
The API key for the selected provider is missing or invalid.
Check your .env file:
# .env — must be in the directory where you run the script
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GROQ_API_KEY=gsk_...
Verify the key is being loaded:
import os
from dotenv import load_dotenv
load_dotenv()
print(os.getenv("OPENAI_API_KEY")) # should print your key, not None
Pass the key directly (as a fallback):
Session already ended¶
ValueError: Session already has ended. Delete old files to run.¶
This means a previous run completed successfully and left an END marker in the
tunnel log. Re-running is blocked to prevent accidental data overwriting.
To start a fresh run, delete the project data:
import shutil
from pathlib import Path
# Delete only the tunnel log (keeps raw data)
tunnel = Path("results/my_project/my_task/openai_gpt-4o-mini_SingleTurn/my_project-tunnel.json")
tunnel.unlink(missing_ok=True)
# — or delete the entire run directory —
shutil.rmtree("results/my_project")
If you don't need checkpointing, set tunnel_status="0" to disable it.
Parser / structured output errors¶
ValidationError or garbled responses¶
The model's output did not match the expected schema.
Try parser_raw=True to see the raw response:
Try json_mode or function_calling if json_schema fails:
card.parser_config = {"method": "function_calling"}
# or
card.parser_config = {"method": "json_mode"}
Use temperature=0 for more reliable structured output:
Task JSON errors¶
KeyError on contexts_id¶
The contexts_id values in your task JSON must match the keys in items exactly.
// WRONG — mismatch
"contexts_id": ["E", "T"],
"items": { "encode": [...], "test": [...] }
// CORRECT
"contexts_id": ["encode", "test"],
"items": { "encode": [...], "test": [...] }
ValueError: trcode must be unique¶
Each trial needs a unique trcode across the entire task (not just within a context).
Memory / context errors¶
Responses seem unaware of previous trials¶
Check that memory is set to "Convo" for multi-phase tasks:
Context window overflow in long Convo runs¶
Use memory_k to limit conversation length:
Or use summary_k to compress old messages:
Ollama errors¶
ConnectError / Connection refused¶
Ollama is not running. Start it with:
For a remote Ollama server, pass the base URL:
Model not found¶
Pull the model first:
Then confirm it's available:
Slow runs / timeouts¶
HPC wall-time exceeded¶
Enable checkpointing so the run resumes where it left off:
Re-submit the same script — completed participants are automatically skipped.
Mock model for fast testing¶
Use the built-in mock provider to test your pipeline without API calls:
Import errors¶
ModuleNotFoundError: No module named 'psychscanner'¶
Activate the uv environment before running:
Or reinstall:
Getting help¶
- Open an issue at github.com/saurabhr/psychscanner/issues
- Check the Configuration Reference for valid parameter values
- Run notebooks in
examples/to see working code