Documentation
¶
Overview ¶
Package fence lifts runnable code blocks out of a model reply. It is the lexical layer of a code-as-action engine: the model writes an action as a fenced code block, or in whatever costume its fine-tune reaches for instead, and this package reads the language tag and the code back out. Which blocks run, and how, is engine policy and stays with the engine; this package only parses text, so any engine built on the same one-action idea shares it rather than growing a drifting copy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
Block is one fenced code block lifted from a model reply: the language tag after the opening fence and the raw code between the fences.
func ParseMarkdown ¶
ParseMarkdown reads the Markdown fences and, only when there are none, salvages a generic execute XML tool call. A default-dialect model (deepseek among them) writes a fence on almost every turn, so the fence parser carries the work and the salvage never runs; but that model intermittently reaches for its native tool-call syntax instead, and dropping that action ends the turn on nothing. The fallback recovers it without touching the dominant fenced path or the system prompt, the same meet-the-model-where-it-is repair the glued-fence split is.
type Dialect ¶
type Dialect struct {
// Name identifies the dialect in a trace.
Name string
// Parse lifts the runnable blocks out of a reply in the model's own syntax.
Parse func(reply string) []Block
// Hint is appended to the system prompt to ask the model for the syntax this
// dialect parses. Empty leaves the base prompt's Markdown instruction alone,
// which is right for a model that already writes Markdown.
Hint string
}
A Dialect is how a given model natively expresses "run this code". The Open Interpreter idea is one action, a code block, but models disagree on the syntax of that block even when the prompt asks for Markdown: a base model writes a Markdown fence, a tool-tuned model reaches for JSON, a Hermes-family model emits an XML tool call. A single parser extracts the action from one of them and silently drops it from the rest, so the engine carries a dialect per model and parses whatever that model actually produces.
This is the per-model harness: meet the model where it is. Adding a model is adding one registry entry, and if its syntax is new, one parse function, which is the seam a later fine-tune tunes at.
func For ¶
For picks the dialect for a model by family, matching on the bare model id (any provider/ prefix stripped). An unknown model gets Markdown, the safe default: a model that writes fences is parsed correctly, and one that does not simply produces no block and ends the turn, the same as before dialects.