Skip to content

feat(code): show conversation turns alongside message counts - #5571

Merged
Mason Daugherty (mdrxy) merged 6 commits into
mainfrom
mdrxy/code/offload-turn-counts
Aug 18, 2026
Merged

feat(code): show conversation turns alongside message counts#5571
Mason Daugherty (mdrxy) merged 6 commits into
mainfrom
mdrxy/code/offload-turn-counts

Conversation

@mdrxy

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

Copy link
Copy Markdown
Member

/offload feedback and the Debug Console now show conversation turns together with raw message counts.


Message counts are hard to interpret. One user prompt can become several provider messages (a tool call, a tool result, and a follow-up model turn), and the count changes from provider to provider. Conversation turns — the user prompts the model actually saw — do not change between providers. This makes them a better unit for comparing offloads.

Changes:

  • The offload report now shows both units, for example Offloaded 4 older messages (2 conversation turns) and 6 messages (3 conversation turns) kept. The turn count excludes internal human messages (goal-state notices and [SYSTEM] interruptions) that collect below the cutoff.
  • The Debug Console Messages field shows N messages (M rendered), K turns, with correct singular and plural labels.
  • The new MessageStore.turn_count property counts USER and SKILL rows. A /skill invocation creates one SKILL row instead of a USER row, so each skill use counts as one turn. It counts all rendered rows, including local-only flows such as !shell and most slash commands. That is a broader set than the offload report's turn count, which comes from graph state; the property's docstring describes the difference.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@github-actions github-actions Bot added dcode Related to `deepagents-code` feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: M 200-499 LOC labels Aug 18, 2026

@open-swe open-swe Bot left a comment

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.

✅ Open SWE Review: No issues found

Open SWE reviewed this PR and found no potential bugs to report.

Open in WebView Open SWE trace

The re-offload assertion stopped before the turn parenthetical, so
`turns_offloaded` never exercised a non-zero `prior_cutoff`: slicing
`before_messages[:new_cutoff]` instead of `[prior_cutoff:new_cutoff]`
passed the whole suite while re-reporting turns that a previous
`/offload` had already archived. Anchor that assertion on the
parenthetical and add the kept-slice counterpart.

Also cover the branches no test rendered: a singular kept message, a
zero-turn offloaded slice, a zero-turn kept slice, singular and
mixed-plurality Debug Console labels, and `turn_count` parametrized
over every `MessageType` so a new enum member fails loudly.

The Debug Console liveness test recomputed the production ternaries,
so it agreed with itself; it now asserts a literal string.

Drop the duplicated cutoff comment (the surviving copy said "Message
counts" where both message and turn counts are derived) and the dead
`total == 0` branch, which returned a string byte-identical to the
fall-through. Correct the `turn_count` docstring: it spans the store
rather than the rendered window, `APP` is app-authored rather than
agent-authored, and the cross-module pointer to a private constant in
`app.py` invited the opposite conclusion about `SKILL`.
@github-actions github-actions Bot added size: L 500-999 LOC and removed size: M 200-499 LOC labels Aug 18, 2026
Conflict in `test_build_snapshot_message_count_reports_rendered_window`:
main's #5479 replaced the mounted-window expectation with
`min(INITIAL_WINDOW_SIZE, WINDOW_SIZE)` while this branch changed the
same assertion's string to carry turn counts. Both sides were needed,
so the resolution keeps main's `rendered` computation inside this
branch's `"N messages (M rendered), K turns"` format.

Main also added `MessageType.TOOL_GROUP`, which the new parametrized
`turn_count` test flagged on contact -- the enum-drift guard behaving
as intended. `TOOL_GROUP` is agent-authored, so it stays outside the
counted set; the case only needed `tool_group_messages` to construct.

`test_footers_render_for_hydrated_messages_above` fails on this merge,
but it fails identically on clean origin/main (verified by swapping in
main's copies of both source files), so it is pre-existing and
unrelated to these counts.
@mdrxy
Mason Daugherty (mdrxy) merged commit 3dd4fe5 into main Aug 18, 2026
53 of 56 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the mdrxy/code/offload-turn-counts branch August 18, 2026 03:17
Mason Daugherty (mdrxy) pushed a commit that referenced this pull request Aug 18, 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.57](deepagents-code==0.1.56...deepagents-code==0.1.57)
(2026-08-18)

### Features

- Added warnings before expensive cold-cache turns and trust
user-declared endpoints for cold-cache policies
([#5439](#5439),
[#5462](#5462)).
- Made the chat input resizable by dragging its top border
([#5524](#5524)).
- Added a `multi_select` question type to `ask_user`
([#5097](#5097)).
- Added support for ACP approval modes
([#5394](#5394)).
- Added `DeepSeek-V4-Pro-0813` to the model picker
([#5512](#5512)).
- Show conversation turns alongside message counts
([#5571](#5571)).
- Include `TERM_PROGRAM` in the resume hint
([#5548](#5548)).

### Bug Fixes

- Report total context after `/offload`
([#5488](#5488)).
- Fixed transcript and thread restoration issues, including hydration
lag, scrolling resumed threads to the bottom, and hiding empty
previous-thread hints
([#5479](#5479),
[#5543](#5543),
[#5552](#5552)).
- Fixed Auto-mode approval handling by binding “yes” to the paired
`ask_user` question and avoiding duplicate Auto denial notices
([#5038](#5038),
[#5501](#5501)).
- Improved reload behavior by keeping the chat input responsive during
`/reload`, reporting MCP server changes, and avoiding plugin reload
prompt flashes or startup hints
([#5529](#5529),
[#5504](#5504),
[#5500](#5500),
[#5502](#5502)).
- Improved dependency update UI by preserving editable fields and hiding
dependency details after updates
([#5521](#5521),
[#5519](#5519)).
- Fixed chat UI polish issues, including detached spacer mount anchors,
the unfocused input cursor, and relative timestamp toggle display
([#5516](#5516),
[#5258](#5258),
[#5503](#5503)).
- Refresh the splash version after updates
([#5520](#5520)).

_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` feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: L 500-999 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant