Version: latest
agrag.agents.middleware.record_event_or_flag
record_event_or_flag(memory:Any, task_name:str, run_state:RunState, kind:EventKind, *, payload:str, role:str | None = None, name:str | None = None) -> Any
Append one event, retry it once, and flag the run if it still fails.
The retry reuses one request id, so a write that committed before the error returns its stored result instead of a second event.
Parameters:
- memory (
Any) – The task memory that holds the event. - task_name (
str) – The task the event belongs to. - run_state (
RunState) – The run whose failure flag is set on a lasting error. - kind (
EventKind) – The kind of event. - payload (
str) – The event text. - role (
str | None) – The speaker role for a message, or None. - name (
str | None) – The tool or source name for a tool event, or None.
Returns:
Any– The stored event, or None when the write did not complete.