groundy
Agents & Frameworks

How to Preserve Code Provenance Across LangGraph Agent Handoffs

LangGraph handoffs require a manifest linking revisions, agents, and tests to preserve code provenance, as traces alone lack integrity and execution evidence.

Published 7 references
On this page7 sections

Preserve code provenance by making every LangGraph handoff produce a record that a chat view cannot supply: the input revision; agent identity and version; model and prompt versions; tool side effects; patch or artifact identifiers; test-run references; and human approval. Store that manifest in source control or an event log, with accepted history protected from agent rewrites, link it to the LangSmith trace and CI run, and enforce high-stakes approvals and independent execution recording outside the agent host. A final diff then has a resolvable chain back to its inputs and tests, rather than relying on a plausible transcript.

The record has to join three evidence types: trace context, artifact provenance, and independently enforced controls. LangSmith can contribute the first, but LangChain’s LangGraph tracing documentation explicitly leaves coverage dependent on instrumentation and describes its Trajectory view as a simplified conversation history. The design below treats the handoff, rather than the whole conversation, as the unit that must connect an agent’s work to a specific code change.

What LangSmith records at a LangGraph handoff

LangSmith integrates with LangGraph in Python and JavaScript, whether the nodes use LangChain modules or other SDKs. That makes it a useful place to locate and inspect execution. It does not make instrumentation automatic for everything a node does.

The same documentation says custom functions and other SDKs must be wrapped or decorated to have their traces nested automatically. It names @traceable in Python, traceable in JavaScript, and wrappers such as wrap_openai as examples. An unwrapped helper can therefore sit outside the nested trace even though it participated in the work. Trace coverage is a property of what you instrumented, not a guarantee conferred by drawing the workflow as a graph.

The Trajectory UI has a separate limitation. LangChain describes it as a chat-like rendering of messages from the top-level trace, including the initial request, tool calls, and final response. This does not establish that the underlying trace contains only those messages. It does establish that a clean conversation rendering should not be mistaken for a complete account of execution.

Neither documented capability, by itself, binds an input source revision to an output patch and a CI run. Nor does it account for side effects in custom code that was never wrapped. I would therefore use LangSmith as an index into the handoff: valuable for finding context, insufficient as the sole system of record for generated code.

A convincing transcript can still be wrong

Coverage is not the only problem. Even a detailed trace needs an integrity argument.

In the preprint LLM Agents Can Easily Tamper With Their Own Traces, the authors report that agents can alter their own traces. They advise recording model API exchanges through an independent interception server outside the agent’s host. Their tool-spoofing demonstration also leads to an important qualification: complete coverage requires preventing bypass of that recording and verifying that client-side tool calls executed as reported. An independent API log is stronger evidence than an agent-hosted account, but it still does not prove every local action.

Consider a hypothetical coding handoff with an unwrapped file-editing helper. Three different questions arise:

  1. Coverage: did the helper appear in the trace?
  2. Integrity: could the displayed account have been altered?
  3. Execution: does available evidence show that the helper’s reported writes actually occurred?

A longer transcript answers none of those questions by itself. The first requires instrumentation, the second requires a record outside the agent’s control, and the third requires execution evidence beyond a model request log.

There is also a reason to prioritize coding and testing handoffs. The Shadows in the Code preprint reports IMBIA attack success rates of 93% for ChatDev, 45% for MetaGPT, and 71% for AgentVerse in the scenarios it labels MU-BA. It also reports that malicious infiltration during coding or testing posed significantly higher security risks than infiltration during design.

Those percentages are not LangGraph measurements. ChatDev, MetaGPT, and AgentVerse were evaluated, so the results cannot estimate the probability that your LangGraph pipeline will be compromised. They support spending control effort on coding and testing transitions; they do not support presenting 45–93% as a LangGraph risk range.

The handoff manifest: seven fields to record

The following schema is an implementation synthesis, not a list of fields LangSmith automatically supplies and not a schema validated by the cited studies. It combines the handoff requirements in the practical decision with two research models.

PROV-AGENT extends W3C PROV and incorporates Model Context Protocol concepts to represent agent actions and their relationships to data and workflow tasks. Its authors describe tracing an output back through reasoning, prompts, input data, system context, and execution metadata. The Code as Agent Harness preprint separately defines the evidence an auditable approval should preserve.

At each handoff, record:

  1. Input revision. Identify the exact source state from which the agent started, together with references to any other input artifacts needed to interpret its output. “Latest main” is not a durable revision identification.

  2. Agent identity and version. Identify which agent or graph role acted and which version of its implementation did so. This is the field that lets a patch be attributed to a particular handoff rather than to the multi-agent system as a whole.

  3. Model and prompt versions. Record the model version and prompt or template revision, along with the system-context and execution-metadata references needed to interpret the run. PROV-AGENT supplies the traceability dimensions; it does not prescribe a storage format for them.

  4. Tool side effects. Record reported writes and other state changes, not only the names of tools that were called. Where a side effect matters, link to independent execution evidence rather than treating the agent’s report as confirmation.

  5. Patch or artifact identifiers. Give the output a resolvable identifier and connect it to the input revision. The reviewer should be able to distinguish the artifact produced by this handoff from a later edited or regenerated version.

  6. Test-run references. Link the CI or test run to the artifact it consumed. A passing result without that connection does not establish which generated patch passed.

  7. Human approval. For a high-stakes action, the harness preprint says the record should capture what action was proposed, what evidence was shown, what risks were surfaced, who approved or rejected it, and what responsibility boundary changed afterward. If no human gate is required, record the applicable validation or gate outcome instead of implying that a person approved the change.

These fields make a useful review unit because they connect identities and versions to artifacts. They do not become trustworthy merely because they were generated automatically. A manifest entry containing “tests passed” is still a claim until it resolves to the relevant test run, and a reported file write still needs execution evidence when that distinction matters.

The boundary matrix: navigation, provenance, enforcement

The central design choice is not whether to use traces or source control. It is which kind of evidence each component can reasonably contribute.

LayerPrimary homeEvidence it contributesBoundary that remains
Trace evidenceLangSmith, with explicit wrappers where requiredExecution context for instrumented LangGraph work and a way to navigate requests, tool calls, and responsesUnwrapped custom functions are not automatically nested. The cited documentation does not establish retention, export, field-level coverage, or tamper resistance
Artifact provenanceSource control or an event log, linked to CIInput revision, agent and version context, reported side effects, patch identifiers, and test-run referencesA repository snapshot alone does not supply the sequence of events. Manifest assertions still depend on trustworthy writers and external evidence
Human approvalA review gate linked to the exact manifest and artifactProposed action, evidence and risks shown, decision maker, and responsibility changeA conversational statement of approval is not independent enforcement. The decision must apply to the artifact actually reviewed
Model API evidenceAn interception server outside the agent hostAn independently recorded account of model API exchangesBypass must be prevented, and the exchange log does not prove client-side tool execution
Tool executionCI for applicable test evidence, plus separate verification for client-side toolsEvidence bearing on whether reported execution occurred and which artifact was testedThe tampering preprint explicitly shows why an API request log is insufficient here

This allocation also clarifies what CI cannot do. CI can anchor a test run to an artifact when that reference is recorded properly. It does not, by extension, verify every unrelated client-side tool action in the preceding agent session.

Why an event log can outperform a repository snapshot

A source tree shows the state that survived. Provenance often requires the sequence that produced it.

The ESAA-Security preprint proposes treating the event log, rather than the mutable repository snapshot, as the source of truth. It derives project state through deterministic projection, replay, and verification. Its canonical cycle parses the event store, projects current state, selects the next eligible task, dispatches the agent with purified context, validates output, appends accepted events, rebuilds views, and verifies integrity through replay and hashing.

For a LangGraph pipeline, my implementation inference is to append a manifest event when a handoff output is accepted, then append linked test and approval events as those facts become available. That avoids an awkward requirement to record a CI result before CI has run. A common handoff reference can make the sequence resolvable without forcing every fact into one prematurely completed record.

Source control remains a reasonable candidate for the manifest when the main requirement is to keep revision, patch, tests, and review together. The event-sourced pattern adds a clearer model when you must reconstruct sequences of accepted tasks and outputs. In either design, accepted history needs protection from agent rewrites.

Replay and hashing do not make every original statement true. They support verification of the recorded history and derived state; independent API recording, tool-execution checks, and approval enforcement address different failure modes. That distinction is why an event log complements the boundary matrix rather than replacing it.

Where human gates earn their keep

The evidence does not justify requiring manual approval for every routine handoff. The harness paper defines requirements for high-stakes approvals, while the injection paper supplies a reason to prioritize coding and testing stages.

I would concentrate mandatory human review on high-stakes coding and testing transitions, particularly where generated output will change accepted code or trigger consequential execution. Routine handoffs can use automated validation and artifact linkage, with the gate outcome recorded. That is a deployment judgment, not a threshold measured by the papers.

The reviewer’s starting point should be the manifest rather than the chat. It identifies the base revision, output artifact, test run, reported side effects, and agent and model context; LangSmith can then supply execution context where instrumentation exists. The approval record should preserve the evidence and risks presented to the reviewer and state what responsibility changed. Otherwise, “approved” may establish that someone clicked a control without establishing what they accepted.

Verify product capabilities instead of inferring them

The cited LangChain documentation supports claims about LangGraph integration, explicit wrapping, and the Trajectory rendering. It does not establish LangSmith’s full trace-field availability, retention, export behavior, or tamper resistance. Those are requirements to check against current documentation and your deployment before assigning LangSmith a stronger evidentiary role.

The same restraint applies to OpenHands. Its homepage describes an open source platform for software engineering agents with a GUI, CLI, SDK, and enterprise control plane. It mentions “auditability” as one of the things its enterprise deployment options help control, alongside models, data, and access, but documents no provenance, audit-trail mechanics, or trace-retention capabilities on that page. That absence does not prove OpenHands lacks such capabilities elsewhere, but it cannot support a claim that its control plane provides this manifest, protected history, or independent enforcement. Nothing in the evidence also establishes an OpenHands integration with LangGraph.

Before relying on either product for provenance, verify the exact artifact references available, the audit records and export path, who can rewrite each store, and where approval and execution controls run. Sensitive-code handling remains a separate open question: the evidence here does not establish either exposure from sending code content to a hosted tracing backend or that doing so is safe. If your source cannot leave controlled infrastructure, verify the current backend and data-handling behavior before enabling content capture.

Four of the five research papers cited here are arXiv preprints. PROV-AGENT is the exception: its arXiv page directs readers to cite it as published in the Proceedings of the 21st IEEE International Conference on e-Science (e-Science), Chicago, IL, 2025. Their results were not independently reproduced for this article, and this article characterizes the papers only at the level of their reported findings.

The practical default is nevertheless clear: let LangSmith help you find and inspect a handoff, but make the joined manifest and artifact chain the unit of code review. More conversation detail will not supply the missing provenance.

References

Follow the links in the article for context. The supporting material is collected here for further reading.

  1. LangChain's LangGraph tracing documentationdocs.langchain.comAccessed
  2. LLM Agents Can Easily Tamper With Their Own Tracesarxiv.orgAccessed
  3. Shadows in the Code preprintarxiv.orgAccessed
  4. PROV-AGENTarxiv.orgAccessed
  5. Code as Agent Harness preprintarxiv.orgAccessed
  6. ESAA-Security preprintarxiv.orgAccessed
  7. OpenHands homepageopenhands.devAccessed

Join the discussion

Share a useful perspective or ask a question about this article.

Discussion guidelinesComments privacy