Skip to content

fix(generate): persist generated agents in API classrooms#111

Open
cosarah wants to merge 7 commits intomainfrom
fix/agentmode-persist
Open

fix(generate): persist generated agents in API classrooms#111
cosarah wants to merge 7 commits intomainfrom
fix/agentmode-persist

Conversation

@cosarah
Copy link
Copy Markdown
Collaborator

@cosarah cosarah commented Mar 19, 2026

Summary

  • Bug: agentMode=generate in /api/generate-classroom generated agent profiles via LLM but never persisted them to the classroom JSON, so the classroom page couldn't display custom agents
  • Fix: Added PersistedAgent type, enriched server-side agent generation with full display data (avatar, color, priority), persisted agents alongside classroom data, and added registerPersistedAgents() for the frontend to load them without IndexedDB

Test plan

  • Call /api/generate-classroom with agentMode: "generate" and all features enabled
  • Verify generated classroom JSON contains agents array with full profile data
  • Verify /api/classroom?id=... returns agents in response
  • Verify classroom page loads and displays generated agents in browser

🤖 Generated with Claude Code

cosarah and others added 5 commits March 19, 2026 15:30
…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>
@cosarah cosarah requested a review from wyuc March 19, 2026 10:53
cosarah and others added 2 commits March 19, 2026 19:16
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>
Copy link
Copy Markdown
Contributor

@wyuc wyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants