Available since 1.0 (source)
  • (agent state & options)
Creates and returns an agent with an initial value of state and
zero or more options (in any order):
 :meta metadata-map
 :validator validate-fn
 :error-handler handler-fn
 :error-mode mode-keyword
 If metadata-map is supplied, it will become the metadata on the
agent. validate-fn must be nil or a side-effect-free fn of one
argument, which will be passed the intended new state on any state
change. If the new state is unacceptable, the validate-fn should
return false or throw an exception.  handler-fn is called if an
action throws an exception or if validate-fn rejects a new state --
see set-error-handler! for details.  The mode-keyword may be either
:continue (the default if an error-handler is given) or :fail (the
default if no error-handler is given) -- see set-error-mode! for