Files
deepagents/libs/code/deepagents_code
Hari Harish cb39747480 feat(code): adopt coding-agent-v1 trace metadata (#4367)
**Why this is needed**
LangSmith groups and filters coding-agent traces by a standard set of
metadata keys — the agent, its version, the conversation turn, and the
repo it ran in. Deep Agents Code didn't emit them, so its traces were
the odd one out: you
couldn't line them up against the other coding agents in dashboards or
evals.

**What this does**
Deep Agents Code now stamps the shared coding-agent-v1 metadata contract
on its LangSmith traces, using the same stable keys as the other
integrations. Each trace now reliably records what agent and version
produced it, which user turn it belongs to, and the repo/git/cwd it ran
in.

**Changes (all in `libs/code`)**
- New `_git.py`: resolves the commit SHA, remote URL, and parsed repo
metadata (provider/name).
- `config.py`: a single `build_coding_agent_metadata()` helper wired
into `build_stream_config`; mirrors `thread_id` to top-level metadata
and keeps existing keys.
- Turn markers (`turn_id` + 1-based `turn_number`) tracked on session
state and passed through the interactive and non-interactive paths.
- Tests for the git helpers, turn markers, and a contract test
validating the metadata block against the vendored coding-agent-v1
validator.

**Known limitation**
On `chat_model` / `create_agent` runs, LangChain core overwrites
`ls_integration` with its own value, so per-run `ls_integration` isn't
`deepagents-code` there. Traces stay identifiable via
`ls_agent_kind="coding_agent"` and root-level `ls_integration`.

**How I verified**
Verified on a [live
trace](https://smith.langchain.com/o/ebbaf2eb-769b-4505-aca2-d11de10372a4/projects/p/32d59ccd-86a1-447c-8a6d-53ee4f75ce62?timeModel=%7B%22duration%22%3A%2230d%22%7D&peek=20260623T212320Z019ef65d-bf93-7450-9690-e0e4c72e09d0&peekedConversationId=019ef65c-5012-7521-a536-725278301be0&trace_id=019ef65d-bf93-7450-9690-e0e4c72e09d0&run_id=20260623T212320Z019ef65d-bf93-7450-9690-e0e4c72e09d0&peeked_trace=20260623T212320288794Z019ef65d-bf93-7450-9690-e0e4c72e09d0&conversationTab=trace&scroll_to=feedback)
— all required keys present per run type.

---

Fixes LSEN-307

---------

Co-authored-by: Mason Daugherty <github@mdrxy.com>
Co-authored-by: Mason Daugherty <mason@langchain.dev>
2026-06-29 16:41:01 -04:00
..
2026-04-29 20:15:08 -04:00