Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions sdk/guides/convo-fork.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@ fork_fresh = source.fork()
fork_with_history = source.fork(reset_metrics=False)
```

### Local Prompt Cache Routing

Pass `prompt_cache_key` to `LocalConversation.fork()` to choose the fork's
prompt-cache routing key. To reuse the source's key:

```python icon="python" wrap
fork = source.fork(
prompt_cache_key=source.get_llm_call_context().prompt_cache_key,
)
```

Omitting the parameter, or passing `None` or an empty string, uses the fork's
own conversation ID. The fork keeps its own session ID and usage accounting.
Cache reuse also depends on the provider and matching prompt and tool prefixes.
Anthropic uses content-based caching. OpenRouter continues to receive the fork's
own `session_id` for routing.

This is a local, runtime option. When reopening a persisted fork, pass the key
again to the `LocalConversation` constructor. `RemoteConversation.fork()` does
not accept this parameter.

## API Reference

```python icon="python" wrap
Expand All @@ -118,12 +139,14 @@ def fork(
title: str | None = None, # remote forks only; deprecated locally
tags: dict[str, str] | None = None, # arbitrary metadata
reset_metrics: bool = True, # cost/tokens start fresh
prompt_cache_key: str | None = None, # local forks only
) -> Conversation:
```

| Parameter | Default | Description |
|-----------|---------|-------------|
| `conversation_id` | auto-generated UUID | ID for the forked conversation |
| `prompt_cache_key` | fork conversation ID | Local fork prompt-cache routing override |
| `agent` | deep-copy of source | Agent for the fork (swap model, tools, etc.) |
| `title` | `None` | Sets the agent-server fork title for `RemoteConversation`; deprecated and ignored by `LocalConversation` |
| `tags` | `None` | Arbitrary key-value metadata |
Expand Down