Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435"""The channel a tool uses to draw something in the chat.
Until now the UI got its instructions from the assistant's *prose*: it scannedthe reply for `[3]` and swapped in a post card. That works, at the cost of threerules in AGENTS.md that the model has to remember on every single reply — writethe bracketed index, never the raw at:// URI, never put an index in a table —each added after a real failure. It asks the weakest part of the system forprose-formatting discipline.
This inverts it. A tool call is the channel a model is most reliable in, so themodel asks for a card by *calling a tool*, and the tool emits a payload the UIrenders. Nothing about the reply text matters any more.
The payload is one line at the end of the tool's output:
RENDER {"kind": "posts", ...}
One line, so the regex can't run away; at the end, so the human-readable partthe model reads comes first; `kind` chosen by the tool, so the UI dispatches onit and a tool whose kind the UI doesn't know yet degrades to its text outputinstead of vanishing.
The model sees this line too, which is deliberate — it's the tool's receipt thatthe cards were drawn, and it needs to know that so it doesn't describe the postsall over again in prose."""import json
SENTINEL = "RENDER"
def emit(kind: str, **payload) -> None: """Print the render line. Compact separators keep it to one line.""" print(SENTINEL + " " + json.dumps({"kind": kind, **payload}, separators=(",", ":")))