Answer architecture round 1: 2 🔴, 2 🟡 (0 misread); move transcript parsing into claude_code and keep repeat_read pure
This commit is contained in:
@@ -5,7 +5,7 @@ import re
|
||||
import statistics
|
||||
import typing
|
||||
|
||||
from claude_code.entries import assistant_parts, parts, tool_call
|
||||
from claude_code.entries import assistant_parts, parts, tool_call, tool_result
|
||||
from git_command import commits
|
||||
from model_routing.route import ESCALATION_MARKER, route_from
|
||||
from routing_figures.prices import listed
|
||||
@@ -204,19 +204,7 @@ def messages(entries: list[dict]) -> list[Message]:
|
||||
|
||||
def results(entries: list[dict]) -> dict[str, str]:
|
||||
"""Each tool result's text by the id of the call it answers."""
|
||||
found = {}
|
||||
for entry in entries:
|
||||
for part in parts(entry):
|
||||
if isinstance(part, dict) and part.get("type") == "tool_result":
|
||||
found[str(part.get("tool_use_id"))] = result_text(part.get("content"))
|
||||
return found
|
||||
|
||||
|
||||
# {"type": "tool_result", "content": "hi"} or {"type": "tool_result", "content": [{"type": "text", "text": "hi"}]}
|
||||
def result_text(body: object) -> str:
|
||||
if isinstance(body, str):
|
||||
return body
|
||||
return "".join(block["text"] for block in body if isinstance(block, dict) and isinstance(block.get("text"), str)) if isinstance(body, list) else ""
|
||||
return {result.tool_use_id: result.text for entry in entries for part in parts(entry) if (result := tool_result(part))}
|
||||
|
||||
|
||||
def rounds_past_first(worker: list[dict], home: str) -> int:
|
||||
|
||||
Reference in New Issue
Block a user