Skip to content

ENG-742: Count turns without tools-calls - #262

Merged
ea-rus merged 1 commit into
stagingfrom
feat/eng-742-save-tool-calls
Jul 22, 2026
Merged

ENG-742: Count turns without tools-calls#262
ea-rus merged 1 commit into
stagingfrom
feat/eng-742-save-tool-calls

Conversation

@ea-rus

@ea-rus ea-rus commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Continue of mindsdb/cowork-server#203

Problem

_turn_count is seeded by counting role == "user" messages in history
(session.py, commands/session.py, memory/history_store.py). Once a host
replays tool activity into history, tool_result messages — which are also
role == "user" — get counted as turns. Every tool call inflates the count,
and the drift compounds as the session is rebuilt each turn.

Impact: the "every 5 turns" identity extraction misfires, telemetry/episodic
turn IDs are wrong, and resume/list show inflated turn totals.

Fix

Add is_user_turn(message) in history_store.py: a user-role message whose
content is only tool_result blocks is a tool reply, not a turn. Replace all
three naive counts with it.

  • One shared helper, no duplicated predicate.
  • Backward compatible: histories without tool_result count unchanged.

Fixes https://linear.app/mindsdb/issue/ENG-742/cowork-tool-calls-are-not-stored-in-conversation-history

@ea-rus
ea-rus requested a review from StpMax July 21, 2026 15:44
@ea-rus
ea-rus merged commit 9382bac into staging Jul 22, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 22, 2026
@ea-rus
ea-rus deleted the feat/eng-742-save-tool-calls branch July 23, 2026 09:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants