Thread copy API fails with KeyError when visiting previously unvisited subgraph nodes

Hi @reecemillsom is it a MUST that the copy has a new thread_id?

If so, then try this

Rehydration (supersteps)

history = await client.threads.get_history(src_thread_id)
supersteps = []
for step in history:
    supersteps.append({
        "updates": [{
            "values": step["values"],      # prune to keys you care about
            "as_node": step["metadata"].get("last_node", "__start__")
        }]
    })

new_thread = await client.threads.create(
    graph_id="conversation",
    metadata={"parent_thread": src_thread_id},
    supersteps=supersteps,
)

If not, then maybe this

Time-travel (branch) within the same thread

# start a new branch from a prior checkpoint within the SAME thread
cp = (<checkpoint_id you want to branch from>)
await client.runs.wait(
    thread_id=thread_id,
    assistant_id=assistant_id,   # or graph_id depending on your setup
    input=None,                  # resume from checkpoint
    config={"configurable": {"thread_id": thread_id, "checkpoint_id": cp}},
)

Let us know if any of those works :slight_smile: