Skip to content

fix(code): group resume trace rounds - #5593

Merged
Mason Daugherty (mdrxy) merged 4 commits into
mainfrom
mdrxy/code/group-resume-traces
Aug 18, 2026
Merged

fix(code): group resume trace rounds#5593
Mason Daugherty (mdrxy) merged 4 commits into
mainfrom
mdrxy/code/group-resume-traces

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Aug 18, 2026

Copy link
Copy Markdown
Member

Deep Agents Code now marks every approval-interrupt continuation as part of the same user turn, making long auto-approval sessions readable and groupable in LangSmith.


Before

A single user prompt can pause many times while tools pass through approval checks. After each approval, dcode resumes the LangGraph checkpoint with a new Agent Server request. LangSmith recorded every resume request as a separate root trace, so one turn with 30 approval checks looked like 30 independent traces with nearly identical conversation inputs—even though the graph was advancing normally by one step each time.

After

The initial run of a turn is unchanged and stays untagged. Every later Command(resume=...) request is tagged dcode:resume and reuses the turn's config, so it keeps the same thread_id, turn_id, and turn_number as the original run. LangSmith views and cost reports can therefore filter and group those sibling roots as one logical user turn.

stream_trace_config(config, stream_input) makes that decision in one place; each call site passes its stream input and the helper tags only Command inputs.

This applies to interactive TUI runs, headless runs, and internal /offload resumes. It does not change approval or classifier decisions, model inputs, prompt caching, checkpoint frequency, or graph execution semantics.

Scope and caveats

  • /offload groups by thread_id only. It builds a thread-only config instead of going through build_stream_config, so its rounds carry no turn_id/turn_number. The tag is its only resume marker.
  • The tag is inheritable. LangGraph unions tags onto child configs, so pair it with an is_root filter to select resume roots alone.
  • Nothing in this repository reads dcode:resume. The consumer is LangSmith, so the literal string is an external contract — renaming it breaks saved views and filters. This is recorded next to the constant.

Made by Open SWE

References

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@github-actions github-actions Bot added dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: S 50-199 LOC labels Aug 18, 2026
@mdrxy
Mason Daugherty (mdrxy) marked this pull request as ready for review August 18, 2026 15:18
Replace `resume_trace_config(config)` with `stream_trace_config(config,
stream_input)`, which decides internally whether the round is a resume. The
`isinstance(stream_input, Command)` ternary was duplicated verbatim at all
three call sites; folding it in leaves one shared branch to test.

Correct the docstrings. The old text claimed the parameter was the stream
config shared across a user turn, which is false on the `/offload` path --
`DeepAgentsApp._offload` passes a thread-only config that never goes through
`build_stream_config`, so those rounds carry no `turn_id`/`turn_number` and
group by `thread_id` alone. Also record that LangGraph unions `tags` onto every
child config, so the tag reaches descendant runs and must be paired with an
`is_root` filter to select resume roots, and that the shallow copy shares
`metadata`/`configurable` by reference.

Document what consumes `RESUME_TRACE_TAG`. Nothing in this repository reads it,
so without a note the literal is indistinguishable from dead code.

Cover the two call sites that had none: the headless loop and the `/offload`
compaction driver both now assert the initial round is untagged, later rounds
are tagged, and the base config is never tagged in place. Add a boundary test
for `_prepare_config`, which every config crosses before reaching the server --
narrowing it to a whitelist would drop `tags` and make grouping a silent no-op
with its own tests still green.

Replace two assertions that pinned implementation over behavior: metadata dict
identity (an artifact of `dict.copy()`) and an exact-match on a tag list that
happens to be empty today.
@github-actions github-actions Bot added size: M 200-499 LOC and removed size: S 50-199 LOC labels Aug 18, 2026
@mdrxy
Mason Daugherty (mdrxy) merged commit 345859e into main Aug 18, 2026
95 of 98 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the mdrxy/code/group-resume-traces branch August 18, 2026 16:33
Mason Daugherty (mdrxy) pushed a commit that referenced this pull request Aug 19, 2026
> [!CAUTION]
> Merging this PR will automatically publish to **PyPI** and create a
**GitHub release**.

For the full release process, see
[`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md).

---

_Release notes preview: keep this section in sync with the package
`CHANGELOG.md`. Publish reads the merged CHANGELOG via `release.yml`,
not this PR description — keep them aligned anyway so the PR stays an
accurate historical record for reviewers and anyone returning later._

---


##
[0.1.58](deepagents-code==0.1.57...deepagents-code==0.1.58)
(2026-08-19)

### Breaking Changes

- `deepagents-code` now requires Python 3.12 or newer.
([#5603](#5603))

### Features

- Added OpenRouter `z-ai/glm-5.3` to the model switcher.
([#5641](#5641))
- Added support for re-authenticating MCP servers from the viewer.
([#5637](#5637))
- Footer pickers can now be opened with `ctrl+click`.
([#5611](#5611))
- Resume hints now account for `TERM_PROGRAM` support before showing
terminal-specific guidance.
([#5580](#5580))

### Fixes

- Completed the `dcode config` command surface.
([#5581](#5581))
- Made `/offload` interruptible.
([#5590](#5590))
- Improved chat and footer UI behavior: rapid typing stays visible,
double-click collapses a resized chat input, and the MCP footer wraps on
narrow windows.
([#5424](#5424),
[#5578](#5578),
[#5651](#5651))
- Captured stdio MCP server stderr in the logger.
([#5610](#5610))
- Drained hook pipes after timeout.
([#5606](#5606))
- Grouped resume trace rounds.
([#5593](#5593))
- Omitted web-search prompt guidance when web search is unavailable.
([#5602](#5602))
- Resolved message pointer shapes per cell.
([#5592](#5592))

_End release notes preview._

---

> [!NOTE]
> A **community contributors** list and a **Special thanks** section
(crediting the users who filed the issues this release's PRs closed) are
appended to the GitHub release notes automatically at publish time (see
[Release
Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline),
step 3).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: langchain-oss-automated-triage[bot] <248757908+langchain-oss-automated-triage[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant