Skip to content

Support LangSmith agent destinations and replica routing in TypeScript - #314

Merged
patbeqo merged 2 commits into
mainfrom
codex/langsmith-typescript-destinations
Nov 9, 2026
Merged

patbeqo merged 2 commits into
mainfrom
codex/langsmith-typescript-destinations

Conversation

@brianstrauch

Copy link
Copy Markdown
Member

Add agent/environment destinations and write replicas to the TypeScript LangSmith integration. An optional address is mutually exclusive with projectName; destinations and sanitized replica routing follow traces through Activities, child Workflows, and Nexus, including with addTemporalRuns: false. Credentials and client objects stay local to each process.

Make native RunTree construction and writes replay-safe with installRunTreeOverrides, scoped to Workflow handlers. Roots remain real roots, and LangSmith retains child creation, destination inheritance, and replica serialization. IDs use the existing independent random stream, timestamps use Workflow time, and writes use Worker sinks with replay suppression. Read-only handlers use the unsafe random source without advancing the recorded stream.

TypeScript companion to #115. Agent addressing requires LangSmith 0.10.8 or later within the supported peer range and the workspace-enabled LangSmith beta.

Validation on Node 24.22.1 / LangSmith 0.10.8:

  • Lint and the full 131-test suite pass; focused replay/routing checks and the final native-run regression pass after the final adjustments.
  • Fresh-worker replay compares native IDs, timestamps, parent links, and dotted ordering and emits no duplicate writes. Tests cover asynchronous input processing, native destination validation, replicas, and forced cache eviction.
  • Package build/content checks, clean-consumer import, and repository conventions pass.

@brianstrauch
brianstrauch marked this pull request as ready for review October 30, 2026 20:41
@brianstrauch
brianstrauch requested a review from a team as a code owner October 30, 2026 20:41
@brianstrauch
brianstrauch requested a review from patbeqo November 2, 2026 22:47
// No propagated parent: run the body with no ambient run by design (nothing to attach to).
return parent ? withRunTree(parent, () => next(input)) : next(input);
// Without a parent, an invisible factory supplies defaults to independent root traceables.
return withRunTree(parent ?? rootRunTree(config), () => next(input));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's no parent, can this just default to the plugin's destination like Python, without a placeholder root?

@brianstrauch
brianstrauch requested a review from patbeqo November 3, 2026 17:11
@patbeqo
patbeqo merged commit db2c5e1 into main Nov 9, 2026
15 checks passed
@patbeqo
patbeqo deleted the codex/langsmith-typescript-destinations branch November 9, 2026 20:39
patbeqo added a commit that referenced this pull request Nov 13, 2026
Follow-up to #314. Brings the TypeScript LangSmith plugin in line with
the Python plugin.

## What changed

- **Same runs as Python.** Plugin runs record no Temporal arguments or
results, end with `{status}`, and treat continue-as-new and cancellation
as statuses, not errors. Errors read `ClassName: message`, and Nexus
handler runs are `tool` runs.
- **Same trace shape.** Client markers span their call and record its
error. Update-with-start propagates to the update, signals nest beside
their marker, and runs carry Temporal ID metadata and the plugin's tags.
Metadata is no longer scrubbed.
- **Replay-safe IDs and times.** Workflow run IDs are UUIDv7 from
Workflow time and the plugin's random stream; queries and validators get
random IDs. Start and end times come from the Worker's clock when live.
- **Ordered, logged writes.** An update can't reach LangSmith before its
create, and failed writes are logged.
- **ESM Workflows are traced.** `langsmith` imports in the Workflow
bundle resolve to the patched CommonJS build.
- **A propagated parent keeps tracing on** when `LANGSMITH_TRACING` is
off, like Python.
- **Fails loudly when LangSmith changes.** Worker setup fails if a
patched `RunTree` method is missing.

Plugin run inputs no longer include Temporal arguments, which changes
what existing users see in LangSmith.

## Not in this PR

- `langsmith` 0.11 support. The `address` option breaks on 0.11 and
needs its own change.
- LangChain and LangGraph inside Workflows, until a TypeScript LangGraph
plugin exists.

## Testing

- `pnpm run lint` and `pnpm test` pass (176 tests).
- Each new test fails when its change is reverted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants