fix(generate): persist generated agents in API classrooms#111
Open
fix(generate): persist generated agents in API classrooms#111
Conversation
…ssrooms When agentMode=generate was used with /api/generate-classroom, the LLM-generated agent profiles were created but never persisted to the classroom JSON file. This meant the classroom page couldn't display custom agents. - Add PersistedAgent type and agents field to PersistedClassroomData - Enrich server-side generateAgentProfiles to produce full agent data (avatar, color, priority) - Pass generated agents through to persistClassroom - Add registerPersistedAgents() to load agents from server data without IndexedDB - Update classroom page to register agents from API response Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When using default agents (agentMode != 'generate'), agent profiles were not persisted to the classroom JSON. This meant the classroom page showed no agents for default-mode classrooms. - Add getDefaultAgentsForPersistence() that exports full agent data - Always persist agents (default or generated) to the classroom file Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rsona The teacher hover card was displaying the raw English persona prompt while other agents correctly showed short i18n descriptions. Apply the same i18n-first fallback logic used by student/assistant agents. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a speech action has no pre-generated audioUrl (server TTS not configured), automatically use the browser's native SpeechSynthesis API as a fallback instead of requiring the user to manually enable browser-native-tts in settings. Reading timer remains the final fallback when browser TTS is also unavailable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
wyuc
requested changes
Mar 22, 2026
Contributor
wyuc
left a comment
There was a problem hiding this comment.
Core agent persistence fix looks good. Two things to address:
1. engine.ts TTS fallback bypasses ttsEnabled check
The new condition:
if ((browserTTSExplicit || !speechAction.audioUrl) && browserTTSAvailable)When !speechAction.audioUrl is true, this fires browser TTS even if the user has set ttsEnabled: false. Should respect the toggle:
if ((browserTTSExplicit || (!speechAction.audioUrl && settings.ttsEnabled)) && browserTTSAvailable)2. getDefaultAgentsForPersistence() return type + registerPersistedAgents() param type
Both use inline Array<{id, name, role, ...}> instead of the PersistedAgent type you already defined. Using import type { PersistedAgent } keeps them in sync and avoids drift.
Minor: the engine.ts and roundtable i18n changes are unrelated to agent persistence — would be cleaner as separate commits for bisectability, but not blocking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agentMode=generatein/api/generate-classroomgenerated agent profiles via LLM but never persisted them to the classroom JSON, so the classroom page couldn't display custom agentsPersistedAgenttype, enriched server-side agent generation with full display data (avatar, color, priority), persisted agents alongside classroom data, and addedregisterPersistedAgents()for the frontend to load them without IndexedDBTest plan
/api/generate-classroomwithagentMode: "generate"and all features enabledagentsarray with full profile data/api/classroom?id=...returns agents in response🤖 Generated with Claude Code