Type Safety
Type Safety
AgentMark provides robust type safety through JSON Schema definitions in your prompt files. This ensures type checking for both inputs and outputs, making your prompts more reliable and maintainable.
Defining Types
You can define both input and output types in your prompt files using JSON Schema:
math/addition.prompt.mdx
puzzlet.types.ts
Generating Types
AgentMark provides a CLI tool to automatically generate TypeScript types from your prompt schemas:
Local Development
The generated types will include:
- Input types based on your
input_schema
- Output types based on your model’s
schema
- A mapping of prompt paths to their respective types
Using Generated Types
Benefits
- Compile-Time Safety: Catch type errors before runtime
- IDE Support: Get autocomplete and inline documentation
- Consistent Interfaces: Ensure consistent input/output shapes across your application
- Documentation: JSON Schema descriptions serve as built-in documentation
- Validation: Automatic runtime validation of inputs and outputs
Best Practices
- Always define both
input_schema
andschema
(when applicable) in your prompt files - Use descriptive property names and include descriptions
- Mark required properties using the
required
field - Regenerate types when you update your schemas
- Commit generated types to version control
Have Questions?
We’re here to help! Choose the best way to reach us:
Join our Discord community for quick answers and discussions
Email us at hello@puzzlet.ai for support
Schedule an Enterprise Demo to learn about our business solutions
Was this page helpful?