fix(#353,#354): conditionally set generatedAgentConfigs based on agentMode#373
Open
YizukiAme wants to merge 2 commits intoTHU-MAIC:mainfrom
Open
fix(#353,#354): conditionally set generatedAgentConfigs based on agentMode#373YizukiAme wants to merge 2 commits intoTHU-MAIC:mainfrom
YizukiAme wants to merge 2 commits intoTHU-MAIC:mainfrom
Conversation
975be56 to
443e296
Compare
…gs based on agentMode THU-MAIC#353: Only embed generatedAgentConfigs in the Stage when agentMode is 'generate'. For default mode, set agentIds instead. This prevents default agents from being incorrectly marked as isGenerated on the client-side registry. Also reset agentMode to 'default' in the catch block when LLM agent generation fails and falls back to defaults. THU-MAIC#354: Remove redundant setSelectedAgentIds call from Path 1 (server hydration). Path 2 handles agent restoration uniformly for both IndexedDB and server-loaded classrooms. Includes unit tests covering all three scenarios (default, generate, and LLM fallback).
443e296 to
4105736
Compare
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
Fixes #353 and #354.
#353:
generatedAgentConfigsunconditionally set for all agent modesProblem:
classroom-generation.tsalways embeddedgeneratedAgentConfigsin the Stage object regardless ofagentMode. WhenagentMode === 'default', this caused the 6 default agents (default-1~default-6) to be written to the client-side IndexedDB and Agent Registry asisGenerated: true, overwriting theirisDefault: trueentries.Fix: Only set
generatedAgentConfigswhenagentMode === 'generate'. For default mode, setagentIdsinstead — the client already has the default agent definitions built in.Additional fix: When LLM agent generation fails and falls back to defaults, reset
agentModeto'default'so the Stage object correctly usesagentIdsinstead ofgeneratedAgentConfigs.#354: Redundant agent hydration in classroom page load
Problem: When loading a server-generated classroom,
page.tsxPath 1 called bothsaveGeneratedAgents()andsetSelectedAgentIds(). Path 2 (general restoration logic) would then clear the registry and re-add the same agents, callingsetSelectedAgentIds()again — redundant work.Fix: Path 1 now only calls
saveGeneratedAgents()to persist agents to IndexedDB. Path 2 handles all agent restoration uniformly, including settingselectedAgentIdsandagentMode.Changes
lib/server/classroom-generation.tsgeneratedAgentConfigsvsagentIdsbased onagentMode; resetagentModeon LLM fallbackapp/classroom/[id]/page.tsxsetSelectedAgentIdsfrom server hydration pathtests/server/classroom-agent-mode.test.tsVerification
tsc --noEmit— zero errorspnpm lint— no new warnings/errorsagentMode: 'default'producesagentIds: ["default-1",...,"default-6"]and nogeneratedAgentConfigs