Skip to content

fix(sessions): dedupe subagent IDs across disk paths - #1238

Open
rioyu123 wants to merge 1 commit into
anthropics:mainfrom
rioyu123:codex/dedupe-subagent-ids
Open

fix(sessions): dedupe subagent IDs across disk paths#1238
rioyu123 wants to merge 1 commit into
anthropics:mainfrom
rioyu123:codex/dedupe-subagent-ids

Conversation

@rioyu123

@rioyu123 rioyu123 commented Aug 27, 2026

Copy link
Copy Markdown

Summary

This pull request makes filesystem-backed list_subagents() return each logical agent ID once when the same ID exists under multiple physical subpaths.

  • preserve the first discovery order while deduplicating IDs
  • align the disk helper with list_subagents_from_store() and its TypeScript parity contract
  • document the uniqueness guarantee
  • add regression coverage for a direct transcript plus nested duplicate

Why

Subagent transcripts can exist both directly under subagents/ and under nested workflow directories. The disk helper previously returned duplicate IDs for those paths even though callers can only address a subagent by ID and the store-backed helper already deduplicates them.

The change is intentionally limited to list_subagents(): traversal, exception behavior, get_subagent_messages(), and public signatures remain unchanged.

Test plan

  • pytest tests/test_sessions.py::TestListSubagents tests/test_session_helpers_store.py::TestSubagentsFromStore -q -p no:cacheprovider - 29 passed
  • ruff format --check src/claude_agent_sdk/_internal/sessions.py tests/test_sessions.py
  • ruff check src/claude_agent_sdk/_internal/sessions.py tests/test_sessions.py
  • mypy src - clean
  • pytest tests --ignore=tests/test_changelog.py -q -p no:cacheprovider - 1471 passed, 14 skipped
  • Full Windows suite: 1472 passed, 14 skipped, with the five pre-existing locale-decoding failures in tests/test_changelog.py; those are unrelated to this patch and are addressed separately in fix(tests): read changelog as UTF-8 #1236

AI assistance disclosure

I used AI assistants for implementation review. I independently reproduced the bug, verified the regression test against the old behavior, reviewed the resulting diff, and ran the checks above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant