Improve LangSmith trace coverage - #2127
Conversation
❌ Sync Manifest Validation FailedThis PR modifies files that should be synced to consumer repos, Required action: Update Why this mattersFiles not declared in the manifest won't be synced to consumer repos How to fix
See the workflow logs for specific files that need to be added. |
Workflow source neededPR #2127 needs either a linked GitHub issue or one valid non-issue Workflow Source before PR metadata automation can manage it safely. Please do one of:
Once a valid source is present, this warning will not be reposted. |
Automated Status SummaryHead SHA: 12d8c98
Coverage Overview
Coverage Trend
Top Coverage Hotspots (lowest coverage)
Updated automatically; will refresh on subsequent CI/Docker completions. Keepalive checklistScopeNo scope information available Tasks
Acceptance criteria
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d89d3e0e97
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| except Exception as first_exc: | ||
| try: | ||
| response = runnable.invoke(payload) | ||
| except Exception: |
There was a problem hiding this comment.
Retry without config only on signature incompatibility
invoke_with_trace retries every failed runnable.invoke(..., config=...) call without config, regardless of why the first call failed. That means transient/provider errors (timeouts, auth/rate-limit failures, upstream 5xx) trigger a second LLM request unnecessarily, increasing latency/cost and potentially worsening rate limiting for every failed operation. Limit the fallback retry to incompatibility errors (for example a TypeError about an unexpected config argument) so real invocation failures are not duplicated.
Useful? React with 👍 / 👎.
|
Runner dispatch state for codex on PR #2127. Do not edit. |
|
Runner dispatch state for autofix on PR #2127. Do not edit. |
There was a problem hiding this comment.
Pull request overview
This PR threads LangSmith trace metadata through the LangChain script entry points (issue formatter, context extractor, task decomposer, task validator, topic splitter, structured-output repair) by introducing a shared trace_utils helper, records the format-step trace IDs/URLs in auto-pilot metrics with sanitized env exports, gates LANGCHAIN_TRACING_V2 on LANGSMITH_API_KEY availability, deduplicates verifier trace coverage by run key while keeping URL-only traces countable, and adds dashboard diagnostics for the LangSmith metrics workflow. Consumer template files and the sync manifest are updated in lockstep.
Changes:
- New
scripts/langchain/trace_utils.py(and template copy) plus wiring in formatter/extractor/decomposer/validator/topic-splitter/structured-output to capture and propagate trace IDs/URLs. - Auto-pilot workflow: gate tracing on the secret, sanitize trace env exports, surface format-step trace metadata to the metrics step.
- Aggregate metrics: dedupe verifier LangSmith trace coverage by run key while still counting URL-only traces; LangSmith dashboard workflow gains diagnostics output and an artifact.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/langchain/trace_utils.py | New shared LangSmith trace helper used by all LangChain entry points. |
| scripts/langchain/issue_formatter.py | Wires invoke_with_trace, returns trace metadata in result. |
| scripts/langchain/context_extractor.py | Same trace wiring for context extraction path. |
| scripts/langchain/task_decomposer.py | Trace wiring + propagates trace dict in result. |
| scripts/langchain/task_validator.py | Adds trace fields to ValidationResult and refine fates. |
| scripts/langchain/topic_splitter.py | Logs LangSmith trace URL when available. |
| scripts/langchain/structured_output.py | Repair callback now uses invoke_with_trace; refactors loop and clamps repair attempts. |
| scripts/aggregate_agent_metrics.py | Dedupes verifier trace refs by run key, keeps URL-only counting. |
| .github/workflows/agents-auto-pilot.yml | Gates tracing on secret; exports format-step trace IDs/URLs into metrics. |
| .github/workflows/maint-80-langsmith-metrics-dashboard.yml | Adds diagnostics file/artifact and run/artifact counters. |
| .github/sync-manifest.yml | Registers new trace_utils.py and task_validator.py consumer scripts. |
| templates/consumer-repo/... (multiple) | Mirrors the above changes to the consumer template. |
| tests/scripts/test_trace_utils.py | New unit tests for invoke_with_trace. |
| tests/scripts/test_issue_formatter.py | Asserts trace ID is propagated through formatter. |
| tests/scripts/test_task_validator.py | Adds trace-shape assertion for empty refinement. |
| tests/scripts/test_aggregate_agent_metrics.py | Verifies run-key dedup of verifier trace coverage. |
| try: | ||
| response = runnable.invoke(payload, config=config) | ||
| except Exception as first_exc: | ||
| try: | ||
| response = runnable.invoke(payload) | ||
| except Exception: | ||
| raise first_exc |
| try: | ||
| response = runnable.invoke(payload, config=config) | ||
| except Exception as first_exc: | ||
| try: | ||
| response = runnable.invoke(payload) | ||
| except Exception: | ||
| raise first_exc |
Summary
Validation
Notes