AgentMark supports structured output through JSON Schema. This allows you to define the exact shape of the data you want the model to return.

Basic Usage

Define the schema in your object prompt:

---
name: calculate
object_config:
  model_name: claude-3-5-haiku-latest
  max_tokens: 4096
  temperature: 0.7
  top_p: 1
  schema:
    type: object
    properties:
      names:
        type: array
        items:
          type: string
        description: names of people
    required:
    - names
---

<System>You are a helpful assistant capable of finding all the names of the people in a given body of text.</System>
<User>Jessica and Michael decided to host a barbecue at their house, inviting their closest friends, Emily, David, and Sarah. As the evening went on, Jessica shared stories from her recent trip, while Michael grilled burgers, and Emily entertained everyone with her hilarious anecdotes.</User>

Returns:

{
  "names": [
    "Jessica",
    "Michael",
    "Emily",
    "David",
    "Sarah"
  ]
}

Complex Schemas

You can define nested objects and arrays:

---
name: event-parser
object_config:
  model_name: gpt-4o
  schema:
    type: object
    properties:
      event:
        type: object
        properties:
          name: 
            type: string
            description: The name of the event
          date:
            type: string
            description: The date of the event
          attendees:
            type: array
            items:
              type: object
              properties:
                name:
                  type: string
                  description: The name of the attendee
                role:
                  type: string
                  description: The role of the attendee
              required:
                - name
                - role
        required: 
          - name
          - date
          - attendees
---

<System>Parse event details from the text.</System>
<User>The company picnic is on July 15th. John (host) and Mary (coordinator) are organizing it.</User>

Returns:

{
  "event": {
    "name": "Company Picnic",
    "date": "July 15th",
    "attendees": [
      {
        "name": "John",
        "role": "host"
      },
      {
        "name": "Mary",
        "role": "coordinator"
      }
    ]
  }
}

Schema Types

Supported JSON Schema types:

  • string: Text values
  • number: Numeric values
  • boolean: True/false values
  • array: Lists of items
  • object: Nested structures
  • null: Null values

Best Practices

  1. Keep schemas as simple as possible
  2. Use clear property names and descriptions
  3. Specify required fields explicitly
  4. Test with various input scenarios
  5. Include type validations where needed

Have Questions?

We’re here to help! Choose the best way to reach us: