Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-landlord-maxretries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"landlord": patch
---

Validate `maxRetries` on a contract as a positive integer. It was previously an unconstrained `z.number()`, so negative or zero values silently caused a tenant to escalate without ever running, and fractional values produced an unexpected extra attempt in the `attempt < maxRetries` loop. The schema now enforces `int().min(1)`.
2 changes: 1 addition & 1 deletion packages/landlord/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const ContractSchema = z.object({
toolsAllowed: z.array(z.string()).optional(),
toolsDenied: z.array(z.string()).optional(),
dependsOn: z.array(z.string()).default([]),
maxRetries: z.number().default(3),
maxRetries: z.number().int().min(1).default(3),
});

export type Checkpoint = z.infer<typeof CheckpointSchema>;
Expand Down
15 changes: 15 additions & 0 deletions packages/landlord/test/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,19 @@ describe('ContractSchema', () => {
});
expect(result.success).toBe(false);
});

it('rejects non-positive, non-integer, and fractional maxRetries', () => {
const base = {
role: 'r',
objective: 'x',
subPrompt: 'x',
checkpoints: [],
outputSchema: {},
};
for (const maxRetries of [0, -1, 2.5]) {
const result = ContractSchema.safeParse({ ...base, maxRetries });
expect(result.success).toBe(false);
}
expect(ContractSchema.safeParse({ ...base, maxRetries: 1 }).success).toBe(true);
});
});
Loading