Skip to content

feat(sdk): add langwatch config to ScenarioConfig for race-condition-free multi-tenant runs#545

Open
drewdrewthis wants to merge 1 commit into
mainfrom
issue203/programmatic-langwatch-config
Open

feat(sdk): add langwatch config to ScenarioConfig for race-condition-free multi-tenant runs#545
drewdrewthis wants to merge 1 commit into
mainfrom
issue203/programmatic-langwatch-config

Conversation

@drewdrewthis
Copy link
Copy Markdown
Collaborator

Summary

  • Adds optional langwatch field to ScenarioConfig that takes precedence over env vars
  • Eliminates the mutex-guarded process.env mutation pattern required for concurrent multi-tenant scenario execution
  • Priority chain: options.langwatch > cfg.langwatch > LANGWATCH_* env vars
  • Moves LangwatchConfig type to the domain layer (avoids circular import)
  • Adds target: ES2022 to tsconfig to support top-level await in test files

Before:

// Race condition! Must serialize concurrent runs
process.env.LANGWATCH_API_KEY = project.apiKey;
await run({ name, agents, ... });

After:

// Safe for concurrent multi-tenant execution
await run({ name, agents, langwatch: { apiKey: project.apiKey }, ... });

Test plan

  • pnpm typecheck — clean
  • 20 unit tests pass including 2 new tests:
    • cfg.langwatch used when no options provided
    • options.langwatch takes priority over cfg.langwatch

Closes #203

🤖 Generated with Claude Code

…free multi-tenant runs (#203) [grinder]

ScenarioConfig now accepts an optional `langwatch` field that takes precedence
over env vars, eliminating the need to mutate process.env before each run
when running scenarios concurrently for different projects.

Priority chain: options.langwatch > cfg.langwatch > LANGWATCH_* env vars.

Also moves LangwatchConfig type definition to the domain layer (no circular deps)
and adds target: ES2022 to tsconfig to support top-level await in test files.

Closes #203

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@drewdrewthis drewdrewthis added the grinding Grinder is actively managing this PR label May 25, 2026
@github-actions github-actions Bot added the low-risk-change PR qualifies as low-risk per policy and can be merged without manual review label May 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Automated low-risk assessment

This PR was evaluated against the repository's Low-Risk Pull Requests procedure.

  • Scope: Adds LangwatchConfig and a langwatch?: LangwatchConfig on ScenarioConfig, changes EventBus construction to prefer options.langwatch then cfg.langwatch then env vars, moves the LangwatchConfig type to the domain layer, updates tsconfig target to ES2022, and adds unit tests.
  • Exclusions confirmed: no changes to auth, security settings, database schema, business-critical logic, or external integrations.
  • Classification: low-risk-change under the documented policy.

The changes are limited to adding a LangwatchConfig type and an optional langwatch field on ScenarioConfig, updating the precedence when constructing the existing EventBus (options > cfg > env), moving the type to the domain layer, a tsconfig target bump, and adding tests. It does not modify authentication/authorization logic, database schemas, business‑critical calculations, or change the external API integration itself (only how credentials/config are provided), so it fits the low‑risk criteria. The tsconfig change is a build/test config tweak and the other edits are straightforward and easily reversible.

An approving review has been submitted by automation. The PR may merge once required CI checks pass.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Approved by automation: PR qualifies as low-risk-change under the documented policy.

@drewdrewthis drewdrewthis added pr-ready and removed low-risk-change PR qualifies as low-risk per policy and can be merged without manual review grinding Grinder is actively managing this PR labels May 25, 2026
@drewdrewthis
Copy link
Copy Markdown
Collaborator Author

[grinder] READY for human review

CI: green (zero failing, zero pending)
Review: APPROVED by automation (low-risk-change policy)
Threads: zero unresolved

Verified by:
`command gh pr checks 545` → all pass: ci-checks (24.x) pass, javascript-complete pass, python-complete pass
`command gh pr view 545 --json reviewDecision` → "APPROVED"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add programmatic langwatch config to ScenarioConfig (remove env var dependency)

1 participant