Problem
When running Goodwizard with updated deps (jido_browser ~> 2.0, jido_ai main), the agent crashes when the LLM invokes any browser tool that returns an error.
Error
(Protocol.UndefinedError) protocol Jason.Encoder not implemented for
type Jido.Browser.Error.InvalidError (a struct)
Jason.Encoder protocol must always be explicitly implemented.
Stacktrace:
(jason) Jason.encode!/2
(jido_ai) Jido.AI.Turn.encode_tool_result_envelope/2
(jido_ai) Jido.AI.Reasoning.ReAct.Strategy.append_tool_result_to_run_context/5
(jido_ai) Jido.AI.Reasoning.ReAct.Strategy.apply_runtime_event/2
(jido_ai) Jido.AI.Reasoning.ReAct.Strategy.process_worker_event/2
Cause
jido_ai's ReAct strategy calls Jido.AI.Turn.encode_tool_result_envelope/2 which tries to Jason.encode! tool results, including error structs. Jido.Browser.Error.InvalidError (from jido_browser 2.0) doesn't implement Jason.Encoder, so it crashes.
Impact
- Text-only Telegram chat works fine
- Any query where the LLM decides to use a browser tool (navigate, click, etc.) crashes the agent process
- The agent recovers (Telegram handler restarts), but the user sees "an unexpected error occurred"
Likely fix
Either:
jido_browser 2.0 needs @derive Jason.Encoder on all error structs (InvalidError, NavigationError, TimeoutError, etc.)
jido_ai's Turn.encode_tool_result_envelope needs to handle non-encodable structs gracefully (e.g., convert to %{error: inspect(struct)} before encoding)
Option 2 is more defensive — any tool could return a non-encodable struct.
Environment
jido ~> 2.1 (hex)
jido_ai main branch (commit 5601aa5)
jido_browser ~> 2.0 (hex, v2.0.0)
- Elixir 1.18 / OTP 27
- Docker container
Related
This was discovered while resolving #23 (broken deps). The browser tools work in terms of compilation, but fail at runtime when errors occur.
Problem
When running Goodwizard with updated deps (
jido_browser ~> 2.0,jido_aimain), the agent crashes when the LLM invokes any browser tool that returns an error.Error
Cause
jido_ai's ReAct strategy callsJido.AI.Turn.encode_tool_result_envelope/2which tries toJason.encode!tool results, including error structs.Jido.Browser.Error.InvalidError(fromjido_browser2.0) doesn't implementJason.Encoder, so it crashes.Impact
Likely fix
Either:
jido_browser2.0 needs@derive Jason.Encoderon all error structs (InvalidError,NavigationError,TimeoutError, etc.)jido_ai'sTurn.encode_tool_result_envelopeneeds to handle non-encodable structs gracefully (e.g., convert to%{error: inspect(struct)}before encoding)Option 2 is more defensive — any tool could return a non-encodable struct.
Environment
jido ~> 2.1(hex)jido_aimain branch (commit5601aa5)jido_browser ~> 2.0(hex, v2.0.0)Related
This was discovered while resolving #23 (broken deps). The browser tools work in terms of compilation, but fail at runtime when errors occur.