Skip to content

100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.

insert generated code into Trinket editor before execution (#1010)

Ankit Kumar Singh51ab4eac6175
diff --git a/advanced_ai_agents/autonomous_game_playing_agent_apps/ai_3dpygame_r1/ai_3dpygame_r1.py b/advanced_ai_agents/autonomous_game_playing_agent_apps/ai_3dpygame_r1/ai_3dpygame_r1.py
index 5e929b01..e1e6a4a5 100644
--- a/advanced_ai_agents/autonomous_game_playing_agent_apps/ai_3dpygame_r1/ai_3dpygame_r1.py
+++ b/advanced_ai_agents/autonomous_game_playing_agent_apps/ai_3dpygame_r1/ai_3dpygame_r1.py
@@ -146,8 +146,20 @@ elif generate_vis_btn:
browser_context=context
)
+ # FIX: The `code` parameter was previously never referenced inside
+ # any agent's task, so nothing actually told the browser agent
+ # what code to type into the editor. It's now interpolated
+ # directly into the coder agent's task, and the instruction is
+ # changed from "wait for the user to write the code" (passive)
+ # to an explicit action: click into the editor and type the code.
coder = Agent(
- task='Coder. Your job is to wait for the user for 10 seconds to write the code in the code editor.',
+ task=(
+ "Coder. Click into the Trinket code editor. Select all existing "
+ "content (Ctrl+A) and delete it. Then paste the following Python "
+ "code exactly as provided without modifying the formatting or "
+ "indentation:\n\n"
+ f"{code}"
+ ),
llm=model,
browser_context=context
)
@@ -173,4 +185,4 @@ elif generate_vis_btn:
asyncio.run(run_pygame_on_trinket(st.session_state.generated_code))
elif generate_code_btn and not query:
- st.warning("Please enter a query before generating code")
\ No newline at end of file
+ st.warning("Please enter a query before generating code")