Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
3.4 kB 78 lines
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879//// The summarizer reads the reasoning a model showed: an agent's decisions//// are often written only in its thinking. Encrypted reasoning and//// signatures never reach it.
import albedo/harness/compactionimport albedo/openai_api/typesimport gleam/jsonimport gleam/listimport gleam/stringimport gleeunit/should
fn replay(protocol: types.Protocol, body: String) -> types.Input { let assert Ok(item) = json.parse(body, types.replay_decoder(protocol)) types.Replay(item)}
fn reads(input: types.Input, shown: List(String), hidden: List(String)) -> Nil { let text = compaction.render_summary_input(input) should.be_true(string.contains(text, "[assistant thinking]")) list.each(shown, fn(part) { should.be_true(string.contains(text, part)) }) list.each(hidden, fn(part) { should.be_false(string.contains(text, part)) })}
pub fn claude_thinking_reaches_the_summarizer_test() -> Nil { replay( types.ChatCompletions, "{\"role\":\"assistant\",\"content\":\"\",\"reasoning_content\":\"stdlib keys stay @runtime\",\"reasoning_details\":[{\"type\":\"claude.blocks\",\"model\":\"claude\",\"blocks\":[{\"type\":\"thinking\",\"thinking\":\"stdlib keys stay @runtime\",\"signature\":\"SIGNED-BLOB\"}]}],\"tool_calls\":[{\"id\":\"c1\",\"type\":\"function\",\"function\":{\"name\":\"python\",\"arguments\":\"{}\"}}]}", ) |> reads(["stdlib keys stay @runtime", "[assistant call python]"], [ "SIGNED-BLOB", ])}
pub fn gemini_thoughts_reach_the_summarizer_test() -> Nil { replay( types.ChatCompletions, "{\"role\":\"assistant\",\"content\":null,\"reasoning_content\":\"relative module paths resolve against the base dir\",\"reasoning_details\":[{\"type\":\"antigravity.parts\",\"index\":0,\"model\":\"gemini\",\"parts\":[{\"thought\":true,\"text\":\"relative module paths resolve against the base dir\",\"thoughtSignature\":\"THOUGHT-SIGNATURE\"}]}]}", ) |> reads(["relative module paths resolve against the base dir"], [ "THOUGHT-SIGNATURE", ])}
pub fn copilot_gemini_reasoning_text_reaches_the_summarizer_test() -> Nil { replay( types.ChatCompletions, "{\"role\":\"assistant\",\"content\":null,\"reasoning_text\":\"keep the relative import\"}", ) |> reads(["keep the relative import"], [])}
pub fn a_summary_keeps_distinct_alias_text_without_repeating_duplicates_test() -> Nil { let text = replay( types.ChatCompletions, "{\"role\":\"assistant\",\"content\":null,\"reasoning_content\":\"shared thought\",\"reasoning\":\"shared thought\",\"reasoning_text\":\"another thought\"}", ) |> compaction.render_summary_input string.split(text, "shared thought") |> list.length |> should.equal(2) string.split(text, "another thought") |> list.length |> should.equal(2)}
pub fn a_responses_reasoning_summary_reaches_the_summarizer_test() -> Nil { replay( types.Responses, "{\"type\":\"reasoning\",\"id\":\"rs_1\",\"encrypted_content\":\"ENCRYPTED\",\"summary\":[{\"type\":\"summary_text\",\"text\":\"**CLI overrides the env var**\"}]}", ) |> reads(["**CLI overrides the env var**"], ["ENCRYPTED"])}
pub fn encrypted_only_reasoning_contributes_nothing_test() -> Nil { replay( types.Responses, "{\"type\":\"reasoning\",\"id\":\"rs_2\",\"encrypted_content\":\"ENCRYPTED\",\"summary\":[]}", ) |> compaction.render_summary_input |> should.equal("")}