I have both handle_event and handle_info handlers which pattern match on certain payloads
The problem mostly manifests in handle_info where (for better or for worse) I end up matching more deeply
Below are diffs directly from phoenix.new (note: phoenix.new tends to "spam" commits which makes the problem slightly worse: you end up with a lot of commits that may contain wildly invalid code)
- def handle_info(%{event: "play_now", payload: %{song: song}}, socket) do
+ def handle_info(%{event: "play_now", payload: %{}, socket) do
- def handle_info(%{event: "song_updated", payload: song}, socket) do
+ def handle_info(%{event: "song_updated", payload: %{
# it's possible that I pushed invalid code, but it never got fixed
- def handle_info(%{event: "song_added", payload: %}}, socket) do
+ def handle_info(%{event: "song_adde}, socket) do
I think there several issues at play (pure speculation on my part):
- the agent doesn't really understand
mix compile
errors, or from whichever tool provides info on syntax errors, and cannot pinpoint the source - the agent has the disadvantage of working with an already established codebase and loses/cannot figure out context
- like any opther agent it optimises random local changes instead of stepping back and re-analyzing. E.g. stopping the death loop and writing this prompt fixed the code:
stop random changes. analyze thoroughly and fix once and for all. you're not allowed to edit a file more than once