AI.Agent.Dispatcher behaviour (fnord v0.9.38)

View Source

The seam between AI.Agent.get_response/2's bookkeeping (name checkout, task wrapping, HTTP pool propagation) and the agent implementation's get_response/1. Production dispatches straight to the impl module; tests inject a Mox mock via the :agent_dispatcher Globals key (see Fnord.TestCase.canned_agent/1) to canned-respond for specific agents while the bookkeeping still runs for real.

Unlike the :http_client and :completion_api seams, tests do NOT default this key to a mock: most tests want real agents driven by canned model responses, and the no-unmocked-network guarantee already lives at those lower layers.

Summary

Functions

Invoke the agent implementation. args already carries the %AI.Agent{} under :agent (so impl == args.agent.impl); the module is passed separately so test stubs can pattern-match the agent being dispatched.

Callbacks

dispatch(module, map)

@callback dispatch(module(), map()) :: {:ok, any()} | {:error, any()}

Functions

dispatch(impl, args)

Invoke the agent implementation. args already carries the %AI.Agent{} under :agent (so impl == args.agent.impl); the module is passed separately so test stubs can pattern-match the agent being dispatched.

impl()

@spec impl() :: module()