Python SDK
Capture application turns with the source Python SDK and inspect their recorded evidence.
Watch the workflow: Read a recorded session and tool trace · Authored dummy data
Read authored agent inputs and outputs, open the recorded trace and inspect one tool run. Role, completion and customer outcome remain unknown. No evidence or feedback is saved.
This video shows the matching app inspection workflow with authored dummy data. It does not execute an SDK example or prove successful delivery from your application. Read the matching command examples separately.
Read the walkthrough transcript
- 00:00 — Read recorded agent inputs and outputs in Tensile. This is an authored demo session.
- 00:05 — Open Trace to see the recorded runs. The session outcome remains unknown.
- 00:11 — Read one tool run's input and output. Saving evidence is a separate action.
The SDK registry release is pending. These instructions require a trusted source checkout supplied by your team. They do not install a package from the public registry. Without SDK source access, use the capture API instead.
Source setup
python3 -m venv .venv
source .venv/bin/activate
python -m pip install ./sdks/pythonRun these commands from the source checkout with Python 3.12 or later. For an application in a different virtual environment, install the SDK folder there.
Configure capture
Create a scoped API key in Settings. Set TENSILE_API_KEY in the application environment. The default endpoint is https://api.withtensile.com. Set TENSILE_ENDPOINT to change it, including for an isolated local test. Never put a real key in source code or a recording.
Set TENSILE_ENV=staging, or pass the environment explicitly. The explicit setting wins. Without a stage tag, the app cannot treat the record as production traffic.
Capture a turn
import os
import withtensile
withtensile.init(os.environ["TENSILE_API_KEY"], environment="staging")
withtensile.identify("demo-user", {"plan": "demo"})
turn = withtensile.begin(
user_id="demo-user",
agent_name="demo-support",
input="What is the status of demo order 1042?",
)
turn.set_property("channel", "help-demo")
turn.end("Demo order 1042 is shipped.", success=True)begin creates a session ID and records the start time. end sends the session once, then sends an event with the output, success flag and latency. success=True describes this recorded turn; it is not an assessment of task correctness.
For a completed turn, use withtensile.track(user_id="demo-user", input="Hi", output="Hello", agent_name="demo-support"). Pass a shared conversation_id to group turns in one session.
Use withtensile.identify("demo-user", {"plan": "demo"}) before capture to attach string traits to the next session. Use turn.set_properties({"channel": "help-demo", "model": "demo-model"}) for custom properties. These values describe the record; they do not run a model.
Check errors and delivery
Capture failures are logged and dropped by default. For a test that must fail on a capture error, construct withtensile.client.Client(api_key, raise_on_error=True). Test against an isolated endpoint. Do not infer delivery from a completed application turn.
Open User Stories to inspect a captured conversation. Use its trace view to read recorded events. Or open Raw Logs, select the matching stage and inspect the input and output of one event. Missing records are not successful delivery. A tool success flag does not prove a customer outcome.
For tool calls, see MCP capture.