AbstractCore Troubleshooting Guide

Complete troubleshooting guide for AbstractCore core library and server, including common mistakes and how to avoid them.

Table of Contents

Table of Contents Agent integration failures Common Mistakes to Avoid Quick Diagnosis Installation Issues Core Library Issues Local Model Downloads Server Issues Provider-Specific Issues Performance Issues Best Practices Debug Techniques Common Error Messages Getting Help

Table of Contents


Agent integration failures

For a version/import check, explicit endpoint discovery, bounded generation and complete-result checks, use Integrating and operating AbstractCore. The portable abstractcore skill contains the same procedures.

  • Code and installed version differ: run the verification recipe in that guide and reinstall in the same Python environment; check for a source checkout shadowing another installation.
  • 401/403: stop and check the selected endpoint's credential. With server authentication, the bearer token authenticates to AbstractCore; X-AbstractCore-Provider-API-Key selects an upstream override. Do not interchange them or retry a login automatically.
  • No text or finish_reason="length": inspect tool calls and reasoning, reject cutoff output, then adjust the output budget or prompt. Never execute incomplete/unparsed tools.
  • Known issue (2.26.4), TypeError decoding a native structured response: a provider can return content=None. Catch TypeError at the extraction boundary and report failed extraction; do not substitute default field values. See the guide's typed-extraction recipe.

Common Mistakes to Avoid

Understanding common pitfalls helps prevent issues before they occur.

Top mistakes (fast fixes)

  1. Incorrect provider configuration
  2. Symptom: Authentication failures, no model response
  3. Quick Fix: Set API keys via environment variables (or persist them with abstractcore --set-api-key ...)
  4. See: Authentication Errors

  5. Not handling tool calls

  6. Symptom: Tools not executing, streaming interruptions
  7. Quick Fix: Use @tool decorator and handle tool calls properly
  8. See: Tool Calls Not Working

  9. Missing local engines or an outdated install

  10. Symptom: ModuleNotFoundError for providers
  11. Quick Fix: pip install -U abstractcore for remote providers; pip install "abstractcore[apple]" or pip install "abstractcore[gpu]" for MLX, vLLM and HuggingFace
  12. See: ModuleNotFoundError

  13. LM Studio server not enabled

  14. Symptom: Connection refused, no response from LM Studio
  15. Quick Fix: Enable "Status: Running" toggle in LM Studio GUI
  16. See: LM Studio Server Not Enabled

  17. Context length too small (LM Studio/Ollama)

  18. Symptom: 400 Bad Request, truncated responses, errors with long inputs
  19. Quick Fix: Set "Default Context Length" to "Model Maximum" in LM Studio
  20. See: Context Length Too Small

Common Mistake Patterns

Mistake: Missing or Incorrect API Keys

You'll See: - ProviderAPIError: Authentication failed - No response from the model - Cryptic error messages about credentials

Why This Happens: - API keys not set as environment variables - Whitespace or copying errors in key - Incorrect key permissions or expired credentials

Solution: See Authentication Errors for complete fix.

Prevention: - Use environment variables for sensitive credentials - Store keys in .env files (add to .gitignore) - Regularly rotate and update API keys - Use secret management tools for production

Mistake: Incorrect Tool Call Handling

You'll See: - Tools not executing during generation - Partial or missing tool call results - Streaming interruptions

Why This Happens: - Not using @tool decorator - Incorrect tool definition format - Not handling tool responses

Solution:

from abstractcore import create_llm, tool

# Use @tool decorator for automatic tool definition
@tool
def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return f"Weather in {city}: sunny, 72°F"

llm = create_llm("openai", model="gpt-4o-mini")
response = llm.generate(
    "What's the weather in Tokyo?",
    tools=[get_weather]  # Pass decorated function directly
)

Prevention: - Always use @tool decorator for automatic tool definitions - Use type hints for all parameters - Add clear docstrings for tool descriptions - Handle tool execution errors gracefully - See: Tool Calls Not Working

Mistake: Overlooking Error Handling

You'll See: - Unhandled exceptions - Silent failures in tool or generation calls - Unexpected application crashes

Why This Happens: - Not catching provider-specific exceptions - Assuming 100% reliability of LLM responses - No retry or fallback mechanisms

Solution:

from abstractcore import create_llm
from abstractcore.exceptions import ProviderAPIError, RateLimitError

providers = [
    ("openai", "gpt-4o-mini"),
    ("anthropic", "claude-haiku-4-5"),
    ("ollama", "qwen3-coder:30b")
]

def generate_with_fallback(prompt):
    for provider, model in providers:
        try:
            llm = create_llm(provider, model=model)
            return llm.generate(prompt)
        except (ProviderAPIError, RateLimitError) as e:
            print(f"Failed with {provider}: {e}")
            continue
    raise Exception("All providers failed")

Prevention: - Always use try/except blocks - Implement provider fallback strategies - Log and monitor errors systematically - Design for graceful degradation

Mistake: Memory and Performance Bottlenecks

You'll See: - High memory consumption - Slow response times - Out-of-memory errors during long generations

Why This Happens: - Not managing token limits - Generating overly long responses - Inefficient streaming configurations

Solution:

from abstractcore import create_llm

llm = create_llm("openai", model="gpt-4o-mini", timeout=30, max_tokens=4096)
response = llm.generate(
    "Complex task",
    max_output_tokens=1000,  # Output cap; max_tokens is the input + output budget
    temperature=0.7,
)

Prevention: - Set total context (max_tokens) and generation (max_output_tokens) budgets explicitly - Use streaming for long responses - Monitor memory usage in production - See: Performance Issues

Mistake: Hardcoding Credentials

You'll See: - Exposed API keys in code - Inflexible configuration management - Security vulnerabilities

Why This Happens: - Copying example code directly - Not understanding configuration best practices - Lack of environment-based configuration

Solution:

import os
from abstractcore import create_llm

# Best practice: Load from environment
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
DEFAULT_MODEL = os.getenv('DEFAULT_LLM_MODEL', 'gpt-4o-mini')

llm = create_llm(
    "openai",
    model=DEFAULT_MODEL,
    api_key=OPENAI_API_KEY
)

Prevention: - Never hardcode API keys or sensitive data - Use environment variables - Implement configuration management libraries - Follow 12-factor app configuration principles


Quick Diagnosis

Run these checks first:

# Check Python version
python --version  # Should be 3.9+

# Check AbstractCore installation
pip show abstractcore

# Test core library
python -c "from abstractcore import create_llm; print('✓ Core library OK')"

# Test server (if installed)
curl http://localhost:8000/health  # Should return {"status":"healthy"}

Installation Issues

Issue: ModuleNotFoundError

Symptoms:

ModuleNotFoundError: No module named .abstractcore.
ModuleNotFoundError: No module named 'openai'

Solutions:

# Light: OpenAI, Anthropic, OpenRouter, Portkey, Ollama, LM Studio, a vLLM server,
# any OpenAI-compatible endpoint (upgrade an older install that lacks a provider SDK)
pip install -U abstractcore

# Local engines (MLX, vLLM in-process, HuggingFace/GGUF)
pip install "abstractcore[apple]"    # Apple silicon
pip install "abstractcore[gpu]"      # NVIDIA / AMD

# Verify installation
pip list | grep abstract

Issue: Dependency Conflicts

Symptoms:

ERROR: pip's dependency resolver does not currently take into account all the packages...

Solutions:

# Create clean environment
python3 -m venv .venv
source .venv/bin/activate  # Linux/Mac
# OR
.venv\Scripts\activate  # Windows

# Fresh install
pip install --upgrade pip
pip install abstractcore                  # light (remote providers)
# or: pip install "abstractcore[apple]"   # Apple silicon local engines
# or: pip install "abstractcore[gpu]"     # NVIDIA / AMD local engines

Core Library Issues

Issue: Authentication Errors

Symptoms:

Error: OpenAI API key not found
Error: Authentication failed
Error: Invalid API key

Solutions:

# Check if API key is set
echo $OPENAI_API_KEY  # Should show your key
echo $ANTHROPIC_API_KEY

# Set API key
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."

# Add to shell profile for persistence
echo 'export OPENAI_API_KEY="sk-..."' >> ~/.bashrc
source ~/.bashrc

# Verify key format
# OpenAI: starts with "sk-"
# Anthropic: starts with "sk-ant-"

# Test authentication
python -c "from abstractcore import create_llm; llm = create_llm('openai', model='gpt-4o-mini'); print(llm.generate('test').content)"

Issue: Model Not Found

Symptoms:

Error: Model 'qwen3-coder:30b' not found
Error: Unsupported model

Solutions:

For Ollama:

# Check available models
ollama list

# Pull missing model
ollama pull qwen3-coder:30b

# Verify Ollama is running
ollama serve

For LMStudio:

# Check LMStudio server
curl http://localhost:1234/v1/models

# In LMStudio GUI:
# 1. Go to "Local Server" tab
# 2. Select model from dropdown
# 3. Click "Start Server"

For OpenAI/Anthropic:

# Use correct model names
llm = create_llm("openai", model="gpt-4o-mini")  # ✓ Correct
llm = create_llm("openai", model="gpt4")  # ✗ Wrong

llm = create_llm("anthropic", model="claude-haiku-4-5")  # ✓ Correct
llm = create_llm("anthropic", model="claude-3")  # ✗ Wrong

Issue: Connection Errors

Symptoms:

Connection refused
Timeout error
Network error

Solutions:

For Ollama:

# Start Ollama service
ollama serve

# Check if running
curl http://localhost:11434/api/tags

# If using custom host
export OLLAMA_HOST="http://localhost:11434"

For LMStudio:

# Verify server is running
curl http://localhost:1234/v1/models

# Check port in LMStudio GUI (usually 1234)

For Cloud Providers:

# Test network connection
ping api.openai.com
ping api.anthropic.com

# Check proxy settings
echo $HTTP_PROXY
echo $HTTPS_PROXY

# Disable proxy if needed
unset HTTP_PROXY
unset HTTPS_PROXY

Issue: Tool Calls Not Working

Symptoms: - Tools not being called - Empty tool responses - Tool format errors

Solutions:

from abstractcore import create_llm, tool

# Ensure @tool decorator is used
@tool
def get_weather(city: str) -> str:
    """Get weather for a city."""
    return f"Weather in {city}: sunny, 72°F"

# Use tool correctly
llm = create_llm("openai", model="gpt-4o-mini")
response = llm.generate(
    "What's the weather in Paris?",
    tools=[get_weather]  # Pass as list
)

# Check if tool was called
if hasattr(response, 'tool_calls') and response.tool_calls:
    print("Tools were called")

Local Model Downloads

These entries cover models loaded from local caches (MLX, HuggingFace, embeddings) and the abstractcore models ... download verbs. See Local Models for the full reference.

Issue: "download it first" when loading a local model

Symptoms: create_llm("mlx", ...), create_llm("huggingface", ...) or EmbeddingManager(...) raises ModelNotFoundError with download it first: abstractcore models download huggingface <repo>.

Cause: with the default offline settings, loading reads the local caches only and never downloads. The model is not cached, or its snapshot is incomplete (a config without weights, a README only, or an adapter whose base model is missing).

Fix:

abstractcore models download mlx mlx-community/Qwen3-4B-4bit      # MLX builds
abstractcore models download huggingface <repo>                  # transformers / GGUF repos
abstractcore models list --provider huggingface                  # confirm it is installed

To let loads fetch from the Hub instead, turn off offline_first and force_local_files_only (see Centralized Config).

Issue: A download is refused because the Hub is offline

Symptoms: abstractcore models download ... or a console download fails at once with a message naming HF_HUB_OFFLINE or TRANSFORMERS_OFFLINE.

Cause: the variable was set in the environment before the process started. AbstractCore never lifts an offline flag you set yourself; offline_first alone never blocks an explicit download.

Fix: unset the variable, restart the process (or the server), and download again.

Issue: A download is stalled or ends failed

Symptoms: the job's state is stalled ("no data for N s"), or the job ends failed.

Checks: abstractcore models jobs <job_id> --json shows ended_reason (one plain sentence: dropped connection, Hub error, full disk, owning process gone, failed MTP companion) and log_tail.

Fix: a stalled download resumes by itself when bytes arrive again. For a failed one, fix the stated reason and run the same download again: files that finished are kept, and the file that was in progress starts over. Set HF_TOKEN for gated repositories.

Issue: Other tools cannot find a model AbstractCore downloaded

Symptoms: mlx_lm.load("<repo>"), transformers with local_files_only=True or vLLM report "couldn't find them in the cached files", while AbstractCore loads the same model.

Cause: the cached repo has a complete snapshot but no refs/main.

Fix:

abstractcore models repair-refs --dry-run   # list what would be written
abstractcore models repair-refs

See Repairing refs/main.

Issue: A model loads but answers nonsense, or MTP is not used

Checks:

abstractcore models verify <repo>            # default provider: mlx
abstractcore models verify qwen3:8b --provider ollama

The command loads the installed model, asks a fixed question and checks the answer. For a model with an MTP companion it also checks that speculation.used is true. When the companion is missing, the response's speculation.message names it and the command that downloads it (see MTP companions and Speculative Decoding). For quantized transformers checkpoints, see the entry below.


Server Issues

Issue: Managed listener is unavailable while native inference works

The optional Core HTTP listener and native framework execution have separate readiness. Inspect the listener handle's status() and last_error, or its supervising host's service status. Check the configured bind, a port collision and Core's own token; a Gateway token is not a direct Core credential. Fix the listener configuration before asking the host to retry. Stopping or restarting HTTP serving does not require unloading the execution owner's models. See managed listeners.

Issue: Server Won't Start

Symptoms:

Address already in use
Port 8000 is already allocated

Solutions:

# Check what's using port 8000
lsof -i :8000  # Linux/Mac
netstat -ano | findstr :8000  # Windows

# Use different port
uvicorn abstractcore.server.app:app --port 3000

Identify the process holding the port before changing it. Reuse the intended service or choose an available port; a separate server process has its own model pool. Direct uvicorn serving requires explicit Core authentication configuration; see Server.

Issue: Client complains about missing API key

Symptoms: - Your OpenAI-compatible client/CLI refuses to run without an API key (even though your server is local).

Solutions:

# Most OpenAI-compatible clients accept a dummy key for local servers.
export OPENAI_BASE_URL="http://localhost:8000/v1"
export OPENAI_API_KEY="unused"

# Verify they're set
echo "$OPENAI_BASE_URL"
echo "$OPENAI_API_KEY"

Issue: Server Running but No Response

Symptoms: - curl hangs - No response from endpoints - Timeout errors

Solutions:

# Check server is actually running
curl http://localhost:8000/health

# Check server logs
tail -f logs/abstractcore_*.log

# Enable debug mode
export ABSTRACTCORE_DEBUG=true
uvicorn abstractcore.server.app:app --host 0.0.0.0 --port 8000

# Test with simple request
curl -X POST http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-4o-mini", "messages": [{"role": "user", "content": "test"}]}'

Issue: Models Not Showing

Symptoms:

curl http://localhost:8000/v1/models returns empty list

Solutions:

# Check if providers are configured
curl http://localhost:8000/providers

# Verify provider setup:

# For Ollama
ollama list  # Should show models
ollama serve  # Make sure it's running

# For OpenAI
echo $OPENAI_API_KEY  # Should be set

# For Anthropic
echo $ANTHROPIC_API_KEY  # Should be set

# For LMStudio
curl http://localhost:1234/v1/models  # Should return models

Issue: Tool Calls Not Working with CLI

Symptoms: - Codex/Crush/Gemini CLI not detecting tools - Tool format errors in streaming

Solutions:

# AbstractCore Server controls tool-call syntax via `agent_format` (request field) or auto-detection.
# - OpenAI/Codex style: structured tool calls are returned in `tool_calls` fields.
# - Tag-based formats: tool calls are emitted as tagged content for clients that parse from assistant text.

# If you control requests (curl/custom client), force a format with `agent_format`:
curl -X POST http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ollama/qwen3:4b-instruct-2507-q4_K_M",
    "messages": [{"role": "user", "content": "Use the tool."}],
    "tools": [{"type":"function","function":{"name":"get_weather","description":"...","parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}],
    "agent_format": "llama3"
  }'

See Server for details and supported formats.


Issue: A mailbox does not connect

Symptoms: - abstractcore email connect (or Connect on the console's Email tab) stops with email_discovery_failed, email_auth_failed, email_tls_failed or email_unreachable.

Checks and fixes:

abstractcore email discover me@example.com   # which servers the address leads to, and every step tried
  • email_discovery_failed: no step found both servers. Give them yourself (--imap-host, --smtp-host, or the Server fields on the IMAP tab); your provider's help pages list them.
  • email_auth_failed: the password was refused. Many providers need an app password when two-step verification is on; if your provider signs in with a name other than the address, pass --username (in the console: My provider uses a different login name).
  • email_tls_failed: the port and security do not match (993 SSL or 143 STARTTLS for IMAP, 465 SSL or 587 STARTTLS for SMTP), or the server is signed by a private CA (--ca-file, in the console: Custom certificate).
  • email_unreachable: the host name is wrong or a firewall blocks the port.

abstractcore email test checks the stored account again once it connects. See Email.


Provider-Specific Issues

Native MLX concurrency and MTP

Requests overlap but do not batch: enable mlx_batching=True when constructing the supported Qwen3.8 provider, or in options on /acore/models/load before sending chat requests. Inspect metadata["execution"]["mode"] and peak_batch_size; concurrent HTTP clients alone do not prove tensor batching.

A later request waits while MTP is running: MTP cohorts cannot admit late arrivals. Use speculation=False for compatible greedy continuous admission. Sampled or incompatible controls run exclusively. Compare policies using your own prompts; see measured concurrency tradeoffs.

Requested MTP is unavailable: check the actual speculation.used outcome, trained head availability and dependency versions. Non-neutral logits penalties and logit bias require target decoding or explicit optional fallback; strict acceleration raises. The 27B head is a separate artifact; Flash-Next requires a checkpoint containing its trained head tensors.

Unload is refused or SSD storage is locked: finish/cancel the owning provider's requests and close its streams before retrying unload. Give each independent process a private SSD cache path. Do not remove another running process's lock. See native lifecycle and cache configuration.

Ollama

Issue: Ollama not responding

# Restart Ollama
pkill ollama
ollama serve

# Check status
curl http://localhost:11434/api/tags

# List models
ollama list

# Pull model if missing
ollama pull qwen3-coder:30b

Issue: Out of memory

# Use smaller models
ollama pull gemma3:1b  # Only 1GB
ollama pull qwen3:4b-instruct-2507-q4_K_M  # 4GB

# Check system memory
free -h  # Linux
vm_stat  # macOS

# Close other applications

OpenAI

Issue: Rate limits

# Check your rate limits
# https://platform.openai.com/account/rate-limits

# Implement backoff in code
import time
try:
    response = llm.generate("prompt")
except RateLimitError:
    time.sleep(20)  # Wait before retry

Issue: Billing

# Check billing dashboard
# https://platform.openai.com/account/billing

# Verify payment method is added
# Check usage limits aren't exceeded

Anthropic

Issue: API key format

# Anthropic keys start with "sk-ant-"
echo $ANTHROPIC_API_KEY  # Should start with sk-ant-

# Get key from console
# https://console.anthropic.com/

LMStudio

Issue: Connection refused

# Verify LMStudio server is running
# Check LMStudio GUI shows "Server running"

# Test connection
curl http://localhost:1234/v1/models

# Check port number in LMStudio (usually 1234)

Issue: LM Studio Server Not Enabled

# CRITICAL: Ensure LM Studio server is enabled in the GUI
# 1. Open LM Studio application
# 2. Look for "Status: Running" toggle switch in the interface
# 3. Make sure the toggle is switched to "ON" (green background, white handle on right)
# 4. If the toggle shows "OFF", click it to enable the server
# 5. Verify the server is running by checking the status indicator

# Test server availability
curl http://localhost:1234/v1/models

# If still failing, check LM Studio logs for any error messages

Issue: Context Length Too Small (400 Bad Request, Truncated Responses)

# Problem: LLM returns 400 Bad Request, truncated output, or errors with long inputs
# Check: configured context length for the model and server

# Solution 1: Increase Default Context Length (RECOMMENDED)
# This is the most robust way to ensure all models use maximum available context
# 1. Open LM Studio application
# 2. Go to "App Settings" → "General" tab
# 3. Find "Model Defaults" → "Default Context Length"
# 4. Set dropdown to "Model Maximum" (or highest available value like 131072)
# 5. Restart LM Studio server for changes to take effect

# Solution 2: Increase Context Length per Model (Alternative)
# This method applies context length setting to a specific model
# 1. Open LM Studio application
# 2. Go to "My Models" tab
# 3. Select the specific model you are using
# 4. Look for "Context Length" slider/input (usually under "Load" or "Context" tab)
# 5. Adjust slider to maximum value (e.g., 131072 tokens)
# 6. Reload the model for changes to take effect

# Solution 3: Increase Context Length via API Request (Advanced)
# For Ollama, or if you need to override settings for LM Studio via API
# For Ollama:
ollama run <model_name> -c <context_length>
# Example: ollama run llama2 -c 4096

# For LM Studio via API (often handled automatically by AbstractCore):
# Include in request payload:
# {
#   "model": "your-model-name",
#   "prompt": "Your long prompt here...",
#   "options": {
#     "num_ctx": 4096  # Or your desired context length
#   }
# }

# Verification:
# After adjusting, test with a long prompt that previously failed
# Check server logs for any warnings or errors related to context

Performance Issues

Issue: Slow Responses

Diagnosis:

# Time a request
time python -c "from abstractcore import create_llm; llm = create_llm('ollama', model='qwen3:4b-instruct-2507-q4_K_M'); print(llm.generate('test').content)"

Solutions:

Use Faster Models:

# Faster cloud models
llm = create_llm("openai", model="gpt-4o-mini")  # Fast
llm = create_llm("anthropic", model="claude-haiku-4-5")  # Fast

# Faster local models
llm = create_llm("ollama", model="gemma3:1b")  # Very fast
llm = create_llm("ollama", model="qwen3:4b-instruct-2507-q4_K_M")  # Balanced

Enable Streaming:

# Improves perceived speed
for chunk in llm.generate("Long response", stream=True):
    print(chunk.content, end="", flush=True)

Optimize Parameters:

response = llm.generate(
    "prompt",
    max_tokens=500,      # Limit length
    temperature=0.3      # Lower = faster
)

Issue: Model is already loaded with another configuration

InvalidRequestError messages that say a second copy is never loaded are deterministic resource-admission refusals. Keep the resident device, backend, GPU-layer placement or MLX target/head/PLE configuration, or finish active work and unload all holders before changing it. Transformers callers reuse the existing provider rather than constructing another for the same base artifact. A retry of the same conflicting request will not help.

List resident_rows() or the host's loaded-models surface to find the owner; do not disable model sharing or launch another standalone server to bypass the refusal. Separate contexts can legitimately allocate separate KV while sharing GGUF weights. See managed-loader sharing rules.

Issue: High Memory Usage

Solutions:

# Use smaller models
ollama pull gemma3:1b  # 1GB instead of 30GB

# Close other applications

# For MLX on Mac
# Use 4-bit quantized models
llm = create_llm("mlx", model="mlx-community/Llama-3.2-3B-Instruct-4bit")

Issue: Memory stays high after unloading a model

Symptoms: unload_model() or POST /acore/models/unload succeeds, but the process still holds the model's memory.

Causes: another compatible holder or owner (a managed runtime, an AbstractRuntime client) still uses the resident model. Holder count does not imply a separate weight copy.

Check:

from abstractcore.utils.memory import get_memory_snapshot
from abstractcore.providers.process_residency import claims_for, resident_rows

snap = get_memory_snapshot()
print(snap["device"]["process_held_bytes"], snap["device"]["process_held_basis"])
print(resident_rows())                                         # holders per model
print(claims_for("mlx", "mlx-community/Qwen3-4B-4bit"))         # who still claims it

Over HTTP, GET /acore/models/loaded shows process: rows and process_holders.

Fix: unload the claiming owner's runtime first, then eject the model from the whole process (eject_unclaimed() in Python, or POST /acore/models/unload with the process: row's runtime_id). A 409 model_in_use or 409 model_locked names the owner in claims. An embedding unload that reports in_flight succeeds once the running embeddings finish.

Verify: device.process_held_bytes drops and the model no longer appears in resident_rows(). Do not use process RSS for this on Metal hosts. See Memory and Model Residency.

Issue: HuggingFace quantized Transformers model loads but generates nonsense

Treat this as a model/runtime compatibility issue. AWQ, GPTQ, bitsandbytes, and compressed-tensors checkpoints require the matching optional Transformers quantization runtime; a downloaded .safetensors file is not enough. If loading reports missing base weights, unexpected packed weights, or mismatched shapes, choose a compatible runtime/model pair or use MLX/GGUF for that quantized artifact. See HuggingFace Model Compatibility.


Best Practices

Follow these best practices to avoid issues:

Configuration Management

  • Use environment variables for API keys
  • Never commit credentials to version control
  • Use .env files (add to .gitignore)
  • Implement configuration validation
  • Use secret management in production

Tool Development

  • Always use @tool decorator
  • Add type hints to all parameters
  • Write clear docstrings
  • Handle edge cases and errors
  • Test tools independently first

Error Handling

  • Always use try/except blocks
  • Implement provider fallback strategies
  • Log errors systematically
  • Design for graceful degradation
  • Monitor error rates in production

Performance

  • Set total context (max_tokens) and generation (max_output_tokens) budgets explicitly
  • Use streaming for long responses
  • Batch similar requests when possible
  • Monitor memory usage
  • Profile slow operations

Security

  • Validate all user inputs
  • Sanitize file paths and commands
  • Use least privilege principle
  • Regular security audits
  • Keep dependencies updated

Debug Techniques

Enable Debug Logging

Core Library:

import logging
logging.basicConfig(level=logging.DEBUG)

from abstractcore import create_llm
llm = create_llm("openai", model="gpt-4o-mini")

Server:

# Enable debug mode
export ABSTRACTCORE_DEBUG=true

# Start with debug logging
uvicorn abstractcore.server.app:app --log-level debug

# Monitor logs
tail -f logs/abstractcore_*.log

Analyze Logs

# Find errors
grep '"level": "error"' logs/abstractcore_*.log

# Track specific request
grep "req_abc123" logs/abstractcore_*.log

# Monitor latency
cat logs/verbatim_*.jsonl | jq '.metadata.latency_ms'

# Token usage
cat logs/verbatim_*.jsonl | jq '.metadata.tokens | .input + .output' | \
  awk '{sum+=$1} END {print "Total:", sum}'

Test in Isolation

# Test provider directly
from abstractcore import create_llm

try:
    llm = create_llm("openai", model="gpt-4o-mini")
    response = llm.generate("Hello")
    print(f"✓ Success: {response.content}")
except Exception as e:
    print(f"✗ Error: {e}")

Collect Debug Information

# Create debug report
echo "=== System ===" > debug_report.txt
uname -a >> debug_report.txt
python --version >> debug_report.txt

echo "=== Packages ===" >> debug_report.txt
pip freeze | grep -E "abstract|openai|anthropic" >> debug_report.txt

echo "=== Environment ===" >> debug_report.txt
env | grep -E "ABSTRACT|OPENAI|ANTHROPIC|OLLAMA" >> debug_report.txt

echo "=== Tests ===" >> debug_report.txt
python -c "from abstractcore import create_llm; print('Core library: OK')" >> debug_report.txt 2>&1
curl http://localhost:8000/health >> debug_report.txt 2>&1

cat debug_report.txt

Common Error Messages

Error Meaning Solution
ModuleNotFoundError Package not installed pip install -U abstractcore, or abstractcore[apple] / abstractcore[gpu] for local engines
Authentication Error Invalid API key Check API key environment variable
Connection refused Service not running Start Ollama/LMStudio/server
LM Studio connection failed LM Studio server not enabled Enable "Status: Running" toggle in LM Studio GUI
400 Bad Request (LM Studio) Context length too small Increase Default Context Length to "Model Maximum" in LM Studio
Model not found Model unavailable Pull model or check name
Rate limit exceeded Too many requests Wait or upgrade plan
Timeout Request took too long Use smaller model or increase timeout
Out of memory Insufficient RAM Use smaller model
Port already in use Another process using port Kill process or use different port

Getting Help

If you're still stuck:

  1. Check Documentation:
  2. Getting Started - Core library quick start
  3. Prerequisites - Provider setup
  4. Python API Reference - Core library API
  5. Server Guide - Server setup
  6. Server API Reference - REST API endpoints

  7. Enable Debug Mode: bash export ABSTRACTCORE_DEBUG=true

  8. Collect Information:

  9. Error messages
  10. Debug logs
  11. System information
  12. Steps to reproduce

  13. Community Support:

  14. GitHub Issues: github.com/lpalbou/AbstractCore/issues
  15. GitHub Discussions: github.com/lpalbou/AbstractCore/discussions

Remember: Most issues are configuration-related. Double-check environment variables, API keys, and that services are running before diving deep into debugging.