A node that executes logic for side-effects (e.g., logging, notifications). Its output does not modify the primary AgentState.
Super class
HydraR::AgentNode -> AgentObserverNode
Methods
Method new()
Initialize AgentObserverNode
Usage
AgentObserverNode$new(id, observe_fn, label = NULL, params = list())Examples
if (FALSE) { # \dontrun{
# An observer that logs stats to a file without modifying state
logger <- function(state) {
stats <- state$get_all()
writeLines(jsonlite::toJSON(stats), "logs/observation.json")
message("Stats observed and written to logs.")
}
node_obs <- AgentObserverNode$new(
id = "status_logger",
observe_fn = logger
)
# Run with dummy state
node_obs$run(AgentState$new(list(x = 10, y = 20)))
} # }