| 76 | * at call time by detecting the fork boilerplate tag in conversation history. |
| 77 | */ |
| 78 | export function isInForkChild(messages: MessageType[]): boolean { |
| 79 | return messages.some(m => { |
| 80 | if (m.type !== 'user') return false |
| 81 | const content = m.message.content |
| 82 | if (!Array.isArray(content)) return false |
| 83 | return content.some( |
| 84 | block => |
| 85 | block.type === 'text' && |
| 86 | block.text.includes(`<${FORK_BOILERPLATE_TAG}>`), |
| 87 | ) |
| 88 | }) |
| 89 | } |
| 90 | |
| 91 | /** Placeholder text used for all tool_result blocks in the fork prefix. |
| 92 | * Must be identical across all fork children for prompt cache sharing. */ |