tablet 58: the tool's answer is given — tool results are sources; markers on word boundaries

The sugya reply came back lo_tov — golden_calf on two sentences the
builder had just read from tool output (the Mishnah's reasons, from the
second scroll; the commit and pod, from its own tools). The gate's
sources were only the user turns' text and document blocks; a
tool_result block and a tool turn — what the model was GIVEN (tablet
49) — were not counted. And "shorashim-675b…" was vital because the
insight markers matched "Rashi" inside it.

- Shape.sources: Anthropic tool_result blocks (string or blocks) inside
  a user turn, and OpenAI role "tool" turns, are sources; the query is
  still the last user turn. gate_test: both shapes.
- zerikah._INSIGHT_MARKERS: \b…\b. test_zerikah: the pod name is not
  Rashi; "Rashi reads" and "The Mishnah records" are; "Rambanovich" and
  "talmudic_engine" are not.
- Tablet 58 in the Broken Tablets.

Elixir 643/0, korban 294/0. Doorpost pin unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Scott KarpandClaude Fable 5.1 committed 2026-10-21 20:56:25 +00:00
1 parent dc93805877
commit ad27d3c037
5 files changed
+97 -3

No files matched your search

+7 -1
View File
@@ -52,9 +52,10 @@ defmodule VavPipeline.Gate.Shape do
# sources pass the cap — a coding agent's conversation runs to megabytes.
@max_source_bytes 1_048_576
# A "tool" turn (OpenAI) is what a tool returned to the model: given, a source (tablet 58).
defp user_sources(messages, text_fun) do
messages
|> Enum.filter(&(&1["role"] == "user"))
|> Enum.filter(&(&1["role"] in ["user", "tool"]))
|> Enum.with_index(1)
|> Enum.flat_map(fn {m, i} -> text_fun.(m) |> wrap("user_#{i}") end)
|> Enum.reverse()
@@ -93,6 +94,11 @@ defmodule VavPipeline.Gate.Shape do
%{"type" => "text", "text" => t} when is_binary(t) -> [t]
%{"type" => "document", "source" => %{"type" => "text", "data" => t}} when is_binary(t) -> [t]
%{"type" => "document", "source" => %{"type" => "content", "content" => inner}} when is_list(inner) -> [text_of_blocks(inner)]
# Tablet 58: what a tool returned to the model was GIVEN to it
# (tablet 49) — a file it read, a reply from a service, the scroll
# it consulted. A claim that rests on it rests on a source.
%{"type" => "tool_result", "content" => c} when is_binary(c) -> [c]
%{"type" => "tool_result", "content" => inner} when is_list(inner) -> [text_of_blocks(inner)]
_ -> []
end)
|> Enum.join("\n")
+31
View File
@@ -248,6 +248,37 @@ defmodule VavPipeline.GateTest do
# The shape
# ------------------------------------------------------------
# Tablet 58: what a tool returned to the model was given to it — a source.
test "tool results are sources: a user turn's tool_result blocks (Anthropic) and a tool turn (OpenAI)" do
anthropic = %{
"system" => "S",
"messages" => [
%{"role" => "user", "content" => "Read the file."},
%{"role" => "assistant", "content" => [%{"type" => "tool_use", "id" => "t1", "name" => "read", "input" => %{}}]},
%{"role" => "user", "content" => [
%{"type" => "tool_result", "tool_use_id" => "t1", "content" => "commit dc938058 on main"},
%{"type" => "tool_result", "tool_use_id" => "t2", "content" => [%{"type" => "text", "text" => "Eduyot 1:5: why the minority is recorded"}]}
]},
%{"role" => "user", "content" => "What did you find?"}
]
}
assert [%{id: "system", text: "S"}, %{id: "user_1", text: "Read the file."},
%{id: "user_2", text: "commit dc938058 on main\nEduyot 1:5: why the minority is recorded"},
%{id: "user_3", text: "What did you find?"}] = Shape.sources(:anthropic, anthropic)
assert Shape.query(:anthropic, anthropic) == "What did you find?"
openai = %{"messages" => [
%{"role" => "user", "content" => "Read it."},
%{"role" => "assistant", "content" => nil, "tool_calls" => [%{"id" => "c1"}]},
%{"role" => "tool", "tool_call_id" => "c1", "content" => "commit dc938058 on main"},
%{"role" => "user", "content" => "And?"}
]}
assert [%{id: "user_1", text: "Read it."}, %{id: "user_2", text: "commit dc938058 on main"}, %{id: "user_3", text: "And?"}] = Shape.sources(:openai, openai)
# the query is still the last USER turn, not the tool's
assert Shape.query(:openai, openai) == "And?"
end
test "sources are the system prompt and the user turns, not the assistant's; the query is the last user turn" do
assert [%{id: "system", text: "Answer from the report."}, %{id: "user_1", text: "Here is the report: revenue rose 4% in Q3."}, %{id: "user_2", text: "What happened to revenue?"}] =
Shape.sources(:anthropic, body())