Structured Output
Free-form text is fine for a chat window, but programs need data they can trust. Structured output lets you constrain Amara’s final answer to a schema you define, so the SDK returns typed, validated JSON instead of prose you have to parse. This is how you turn an agent into a reliable component inside a larger system.
You describe the shape you want, the Syntic model produces a result that conforms to it, and the SDK hands you an object your code can consume directly.
Requesting a schema
Pass an output schema in the options. When the agent finishes, the result message carries a parsed value matching that schema rather than a plain string.
import { query } from "@syntic/agent-sdk";
import { z } from "zod";
const ReviewSchema = z.object({
summary: z.string(),
severity: z.enum(["low", "medium", "high"]),
files: z.array(z.string()),
});
for await (const message of query({
prompt: "Review the staged diff and report issues.",
options: { outputSchema: ReviewSchema },
})) {
if (message.type === "result") {
const review = message.output; // typed as ReviewSchema
console.log(review.severity, review.files);
}
}from pydantic import BaseModel
from syntic_agent_sdk import query
class Review(BaseModel):
summary: str
severity: str
files: list[str]
async for message in query(
prompt="Review the staged diff and report issues.",
options={"output_schema": Review},
):
if message.type == "result":
review = message.output # instance of Review
print(review.severity, review.files)Validation and error handling
The SDK validates the model’s output against your schema before returning it. Use the native schema library for your language — Zod in TypeScript, Pydantic in Python — so you get static types on top of runtime checks. Fields, enums, and nested objects are all enforced, which keeps malformed data out of your pipeline.
If the Syntic model cannot produce a conforming value, the SDK surfaces a validation error rather than silently handing back something unusable. Keep your schemas focused: ask for the specific fields you need instead of a sprawling object, and prefer enums and constrained types over open strings. A tight schema both improves the reliability of the output and makes the downstream code that consumes it far simpler to write.