agentleFS
shyftlabsshyftlabs/continuum/.claude/skills/continuum-observability/SKILL.md

continuum-observability

Skill84 starsChanged 6 months agoApache-2.0View on GitHub

Trace agent runs with Langfuse, decorate functions with @observe, collect latency/token/error metrics, and report errors. Invoke when the user asks about "see what the LLM was prompted with", "Langfuse traces", "track latency", "metrics dashboard", "error reporting", or "instrument my function".

  • Reads credentials

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every OrchestratorError with should_report=True is reported automatically.

    line 140
  2. Very specific:

    Don't expect to see traces if LANGFUSE_ENABLED=false or the keys are missing.

    line 198
  3. Very specific:

    Don't rely on @observe to capture huge payloads — truncate_data caps each field at 10 KB by default.

    line 200
  4. Very specific:

    Don't make @observe-decorated functions sync if the rest of your code is async — the contextvars magic works best in fully-async code.

    line 202
  5. Very specific:

    Don't flush_langfuse() in the middle of a request loop — it's expensive.

    line 204
  6. Very specific:

    Don't forget to set SHARED_SERVICES_ENABLED=false if your process is the sole owner of Langfuse — otherwise traces don't flush on shutdown.

    line 206

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Continuum Observability Skill

Authoritative source: docs/observability.md.


Quick start

Tracing is on by default if Langfuse is configured.

docker compose --profile observability up -d              # brings up Langfuse on :3000
LANGFUSE_ENABLED=true
LANGFUSE_HOST=http://localhost:3000
LANGFUSE_PUBLIC_KEY=…                                      # from Langfuse UI
LANGFUSE_SECRET_KEY=…

Open http://localhost:3000 — every agent run, LLM call, and tool call shows up automatically.

To disable: LANGFUSE_ENABLED=false.


Trace your own functions

from continuum.observability import observe, SpanLevel

@observe(name="my-pipeline", capture_input=True, capture_output=True,
         metadata={"version": "v2"}, level=SpanLevel.DEFAULT)
async def run_pipeline(data):
    ...

Specialized variants:

from continuum.observability import trace_tool, trace_agent

@trace_tool(name="search_db", tool_type="database")
def search_db(query): ...

@trace_agent
async def my_custom_agent_runner(...): ...

Manual spans

from continuum.core.container import get_container

mgr = get_container().tracing_manager

with mgr.trace(name="onboarding", user_id="u1", session_id="s1",
               metadata={"tier": "pro"}, tags=["beta"]) as trace:
    with mgr.span(name="step-1", input={"foo": 1}) as span:
        span.event(name="cache-hit")
        span.score(name="quality", value=0.92)

Generation spans (LLM calls):

with mgr.span(name="step") as span:
    gen = span.generation(name="llm-call", model="gpt-4o-mini",
                          input=messages)
    # … call the LLM …
    gen.end(output=response_text,
            usage_prompt_tokens=120, usage_completion_tokens=80, usage_total_tokens=200)

Async-safe trace context

from continuum.observability import (
    set_trace_context, restore_trace_context,
    get_current_trace_id, get_current_session_id, get_current_user_id,
)

token = set_trace_context(trace_id="abc", user_id="u1", session_id="s1")
try:
    await client.chat(messages)                # inherits the trace context
finally:
    restore_trace_context(token)

Metrics

from continuum.observability import (
    get_metrics_collector, get_metrics_summary, reset_metrics,
)

mc = get_metrics_collector()

# Latency
with mc.track_latency("rag.retrieve") as m:
    docs = await retrieve(query)
print(m.duration_ms)

# Or record directly
mc.record_latency("db.query", 12.4, metadata={"table": "users"})

summary = get_metrics_summary()      # {latency: {...}, tokens: {...}, errors: {...}}

Error reporting

from continuum.observability import (
    report_error, report_exception, flush_errors,
    enable_error_reporting, disable_error_reporting,
)

try:
    ...
except SomeError as e:
    # `context` is a short label string; structured data goes in `metadata=`.
    report_error(e, context="db_query", user_id="u1", metadata={"table": "users"})

Every OrchestratorError with should_report=True is reported automatically. The reporter has a thread-safe queue (max 1000 entries) and an auto-flush every 5 seconds.


Debug tip: log the assembled prompt

LOG_FULL_PROMPT=true

The runner prints the entire message list it sends to the LLM — indispensable for debugging memory / RAG / handoff flows.


ObservabilityConfig (when wiring providers manually)

from continuum.observability import ObservabilityConfig, initialize_observability

cfg = ObservabilityConfig(
    providers=["langfuse"],
    enabled=True,
    public_key="pk-…", secret_key="sk-…",
    host="http://localhost:3000",
    sample_rate=1.0, flush_interval=1, flush_at=15,
    environment="production", default_tags=["app:billing"],
)
mgr = initialize_observability(cfg)

The lifecycle manager normally calls this for you.


Custom provider

from continuum.observability import (
    ObservabilityProvider, ProviderCapabilities, register_provider,
)

class MyProvider(ObservabilityProvider):
    def __init__(self): super().__init__(name="my", config={})
    def supports_feature(self, feat): return feat == ProviderCapabilities.TRACE
    def trace(self, name, **kw): ...
    def span(self, *, trace_id, name, **kw): ...
    # …generation, event, score, flush, shutdown

register_provider("my", MyProvider())

Don't

  • Don't expect to see traces if LANGFUSE_ENABLED=false or the keys are missing.
  • Don't rely on @observe to capture huge payloads — truncate_data caps each field at 10 KB by default.
  • Don't make @observe-decorated functions sync if the rest of your code is async — the contextvars magic works best in fully-async code.
  • Don't flush_langfuse() in the middle of a request loop — it's expensive. Lifecycle shutdown handles it.
  • Don't forget to set SHARED_SERVICES_ENABLED=false if your process is the sole owner of Langfuse — otherwise traces don't flush on shutdown.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.