(requests: T[])
| 252 | |
| 253 | /** Filter to main-agent requests (those carrying the Magic Context system block). */ |
| 254 | export function mainAgentRequests<T extends MinimalRequest>(requests: T[]): T[] { |
| 255 | return requests.filter((r) => { |
| 256 | const sys = r.body.system; |
| 257 | if (sys === undefined || sys === null) return false; |
| 258 | const asString = typeof sys === "string" ? sys : JSON.stringify(sys); |
| 259 | return asString.includes("## Magic Context"); |
| 260 | }); |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Extract the text of the first wire message whose content contains `marker`. |
no outgoing calls