adk_plugin behaviour (erlang_adk v0.7.0)

View Source

Behaviour contract for ordered, Runner-scoped plugins.

A plugin implements any subset of the lifecycle callbacks below. Every callback receives the same immutable, secret-pruned context map, the value at that point in the pipeline, and its private configuration. Observation plugins should return observe (or continue). Intervention plugins may amend the value and continue the operation, return a value immediately, or halt with an error. {replace, Value} is retained as a compatibility alias for {return, Value}; it never means "amend and continue".

Summary

Functions

Validate a hook without converting user input to an atom.

Types

hook/0

-type hook() ::
          on_user_message | before_run | after_run | before_agent | after_agent | before_model |
          after_model | on_model_error | before_tool | after_tool | on_tool_error | on_event |
          on_agent_error | on_run_error | on_error.

result/0

-type result() ::
          observe | continue | ok |
          {amend, term()} |
          {return, term()} |
          {replace, term()} |
          {halt, term()}.

Callbacks

after_agent/3

(optional)
-callback after_agent(Context :: map(), Value :: term(), Config :: map()) -> result().

after_model/3

(optional)
-callback after_model(Context :: map(), Value :: term(), Config :: map()) -> result().

after_run/3

(optional)
-callback after_run(Context :: map(), Value :: term(), Config :: map()) -> result().

after_tool/3

(optional)
-callback after_tool(Context :: map(), Value :: term(), Config :: map()) -> result().

before_agent/3

(optional)
-callback before_agent(Context :: map(), Value :: term(), Config :: map()) -> result().

before_model/3

(optional)
-callback before_model(Context :: map(), Value :: term(), Config :: map()) -> result().

before_run/3

(optional)
-callback before_run(Context :: map(), Value :: term(), Config :: map()) -> result().

before_tool/3

(optional)
-callback before_tool(Context :: map(), Value :: term(), Config :: map()) -> result().

on_agent_error/3

(optional)
-callback on_agent_error(Context :: map(), Value :: term(), Config :: map()) -> result().

on_error/3

(optional)
-callback on_error(Context :: map(), Value :: term(), Config :: map()) -> result().

on_event/3

(optional)
-callback on_event(Context :: map(), Value :: term(), Config :: map()) -> result().

on_model_error/3

(optional)
-callback on_model_error(Context :: map(), Value :: term(), Config :: map()) -> result().

on_run_error/3

(optional)
-callback on_run_error(Context :: map(), Value :: term(), Config :: map()) -> result().
Deprecated compatibility callback. New plugins should implement the phase-specific notification hooks above.

on_tool_error/3

(optional)
-callback on_tool_error(Context :: map(), Value :: term(), Config :: map()) -> result().

on_user_message/3

(optional)
-callback on_user_message(Context :: map(), Value :: term(), Config :: map()) -> result().

Functions

hooks()

-spec hooks() -> [hook()].

is_hook(_)

-spec is_hook(term()) -> boolean().

Validate a hook without converting user input to an atom.