A title and a body: giving my Git assistant an output contract
My Git assistant needs to return a title and a body. I don’t want the next part of the program to guess where one ends and the other begins.

The first pr-agent implementation gives the model a Pydantic output type:
class Message(BaseModel):
title: str
body: str
The agent is constructed with output_type=Message. Instead of treating whatever text comes back as a finished commit message, the application asks for those two fields and handles the result as that model.
The shape belongs in code
Here is a fabricated response with the expected shape:
{
"title": "fix(parser): preserve spaces between lines",
"body": "Keep a separator when joining continued text."
}
The application can access message.title and message.body. Its formatter joins them with a blank line. It doesn’t need to scrape a heading out of a paragraph or remove a Markdown fence around a response.
A response missing the body has a different problem:
{
"title": "fix(parser): preserve spaces between lines"
}
That is valid JSON, but it doesn’t satisfy this model. Requiring the field gives the application a boundary it can validate instead of silently guessing what the missing part should be.
The instructions ask for more than the type checks
The commit prompt asks for Conventional Commit formatting, a short title, and a body explaining what changed and why. Those are useful directions for generation.
They aren’t all encoded in Message. Its fields are strings. It doesn’t include a title-length validator, a list of accepted commit types, or a rule that the strings must be nonempty.
I need to distinguish what I asked the model to do from what my code rejects when it doesn’t. Writing a requirement into a prompt doesn’t add a Pydantic validator for that requirement.
The model can also satisfy the shape and get the change wrong. Suppose a teaching diff adds a new route, and the response says:
{
"title": "feat(api): remove the health route",
"body": "Delete an endpoint that is no longer used."
}
Both required fields are strings. That doesn’t make their description agree with the diff.
Keep the factual check at the boundary too
The application needs the right Git change as input, a usable output structure, and a description that matches the change. Schema validation covers one of those jobs.
The commit path also has a dry-run option, which gives me a way to inspect the generated message before creating a commit. For pull request descriptions, the result is printed for review.
In the dry run I can read the generated title next to the diff and catch a verb like “remove” when the patch actually adds a route.