---
title: "Collect a weighted vote"
lesson_id: "03"
---

# Collect a weighted vote

- **Lesson ID:** 03
- **Goal:** Collect typed votes from several sessions and tally weights in app code.
- **Human lesson:** [03-weighted-voting.html](03-weighted-voting.html)

## Prerequisites

Lesson 02.

## Inputs, outputs, and artifacts

- **Inputs:** Specialist sessions, weights, and a threshold.
- **Outputs:** An approved or failed tally the model does not compute.
- **Artifacts:** Vote, Specialist, and tally sketches.

## Agent build steps

1. Use a Generable Vote type.
2. Run respond calls in a task group.
3. Tally weights in Swift. Do not let a model set its own weight.
4. Require separate transcripts for independence.
5. Link [Pause and resume long AI jobs](../on-device-durable-workflows/), [Stop prompt attacks and leaks](../on-device-guardrails/), and [Talk to tools with MCP](../on-device-mcp-server-client/).

## Constraints

iOS 27 or later, or macOS 27 or later, and Xcode 27. Plain spoken English. No metaphor, quizzes, Mermaid, or em dashes. Do not claim Dynamic Profiles run several agents in parallel inside one session. Parallel votes need several LanguageModelSession values. Confirm Dynamic Profile names in the installed SDK docs.

## Key concepts

- A typed vote carries a choice and a reason.
- Each specialist has a name, a weight, and its own session.
- Collect votes in a task group. Tally approve weights in app code.
- A shared transcript between specialists breaks independence.

## Takeaways

- You assign weights and tally. The model only casts a typed vote.
- Keep weights in your code or shipped config, not model-writable.
- Create separate sessions for independent votes.

## Acceptance checks

- Weights live in app code.
- Votes are independent sessions or child sessions.
- Sibling links, progressive .flow diagrams, and the Agent brief link are present.
- [ ] Proceed to [lesson brief](04-judge-and-escalation.llms.md).
