Assignment
Use timed text events to simulate speech recognition and model streaming. A microphone or paid speech service is not required for the state-machine exercise.
Build sequence
- Assign turn IDs to inputs, partial outputs, and tool proposals.
- Interrupt a turn and deliver its remaining events late.
- Simulate a slow client and bound buffered output.
- Reconnect the client and show the persisted task/proposal state.
Acceptance checks
- Stale events cannot replace the current turn.
- Partial transcripts never authorize writes.
- Cancellation reports whether work stopped before or after any committed effect.
Evidence to keep
Submit the working artifact or decision document described above, the inputs used, and the observed results for every acceptance check. Include one failed attempt and the change you made after investigating it. Label fixture-based outcomes separately from live-system measurements. These artifacts become part of your final portfolio review.
Guided workshop: reject output from an interrupted turn
Streaming presents partial output while work continues. A new user turn can make the old output irrelevant even when cancellation cannot stop an already-started remote call. Tag every event with the turn that owns it.
# academy-check
class Conversation:
def __init__(self):
self.turn = 0
self.parts = []
def begin(self):
self.turn += 1
self.parts = []
return self.turn
def receive(self, turn, text):
if turn == self.turn:
self.parts.append(text)
conversation = Conversation()
a = conversation.begin()
conversation.receive(a, "Old")
b = conversation.begin()
conversation.receive(a, " stale result")
conversation.receive(b, "Current")
assert "".join(conversation.parts) == "Current"
The generation counter prevents stale presentation. It does not reverse a committed action. Persist operation state separately from the transcript and reconcile side effects when cancellation arrives near a commit.
Voice simulation: use timestamped text events to represent speech chunks, user interruption, transcript finalization, tool start, and tool finish. No microphone service is needed for the first exercise. Stop presenting old chunks on interruption and show whether a tool is still running. Never interpret an incomplete utterance as approval.
Exercise sequence: start an answer, interrupt halfway, start a second answer, then deliver the old completion event after the new answer has begun. Repeat while a read-only tool is running and while a write is awaiting approval. Both old presentation events and old approval controls should be rejected or explicitly shown as historical state.
Backpressure case: if chunks arrive faster than the client can render or play them, bound the buffer and choose a clear policy. Pausing, truncating presentation, or failing the stream has different user effects. Do not accumulate unbounded audio or text in memory.
Assessment: submit an event trace demonstrating late-event rejection, cancellation acknowledgement, a visible terminal state, and correct action-state reconciliation. Measure time to first useful output separately from total task completion. A responsive voice demo is not complete if background work can continue invisibly after the user stops it.