DiscordPHP-NHA Documentation

DecisionLogTrait

{@see \NHA\StateStore} slice: the brain's decision record — the last decision per agent (verb, args, rationale, `queued_intent` id) plus a rolling 24-turn history so {@see \NHA\Brain\AutoPlayer::detectLoop()} and the prompt can see repetition beyond the last turn.

Relies on the host's array $data and save().

Tags
since
3.1.32

Table of Contents

Constants

DECISION_LOG_CAP  : mixed = 24
How many past decisions the rolling history keeps.

Methods

clearQueuedIntent()  : void
Drops the stored `queued_intent` id from an agent's last decision once its outcome is settled (`applied` / `rejected`) or it has aged out (`gone`), so the autoplay loop stops issuing `GET /intent/{id}` for it every turn.
getLastDecision()  : array{verb: string, args: array, reason: string, queued_intent: ?int, tick: ?int, at: int}|null
Gets the brain's last recorded decision for an agent, if any.
getRecentDecisions()  : array<int, array{verb: string, args: array, tick: ?int}>
The agent's last few decisions, oldest first — a rolling window so the brain can detect a loop or an already-tried `combine` pair. Each entry is `{verb, args, tick}`; older/other fields are not kept here.
recordDecision()  : void
Records the brain's most recent decision for an agent (verb, args, the one-line rationale and the `queued_intent` id it produced), so a later command can show "what did the bot last do, and did it land?".

Constants

DECISION_LOG_CAP

How many past decisions the rolling history keeps.

private mixed DECISION_LOG_CAP = 24

Methods

clearQueuedIntent()

Drops the stored `queued_intent` id from an agent's last decision once its outcome is settled (`applied` / `rejected`) or it has aged out (`gone`), so the autoplay loop stops issuing `GET /intent/{id}` for it every turn.

public clearQueuedIntent(int $agent_id[, int|null $only = null ]) : void
Parameters
$agent_id : int
$only : int|null = null

When given, only clears the id if it still matches — a no-op if recordDecision() has since stored a newer intent, avoiding a lost update.

Tags
since
3.1.5

getLastDecision()

Gets the brain's last recorded decision for an agent, if any.

public getLastDecision(int $agent_id) : array{verb: string, args: array, reason: string, queued_intent: ?int, tick: ?int, at: int}|null
Parameters
$agent_id : int
Return values
array{verb: string, args: array, reason: string, queued_intent: ?int, tick: ?int, at: int}|null

getRecentDecisions()

The agent's last few decisions, oldest first — a rolling window so the brain can detect a loop or an already-tried `combine` pair. Each entry is `{verb, args, tick}`; older/other fields are not kept here.

public getRecentDecisions(int $agent_id[, int $limit = 10 ]) : array<int, array{verb: string, args: array, tick: ?int}>
Parameters
$agent_id : int
$limit : int = 10
Return values
array<int, array{verb: string, args: array, tick: ?int}>

recordDecision()

Records the brain's most recent decision for an agent (verb, args, the one-line rationale and the `queued_intent` id it produced), so a later command can show "what did the bot last do, and did it land?".

public recordDecision(int $agent_id, array<string, mixed> $decision) : void
Parameters
$agent_id : int
$decision : array<string, mixed>

Expects keys: verb, args, reason, queued_intent, tick.

On this page

Search results