FluxLoop SDK
FluxLoop SDK for agent instrumentation and tracing.
Installation
pip install fluxloop
Quick Start
from fluxloop import trace, FluxLoopClient
# Initialize the client
client = FluxLoopClient()
# Use the trace decorator
@trace()
def my_agent_function(prompt: str):
# Your agent logic here
return result
Features
- 🔍 Automatic Tracing: Instrument your agent code with simple decorators
- 📊 Rich Context: Capture inputs, outputs, and metadata
- 🔄 Async Support: Works with both sync and async functions
- 🎯 Framework Integration: Built-in support for LangChain and LangGraph
Documentation
For detailed documentation, visit https://docs.fluxloop.dev
License
Apache License 2.0 - see LICENSE file for details
Framework Integration: Decorator Ordering and Safe Instrumentation
When integrating FluxLoop with external agent frameworks (e.g., ChatKit, LangChain), follow these rules to avoid type conflicts and ensure observations are captured reliably.
- Outermost framework wrapper: If a framework provides its own decorator/wrapper that transforms a plain function into a framework-specific object (e.g., a Tool), that decorator MUST be the outermost (top) decorator. This preserves the type the framework expects.
- FluxLoop instrumentation inside: Place FluxLoop decorators inside (below) the framework decorator, or instrument from within the function body using the SDK context APIs.
Two safe patterns:
-
Pattern A (safest, framework-agnostic): instrument inside the function body
-
Use
get_current_context()and push/pop anObservationDatamanually around your logic. This keeps signatures and framework typing unchanged. -
Example (tool function):
from fluxloop import get_current_context from fluxloop.models import ObservationData, ObservationType async def my_tool(param: str) -> dict: fl_ctx = get_current_context() obs = None if fl_ctx and fl_ctx.is_enabled(): obs = ObservationData( type=ObservationType.TOOL, name="tool.my_tool", input={"args": {"param": param}}, ) fl_ctx.push_observation(obs) try: result = {"result": do_work(param)} if obs: obs.output = result return result except Exception as e: if obs: obs.error = str(e) raise finally: if fl_ctx and obs: fl_ctx.pop_observation()
-
-
Pattern B (stacking decorators): framework outermost, FluxLoop inside
-
Example with a framework tool decorator:
@framework_tool_decorator(...) @fluxloop.tool(name="tool.my_tool") async def my_tool(...): ...
-
Important: If you reverse the order (FluxLoop outside), the framework may see a plain function instead of its expected type and raise errors like "Unknown tool type".
-
LLM/streaming calls:
- For LLM calls (including async generators/streams), either:
- Wrap the call site in a small helper decorated with
@fluxloop.prompt(...), or - Use
with fluxloop.instrument("prompt.name"):around the portion that produces model output, ensuring it runs inside the current FluxLoop context.
- Wrap the call site in a small helper decorated with
These patterns guarantee observations are captured (tool, generation) while keeping the external framework’s type system intact.
Metadata
Release files for fluxloop 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fluxloop-0.1.8.tar.gz | 27.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fluxloop-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.4 kB
Release files / fluxloop-0.1.8.tar.gz
| Download URL | fluxloop-0.1.8.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd03d06b96e56450439a2be6d018ede79835468ba43dcb3796d8772e971e6a9a
|
|
BLAKE2b-256 checksum How to use checksums |
64b318e22ab68b13cebc5530f1ad225404667a1cbbfb552629b4c0bbca903def
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / fluxloop-0.1.8-py3-none-any.whl
| Download URL | fluxloop-0.1.8-py3-none-any.whl |
|---|---|
| Size | 24.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8b331a3716a10e8edcd3fd8e2d8104035ea3eb7aca8e177c8b62abec30137d7
|
|
BLAKE2b-256 checksum How to use checksums |
9fe42fc6956df1aaa0c0dc1ee20c27f211e59aeb40173a2a8a48705a510be36d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for fluxloop 0.1.8
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.