Skip to content

Clone session with thinking blocks stripped #47

Description

@gadflysu

Problem

When switching from a third-party LLM endpoint (e.g. mimo) to AWS Bedrock mid-session, Claude Code carries over conversation history containing `thinking` blocks with an empty `signature` field. Bedrock strictly validates `signature`, so any subsequent request fails with:

```
API Error: 400 messages.1.content.0: Invalid `signature` in `thinking` block
```

Goal

Clone an existing Claude session JSONL with all `thinking` blocks stripped, so the clone can be resumed under a strict endpoint. Source session is never modified.

Proposed UX

CLI:
```
aps clone --strip-thinking
```
Prints new session ID and cd "<cwd>" && claude --resume <new-id>.

Interactive: T on a selected session → confirm prompt → clone+strip → show new ID in status bar. Stay in picker, no auto-launch.

Clone Logic (based on CC /branch source)

  1. Read source JSONL; skip isSidechain: true entries and non-transcript entries
  2. Assign new UUID as sessionId; rebuild parentUuid chain
  3. Keep all other fields intact (uuid, timestamps, cwd, gitBranch, etc.)
  4. Add forkedFrom: {sessionId, messageUuid} for traceability
  5. With --strip-thinking: filter out {"type":"thinking",...} blocks from every assistant content array
  6. Copy content-replacement entries (rewrite their sessionId to the new UUID)
  7. Write to same project dir as <new-uuid>.jsonl

Plan

docs/agent/plan-issue-47-clone-strip-thinking.md

Acceptance Criteria

  • Source session never modified
  • New session ID + resume command printed to stdout
  • Works from CLI subcommand and interactive picker keybinding (T)
  • Session ID argument supports full UUID and unambiguous prefix

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions