Your support agent generated three replies, and all three traces show successful execution. A reviewer sent one reply, rejected another, and has yet to open the third. If your dashboard reads agent completion as success, all three look alike. Add LangSmith trace feedback after the review so you can open each original draft trace and see the outcome that belongs to it.
This tutorial is for the engineer who owns a Python tracing integration and can read the review or delivery record. You’ll work in an existing LangSmith Cloud staging environment. The exercise passes when you can find two verified root scores and confirm that the pending draft has a root with no score. You’ll then use the three draft records to calculate send rate and outcome coverage. The cases and expected observations are illustrative. The Python generates fixed text and simulates review records. It sends traces and feedback to staging without sending support messages.
Define what the support reviewer decided
- Use one unit of attribution, the exact draft version presented for review. For
task:draft-outcome-01, each of the three fictional drafts has one version and one dedicated root run. - Choose a single key,
support_draft_sent. Write1when the downstream record confirms that the reviewer sent that draft. Write0when the review record explicitly rejects it. Skip the write while review is pending. - Keep the application’s draft and review records as the authority. Use the trace to inspect how the agent produced the artifact associated with the decision.
A draft can be ready to send and still be sitting in a queue. It can also be approved while a delivery operation is waiting or has failed. For a send metric, read a confirmed send from the downstream record. If your application has an intermediate approved state, wait for a confirmed send before recording a 1. An explicit rejection has a different meaning. A reviewer made a decision about that exact version, and the review receipt records it.
The unit matters if a ticket goes through several attempts. Imagine the address-change reply is rejected, then a second agent run produces a corrected version that the reviewer sends. The first run belongs with the rejection, and the second with the send. A join on ticket number alone can give the first attempt credit for the replacement or overwrite the only rejection you had. Save the roots against the version identifiers when the drafts are created. The example uses draft-sent-v1, draft-rejected-v1, and draft-pending-v1 to make those associations visible.
In the delivery-status case, the send receipt belongs to the Friday delivery reply. If the reviewer changes Friday to Monday before sending, your integration needs to know which version the receipt identifies. The fixture assumes the reviewed and sent version is the same. If your application stores edits as separate versions, preserve that distinction in its records. A send receipt whose draft version cannot be established leaves the original draft without a verified send outcome. Keep that case visible when reviewing the completeness of the data.
The same gap came up in LangChain’s December 3, 2026 Engine Goals announcement. Its Content Studio team already had publishing outcomes elsewhere. Attaching them to the corresponding traces made those outcomes available when investigating how the agent had worked. Here the downstream fact is a support decision, and the exercise uses the tracing and feedback SDK directly. LangChain’s Engine Goals announcement

Capture the root when the draft is created
- Open the existing agent in the intended LangSmith workspace and copy its identifier from the Overview. The example uses
support-draftsas a fictional identifier. SetAGENT_IDto the identifier of your existing agent and leaveENVIRONMENTset tostaging. - Use a Python environment with
langsmith>=0.14.9, tracing enabled withLANGSMITH_TRACING=true, and the existing workspace API key available to the process asLANGSMITH_API_KEY. Use a credential that can submit traces, resolve the environment and write feedback in this workspace. Open the Staging tracing page and locate its tracing project ID before starting the exercise. - Run the definitions below in a fresh interactive Python session with no enclosing trace. Call
rows = create_drafts()once. Keep this session open for the fixture. Confirm the three saved root IDs in Staging before entering the feedback calls.
The SDK supports a tracing_context configured with the agent address. The code opens each trace inside that context and captures root_run.id directly. The draft text comes from the fixture, and the code records it as trace output so that you can check the UUID lookup against the visible artifact. Keep this process on the explicit agent address. LangChain documents conflicts between agent and legacy project settings and notes that an explicit project override can route a traced call away from the environment named in agent variables. Log traces to an agent
The example prints one batch UUID and a root UUID for each draft. The returned mapping holds the root ID and session ID under each draft version. The batch UUID distinguishes consecutive attempts that use the same fixture names. In an application, persist the association beside the stored draft version before showing the draft for review. If a reviewer acts after a restart, the persisted association supplies the same root ID the creation process saw. Carry the routing identity alongside it so a review worker can check where the draft originated before writing anything.
A UUID can identify a valid run and still be wrong for the draft. That happens when an application saves the current span from inside retrieval or starts a new trace during review and uses that ID. The exercise captures the root at the outer draft boundary and uses the draft input and text as an independent check. In a real trace, retrieval and generation spans can carry step-specific feedback. The support disposition applies to the completed artifact and belongs on its root. LangChain’s SDK feedback guide
import asyncio
from uuid import uuid4
import langsmith as ls
from langsmith import Client, trace, tracing_context
AGENT_ID = "support-drafts" # Set this to your existing agent identifier.
ENVIRONMENT = "staging"
TASK = "task:draft-outcome-01"
KEY = "support_draft_sent"
TRACE_NAME = "support-draft-outcome-01"
SCORES = {"sent": 1, "rejected": 0}
DRAFTS = (
("draft-sent-v1", "Delivery status",
"Your parcel is scheduled to arrive Friday."),
("draft-rejected-v1", "Address change",
"Your shipping address has already been changed."),
("draft-pending-v1", "Return window",
"Please confirm the date your parcel arrived."),
)
REVIEWS = {
"draft-sent-v1": ("sent", "send-demo-101"),
"draft-rejected-v1": ("rejected", "reject-demo-102"),
"draft-pending-v1": ("pending", None),
}
client = Client()
address = ls.agent_address(AGENT_ID, ENVIRONMENT)
async def resolve_session_id():
resolved = await client.sessions.resolve(**address)
return resolved.session_id
def create_drafts():
session_id = asyncio.run(resolve_session_id())
print(f"Resolved staging session: {session_id}")
expected = input("Paste the Staging tracing project ID from the UI: ").strip()
if str(session_id) != expected.lower():
raise RuntimeError("Staging project ID mismatch")
batch_id = str(uuid4())
rows = {}
for draft_id, topic, text in DRAFTS:
inputs = {"task": TASK, "batch_id": batch_id,
"draft_id": draft_id, "topic": topic}
with tracing_context(address=address):
with trace(name=TRACE_NAME, inputs=inputs) as root_run:
root_run.outputs = {"draft_text": text}
root_id = root_run.id
rows[draft_id] = {"root_id": root_id, "session_id": session_id}
print(f"{draft_id} batch={batch_id} root={root_id}")
return rows
def record_review(rows, draft_id, *, enabled=False):
if not enabled:
print(f"{draft_id}: writer disabled")
return
row = rows[draft_id]
state, receipt = REVIEWS[draft_id]
if state == "pending":
print(f"{draft_id}: pending, no write")
return
if state not in SCORES or not receipt:
raise ValueError(f"No supported disposition for {draft_id}")
session_id = asyncio.run(resolve_session_id())
if session_id != row["session_id"]:
raise RuntimeError(f"Staging session changed for {draft_id}")
feedback = client.create_feedback(
run_id=row["root_id"],
session_id=session_id,
key=KEY,
score=SCORES[state],
comment=f"{TASK} {draft_id} {state} {receipt}",
)
print(f"{draft_id}: feedback={feedback.id} score={SCORES[state]}")
# First, create the draft roots.
# rows = create_drafts()
# Then check all three roots and the baseline in LangSmith.
# Run the three record_review calls from the worked example table below.
The example resolves the staging address to the UUID of its backing trace storage. LangSmith calls that UUID session_id in the feedback request. The display label Staging identifies the environment in the UI, the agent identifier selects the agent within the workspace, and the UUID identifies the storage backing that environment. Paste the project UUID into the fixture prompt. If the comparison fails, check the UUID against the Staging page for the identifier you passed to agent_address. The comparison runs before the fixture creates any draft traces.
The exercise uses a synchronous entry point and asyncio.run to call the async resolver. If adapting it inside an async web worker or a notebook with a running event loop, await the resolver in that loop and keep the lookup and comparison before the write. A resolver 404 can mean the workspace has no matching agent, the agent is archived, or the credential lacks trace read access. Check those conditions before changing the draft mapping. The resolver is unavailable on BYOC data planes, which use a separate UI path to obtain the tracing project ID. Resolve an agent environment
At the first checkpoint, open the selected agent’s Tracing page, select Staging, and choose a time range covering draft creation. On a page with the search bar, choose Traces and the Root run scope. Enter id: followed immediately by the first printed root UUID. Repeat for each of the other IDs. In each result, open the root and match its draft_id, shared batch_id and draft text to the fixture. Confirm that none of the three roots already carries support_draft_sent. If the project uses filter chips, use the run details to compare the recorded IDs and inspect root feedback. The query examples use the documented search-bar experience. Filter traces
Check the association in both directions while the baseline is empty. Look up the printed ID for the delivery draft and confirm that its output is the Friday sentence. When you open the address-change trace, compare the ID on the trace to the second mapping. Simply finding three traces with the expected name would leave a swap between those two roots undetected. If a third root is missing after a partial fixture attempt, keep that batch out of the exercise and use the IDs from one complete attempt after fixing the trace problem.
Write the two terminal outcomes
- With the three staging roots checked, execute the calls in the table one at a time in the same Python session. Use the printed IDs from your own run when checking results.
- Save the two printed feedback IDs with the fixture mapping. If a call errors or its result is unclear, inspect that root for the existing key and receipt before attempting any repeat write.
- Leave the fixture writer disabled between exercises.
enabled=Trueis an explicit opt-in on each call. The pending case exits before calling the feedback API, even with the writer enabled.
| Input | Action | Expected result |
|---|---|---|
task:draft-outcome-01, draft-sent-v1, delivery status, confirmed send send-demo-101 |
record_review(rows, "draft-sent-v1", enabled=True) |
Illustrative expected observation. One feedback ID prints. The verified Staging root for the Friday delivery draft shows support_draft_sent with score 1 and receipt send-demo-101. |
task:draft-outcome-01, draft-rejected-v1, address change, explicit rejection reject-demo-102 |
record_review(rows, "draft-rejected-v1", enabled=True) |
Illustrative expected observation. One feedback ID prints. The verified Staging root for the address-change draft shows support_draft_sent with score 0 and receipt reject-demo-102. |
task:draft-outcome-01, draft-pending-v1, return window, awaiting review |
record_review(rows, "draft-pending-v1", enabled=True) |
Illustrative expected observation. Python prints pending, no write. The return-window root still exists in Staging and carries no support_draft_sent entry. |
The script passes the saved root UUID as run_id and the owning tracing project UUID as session_id. LangChain reserves project_id on create_feedback for feedback on a project or experiment. The SDK feedback guide also shows a root write using trace_id and says supplying it enables background creation in Python. This fixture uses the documented run_id and session_id call with the root’s ID to keep the target explicit. Verify attribution on the root in the UI after the call. SmithDB feedback migration guide · SDK feedback guide
Keep the comment short enough to match back to the authoritative record. Here reject-demo-102 identifies which decision the score represents, even though another draft could also have a score of zero. In an application use an opaque receipt identifier that your support system can look up. Keep reviewer notes and customer correspondence in the system that owns them. A single key with a numeric score and a reference is enough to verify this join.
The calls are intended as a one-time fixture. An application worker needs durable bookkeeping keyed to the draft version and terminal decision, with one worker handling that decision at a time. Preserve the association and the last known feedback ID when the worker handles an outcome. If a call’s result is ambiguous, reconcile the stored receipt with feedback on the root before retrying. A retry that creates a second entry can make the same draft appear twice in a count of feedback records. For the three-row exercise you can inspect every entry by hand and keep the report at one row per draft.
If the delivery call succeeds and the rejection call fails, you already have two separate facts to investigate. The Friday root should show the receipt from the first call, and the application review record should still identify the address-change rejection. Inspect the address-change root before retrying its call. Once you have reconciled the failure, check both roots again. Repeating the entire table after the error would submit the delivery write again even though its receipt was already accounted for.
Verify each root before counting outcomes
- Reopen each of the three roots using the saved UUID. Match the task, batch and draft version before reading its feedback. Check the two score-and-receipt pairs against the review records in the table.
- In the search-bar experience, use
feedback.support_draft_sent:*in Root run scope to check for the key. For an individual trace useid:<saved-root-uuid> AND feedback.support_draft_sent:*, replacing the bracketed placeholder with the actual UUID. Inspect the actual score and receipt on that root. For the pending row, first find the trace by ID alone, then confirm the key is absent. - Check for feedback attached below the root if the expected key is missing. Open the exact trace and enter
feedback.support_draft_sent:*in Filter runs. Read the highlighted runs in their hierarchy. A hit on a child is a cue to inspect the writer’s target ID.
A presence filter matches a key regardless of its score. That is useful for checking a rejected draft because a numeric 0 is present and meaningful. In a local report, distinguish the missing value from zero explicitly. A truthiness check on the score would make them look alike. Read the child and root independently. A child can have its own feedback within the same trace, and the LangSmith search scopes can match anywhere in the tree or only at the root. LangChain’s trace filter syntax and scope documentation
| What you see | What to inspect | How to interpret it |
|---|---|---|
| No trace appears by the printed ID | Workspace, agent identifier, Staging selector and the trace time range | The draft trace itself is unverified. Check that tracing was enabled and look for an override that routed it elsewhere. |
| Correct root exists, but terminal feedback is absent | Writer output, exact support_draft_sent spelling and the review receipt |
Check whether the staging write was enabled and whether the call returned an error. The review record still supplies the known terminal decision. |
| Feedback appears only on a child | The highlighted child in Filter runs and the ID carried into run_id |
The decision is misattributed for a root-level report. Compare the stored ID with the one on the original draft root. |
| The writer reports a changed session | Compare the saved session UUID, resolved UUID and Staging tracing project ID in the UI | Stop and repair the routing configuration. Keep any draft associated with a different project out of this fixture. |
| The root has two entries or the wrong receipt | Both feedback entries and their IDs, and the application’s immutable version and decision records | Exclude the affected fixture batch from reporting until the discrepancy is accounted for. |
The absence check uses two observations. You can see the pending root and match its draft input, and that root has no entry under the key. If the ID query itself returns nothing, a query that adds the feedback condition also returns nothing. That gives you no evidence about pending. Start with the positive trace lookup so the absence has a known place to inspect.
You can verify the score and still fail attribution. Imagine you find one root with 1 and another with 0 but discover that send-demo-101 is attached to the address-change response. The percentages could still look correct, while any investigation that starts from the rejected trace would open the wrong execution. Sign off each root using the draft version, key, numeric score and receipt together. The pending row gets its own sign-off after you locate the return-window root and inspect its feedback. The aggregate is calculated after those three checks.
Report send rate alongside coverage
- Use the three draft versions from the creation record as the cohort. Count a draft as resolved in this report when its terminal feedback and matching review receipt have been verified.
- Count one sent and one rejected draft, so the illustrative send rate among resolved drafts is 1/2 = 50%. Use both terminal outcomes in the denominator.
- Count two verified terminal outcomes among three created draft versions, so illustrative outcome coverage is 2/3 = 66.7%, rounded to one decimal. Report the remaining pending draft explicitly.
The two percentages answer different questions. Fifty percent tells you what happened among the drafts with verified decisions. Coverage tells you how much of the cohort had a verified decision at the time you looked. If the pending reply is later sent and verified, the figures for the same cohort become two of three sent and three of three covered. If it is rejected, the figures become one of three sent and three of three covered. At the current cutoff, both futures are possible, and there is no third score to average in.
Set the reporting cutoff before comparing cohorts. For example, compare drafts created within each test window at the same age after creation. A newer group may have received replies on its easiest reviews first and show a higher resolved send rate while most decisions are still outstanding. Reporting coverage beside the rate makes that gap visible. Even at equal coverage, review order can differ across cohorts, so use the underlying counts and review timestamps when interpreting the comparison.
A missing write on a known rejection and a genuinely pending review both reduce coverage, but they call for different follow-up. If the address-change receipt exists in the application and the writer skipped it, the missing score is an instrumentation discrepancy. Counting only the verified delivery would show a provisional one send among one verified terminal outcome, with coverage down to one of three. Suspend the comparison until you reconcile the rejected row. For the return-window draft, the application still has no decision to reconcile. Wait for a terminal review record and then verify the write at the next cutoff.
A verified outcome gives you a case to investigate. On the rejected address-change draft, open the execution to see what evidence the agent had for saying the address had already changed. A regression test would need separately defined expected behavior, such as requiring confirmed state before making that claim. Historical feedback helps you choose the case. A curated evaluation provides the rules for checking a proposed fix. LangSmith evaluation types · LangSmith Backtesting for a Wrong Order Lookup
Disable the writer and isolate suspect feedback
- Stop supplying
enabled=True. For a staging worker, disable its feedback-writing entry point and keep the authoritative review records available for reconciliation. Demonstrate the disabled path withrecord_review(rows, "draft-sent-v1"), which printswriter disabledbefore reaching the SDK write. - Use the root-scoped
id:andfeedback.support_draft_sent:*filters to isolate the affected roots. Use Filter runs to identify any misplaced child feedback. Keep the suspect batch out of the report and record the offending run, expected run, receipt and any feedback ID you captured. - Replay the authoritative fixture dispositions into a fresh verified fixture batch. If you are reconciling an actual draft whose intended root has an empty baseline, the documented create operation can attach the verified decision there after you have isolated the wrong attachment. Keep the affected cohort excluded until you can reconcile both sides.
Suppose reject-demo-102 appears on the return-window root. A root presence filter now matches that root, but its input says draft-pending-v1 and the receipt belongs to draft-rejected-v1. The wrong association survives a score edit. Isolate the offending entry with its run and feedback IDs and mark the current batch as failed. The documented creation and filtering operations support isolation and clean replay. For in-place cleanup, consult the official SDK reference for the installed version and confirm the update or delete signature and requirements before attempting the operation. SDK feedback guide · Filter traces
For the clean replay, retain the new batch UUID and its new root IDs with the report. Verify the empty baseline again, then verify both scores and the pending root. Filtering an entire staging project by support_draft_sent can include an old exercise under the same key. Your report’s membership comes from the exact three draft versions in the selected batch and the roots captured for those versions. The failed batch remains evidence of the attribution problem. Its entries stay outside the replay’s numerator and denominator.
The fixture’s recovery ends with three identifiable roots whose outputs match their drafts, two feedback records whose receipts and scores match the review table, and one pending root with no entry under the outcome key. In an integration, that proof lets you trace a displayed number back through a decision receipt to the exact execution. Use the decision record when a reviewer’s operational action matters, and preserve the original execution for later investigation. Annotation and approval · AgentOps · Execution evidence and replay · Agent evaluation gates in CI
Sources
- LangChain — Toward goal-oriented agent improvement with LangSmith Engine
- LangChain — Log user feedback using the SDK
- LangChain — Filter traces
- LangChain — Evaluation types
- LangChain — Resolve an agent environment
- LangChain — Log traces to an agent
- LangChain — Migrate feedback and sharing methods to SmithDB

