feat(http_server): add section headers to _payload_to_text for model parsing
The flattened text output now uses markdown headers so the model can distinguish L0 identity from L1 summary from L2 episodes from handles. This replaces undifferentiated newline-separated text with structured sections: ## L0 Identity, ## L1 Recent Summary, ## Rich Club, ## L2 Episode, ## Handles.
This commit is contained in:
parent
7559bac57f
commit
eec312dcb4
2 changed files with 7 additions and 5 deletions
|
|
@ -73,16 +73,17 @@ def _payload_to_text(result: Any) -> str:
|
|||
if not isinstance(result, dict):
|
||||
return str(result)
|
||||
parts: list[str] = []
|
||||
headers = {"l0": "## L0 Identity", "l1": "## L1 Recent Summary", "rich_club": "## Rich Club"}
|
||||
for key in ("l0", "l1", "rich_club"):
|
||||
val = result.get(key)
|
||||
if isinstance(val, str) and val.strip():
|
||||
parts.append(val.strip())
|
||||
parts.append(f"{headers[key]}\n{val.strip()}")
|
||||
l2 = result.get("l2")
|
||||
if isinstance(l2, list):
|
||||
for item in l2:
|
||||
text = item if isinstance(item, str) else json.dumps(item, ensure_ascii=False)
|
||||
if text.strip():
|
||||
parts.append(text.strip())
|
||||
parts.append(f"## L2 Episode\n{text.strip()}")
|
||||
# Compact handles (populated at minimal; also present at standard/deep).
|
||||
handles = [
|
||||
result.get(k)
|
||||
|
|
@ -90,7 +91,7 @@ def _payload_to_text(result: Any) -> str:
|
|||
]
|
||||
handles = [h for h in handles if isinstance(h, str) and h.strip()]
|
||||
if handles:
|
||||
parts.append(" ".join(handles))
|
||||
parts.append(f"## Handles\n{' '.join(handles)}")
|
||||
return "\n\n".join(parts)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue