Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- In a terminal, start Claude Code in a git repository and have a short conversation, for example
Remember the code word PELICAN.Exit. - In T3 Code, import that project with its conversations from the Welcome page (use Review all if the project is not offered).
- Open the imported conversation and send its first message, for example
What was the code word?
Expected behavior
The first turn resumes the native session the conversation was imported from. That session already holds the conversation, so the agent receives the history once.
Actual behavior
The first turn resumes the native session and also receives the imported rows again, as a text context handoff (strategy manual_context) placed ahead of the message. The agent gets the history twice. Because the text is part of the prompt, it is also written into the user's own Claude Code session.
Cause. In apps/server/src/orchestration-v2/Orchestrator.ts (line 8088 on main at 316c325), the call to shouldPrepareLegacyImportHandoff treats only ACP registry threads as holding native history:
const legacyImportHandoff = shouldPrepareLegacyImportHandoff({
hasNativeHistory:
activeProviderThread?.driver === "acpRegistry" &&
activeProviderThread.nativeThreadRef !== null,
historyOrigin: projection.thread.historyOrigin,
hasCompletedRun: latestCompletedRun !== undefined,
legacyImportItemCount: legacyImportItems.length,
})Threads from the Welcome page's conversation import are also marked historyOrigin: "v1_import", keep their imported rows without a run, and are bound to a strong native reference that the first turn resumes (AgentSessionImporter.ts). So they get the legacy import handoff as well. The guard is the same for Claude, Codex and Pi imports.
Checked with a test. On main at 316c325, a dispatch-level test that writes an imported thread bound to a native Claude session and sends its first message finds one context handoff on the thread, manual_context, where none is needed.
Two things worth knowing for a fix.
- Skipping the handoff whenever the provider thread has a native reference is not enough by itself. When the imported transcript is gone (Claude Code's own retention removes transcripts after 30 days by default), the Claude adapter's
resumeThreadstill succeeds, and the turn opens a new, empty session under the same id. In that case the text handoff is the only history the agent gets. - The same handoff is also prepared on the provider switch path (
legacyImportRecoveryHandoffin the same file), so a first send that goes to another provider and does not complete, followed by a switch back, looks able to reach the original native session with a second copy. I did not exercise that route.
Impact
Minor bug or occasional failure
Version or commit
main at 316c325
Environment
macOS, Claude Code provider. The cause is in the server's orchestrator, so it does not depend on the client.
Logs or stack traces
No response
Screenshots, recordings, or supporting files
No response
Workaround
No response
Activity
test(server): an imported native session's first turn does not resend…