Skip to main content

ClientCoded Python SDK

Trace your AI agent's tool calls for root cause analysis when failures occur.

Install

pip install clientcoded

Quick Start

import clientcoded

# Configure once at startup
clientcoded.configure(
    agent_id="your-agent-id",
    api_key="your-api-key"
)

# Decorate any function your agent calls
@clientcoded.trace
def get_invoice(invoice_id):
    return stripe.Invoice.retrieve(invoice_id)

@clientcoded.trace
def search_knowledge_base(query):
    return pinecone.query(query)

@clientcoded.trace
def update_crm(contact_id, data):
    return hubspot.update_contact(contact_id, data)

Conversation Tracking

# At the start of each conversation
clientcoded.set_conversation_id("conv-123")

# At each turn
clientcoded.set_turn(1)
response = agent.handle_message("What is my invoice total?")

clientcoded.set_turn(2)
response = agent.handle_message("Can you break that down by line item?")

Async Support

@clientcoded.trace_async
async def get_invoice(invoice_id):
    return await stripe.Invoice.aretrieve(invoice_id)

Custom Names

@clientcoded.trace(name="stripe_invoice_lookup")
def get_invoice(invoice_id):
    return stripe.Invoice.retrieve(invoice_id)

Manual Logging

For complex operations where decorators don't fit:

import time

start = time.time()
try:
    result = complex_multi_step_operation()
    clientcoded.log_trace(
        "complex_operation",
        input_data={"step": "final"},
        output_data=result,
        latency_ms=int((time.time() - start) * 1000)
    )
except Exception as e:
    clientcoded.log_trace(
        "complex_operation",
        input_data={"step": "final"},
        error=str(e),
        latency_ms=int((time.time() - start) * 1000)
    )
    raise

LangChain Integration

from langchain.tools import tool
import clientcoded

clientcoded.configure(agent_id="your-agent-id", api_key="your-api-key")

@tool
@clientcoded.trace
def search_database(query: str) -> str:
    """Search the company database."""
    return db.execute(query)

LlamaIndex Integration

from llama_index.core.tools import FunctionTool
import clientcoded

clientcoded.configure(agent_id="your-agent-id", api_key="your-api-key")

@clientcoded.trace
def query_index(question: str) -> str:
    return index.query(question)

tool = FunctionTool.from_defaults(fn=query_index)

What Gets Traced

For each decorated function call, the SDK logs:

  • Function name (or custom name)
  • Input arguments (truncated to 2000 chars)
  • Output (truncated to 2000 chars)
  • Error message if the function threw
  • Latency in milliseconds
  • Conversation ID and turn number (if set)

What Doesn't Get Traced

  • The SDK never captures environment variables
  • The SDK never captures file contents
  • Large inputs/outputs are truncated, not stored in full
  • All trace sends are fire-and-forget with a 2-second timeout

Safety

  • The SDK will never break your agent. Every trace send is wrapped in try/catch.
  • Trace sends happen in background threads. Zero impact on response latency.
  • If the ClientCoded API is down, traces are silently dropped. Your agent continues normally.
  • No sensitive data filtering in v0.1. Do not decorate functions that handle passwords, tokens, or PII directly. Wrap them in a function that sanitizes first.

Configuration

Environment Variable Default Description
CLIENTCODED_TRACE_URL https://clientcoded.app.n8n.cloud/webhook/ap-35-trace-ingest Custom trace endpoint

Metadata

Release files for clientcoded 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clientcoded 0.3.0
File Size Uploaded Provenance Actions
clientcoded-0.3.0.tar.gz 7.4 kB Without provenance Details for clientcoded-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clientcoded 0.3.0
File Interpreter ABI Platform Actions
clientcoded-0.3.0-py3-none-any.whl Python 3 none any Details for clientcoded-0.3.0-py3-none-any.whl

Total release size: 14.4 kB

Release files / clientcoded-0.3.0.tar.gz

Download URL clientcoded-0.3.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
286c48c63a3273d4c29474f25d0f4b6f5b474ead089e59e39754fc109f38494c
BLAKE2b-256 checksum
How to use checksums
55ef49ced9839b9ffefc3c24c2a92eaad98c84e98e87ccd7a9af884b40e65c98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / clientcoded-0.3.0-py3-none-any.whl

Download URL clientcoded-0.3.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f294be1f1f9aa8a923f3df0bb594fec01d4cc94dcefce6050df40df23381951
BLAKE2b-256 checksum
How to use checksums
af28338567481c94d8df23bab233fb10e35906ac25e7a67862411ae1b61d1df3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for clientcoded 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page