CSE Roadmap

Common tier · about 4 hours · 11 parts

Part 4 of 11 · 2 min read

A typed result is what keeps the useful part and drops the dangerous part

Copying only the fields a schema expects is what tells a caveat apart from a planted instruction.

Think of a lab assistant who reports back only the three numbers a form asks for, never the scratch notes beside them. A note slipped into the margin by someone else never makes it onto the form. The form never had a line for it.

In plain words: a typed (structured) result is a return value with a fixed schema -- here finding, detail, caveat -- built by pattern-matching only those fields out of everything the sub-agent produced, so injection containment follows almost for free: text that is not one of the expected fields never gets copied into the result, however it got into the sub-agent's tool output.

A worked example. One sub-agent's tool output contains an injected instruction ([email protected]) planted inside otherwise-ordinary noise. Returning that sub-agent's last three messages carries the injected text straight into the parent, because the injection sits in the same tool output as the caveat the strategy is trying to capture. The typed-result strategy reaches the parent with all four findings and the one real caveat, and the injected text does not appear at all, because the extractor only ever copies text matching FINDING:, detail:, or CAVEAT:.

The key lines. From code/mini-subagents/agents.py:

# from code/mini-subagents/agents.py
def structured_result(sub: W.SubTask) -> str:
    text = "\n".join(m.text for m in sub.messages if m.role == "tool")
    got = {k: re.search(p, text) for k, p in (("finding", r"FINDING: ([^\n]+)"), ("detail", r"detail: ([^\n]+)"), ("caveat", r"CAVEAT: ([^\n]+)"))}
    return "; ".join(f"{k}={v.group(1)}" for k, v in got.items() if v)

Read it as: the three patterns are the whole schema, and re.search only ever extracts text matching one of them. An injected line with no FINDING:, detail:, or CAVEAT: prefix has nothing to match. It is dropped, but not because it was recognised as an attack. It is dropped because it was never one of the fields being asked for.

Typed (structured) result, constraint passing, injection containment

A typed result is a return value with a fixed schema instead of free text. Constraint passing means putting the parent's requirements -- scope, format, forbidden actions -- into the task given to the child, since the child cannot see the parent's own context. Injection containment is keeping instructions found in untrusted tool output from reaching an agent that holds more authority.

Example: the typed-result row is the only one in the results table with zero injected text reaching the parent, purely because the schema gave the injection nowhere to go.