MCPcopy Create free account
hub / github.com/cortexkit/magic-context / req

Function req

packages/e2e-tests/src/cache-analysis.test.ts:18–39  ·  view source on GitHub ↗
(messages: Array<{ role: string; content: unknown; bp?: boolean }>)

Source from the content-addressed store, hash-verified

16const MC_SYSTEM = "## Magic Context\nyou are a long-term partner.";
17
18function req(messages: Array<{ role: string; content: unknown; bp?: boolean }>) {
19 return {
20 body: {
21 system: MC_SYSTEM,
22 messages: messages.map((m) => ({
23 role: m.role,
24 // Real OpenCode wire keeps a message's content shape stable across
25 // turns; only the cache_control marker moves. Render every message
26 // in the identical block-array form so a message looks the same
27 // whether it sits in the tail (with breakpoint) or the prefix
28 // (breakpoint moved on). The oracle strips cache_control before
29 // hashing, so the only difference between tail and prefix is the
30 // (stripped) marker — never the content shape.
31 content: m.bp
32 ? [{ type: "text", text: String(m.content), cache_control: { type: "ephemeral" } }]
33 : Array.isArray(m.content)
34 ? m.content
35 : [{ type: "text", text: String(m.content) }],
36 })),
37 },
38 };
39}
40
41/** A user turn whose final message carries the moving cache_control breakpoint. */
42function turn(prefix: Array<{ role: string; content: string }>, tail: string) {

Callers 6

turnFunction · 0.85
getVersionFunction · 0.85
selfVersionFunction · 0.85
getSelfVersionFunction · 0.85
getSelfVersionFunction · 0.85
index.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected