Skip to content

API Reference parrot.tools.working_memory.task_memory.models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.working_memory.task_memory.models

View source

Domain models for recoverable task memory (FEAT-538, Delivery A).

This is a leaf module: it imports stdlib, pydantic and orjson only. It must never import a concrete backend (PostgreSQL, Redis, a REPL worker), pandas, or the working-memory toolkit — the dependency runs the other way. Keeping it leaf-safe is what lets the store, reducer, observer and tool layers all share one vocabulary without an import cycle.

Everything here follows the specification's §2 Data Models:

  • Pydantic v2 models with schema_version = 1 and extra="forbid".
  • Timezone-aware UTC timestamps; naive datetimes are rejected, never silently localized.
  • Runtime identities from stdlib :func:uuid.uuid4 — Python 3.11 rules out assuming a stdlib uuid7 and no ULID dependency is introduced.
  • Bounded collections and text. Exceeding a bound raises the typed :class:LimitExceeded before any mutation is attempted.
  • Derived state (a task's active/ready step ids) is computed, never persisted as a duplicate list.

.. warning::

Delivery A is not durable. These models describe in-process continuity; durability arrives with Delivery B's PostgreSQL store, blob write-through and crash reconciliation.

Class Actor

Who caused an event (spec §2).

Class AddConstraint

Add a standing constraint.

Attributes:

Attribute Type Description
op Literal['add_constraint'] Discriminator.
text str The constraint.

Class AddStep

Add a step to an existing plan.

Attributes:

Attribute Type Description
op Literal['add_step'] Discriminator.
label Optional[str] Request-local label so that steps added in the same batch can depend on one another before their ids exist.
title str Short human-readable label.
description str Longer explanation.
required bool Whether the task can complete without this step.
depends_on Tuple[str, ...] Existing runtime step ids this one depends on.
depends_on_labels Tuple[str, ...] Labels of steps added in the same batch.
completion_policy CompletionPolicy How the step may be completed.

Class ArtifactAvailability

Where an artifact version's bytes currently are.

missing/expired describe the payload. Invalidation and binding_invalid are separate descriptor flags — a stale REPL binding is not proof that durable bytes disappeared (spec §2).

Class ArtifactDescriptor

Read projection of one versioned catalog entry (D1).

Shared by DataFrame (CatalogEntry) and generic (GenericEntry) entries. Contains no data rows and no raw payload, and building one never calls compact_summary(), describe() or an arbitrary object's repr() — recall must stay cheap and must not leak data.

Attributes:

Attribute Type Description
ref EvidenceRef Artifact identity and version.
alias Optional[str] Current working-memory key, when it still has one.
scope TaskScope Owning scope.
task_id Optional[str] Owning task, when associated.
producer_call_id Optional[str] The physical attempt that produced it.
attribution Attribution How that attempt was attributed.
kind ArtifactKind Evidence type.
availability ArtifactAvailability Where the bytes are.
fingerprint Optional[str] Canonical content fingerprint, when computable.
fingerprint_algorithm Optional[str] Algorithm identity and version, e.g. "blake2b-8/v1".
evidence_verifiable bool Whether the fingerprint actually proves content integrity. False for unsupported or nested mutable values — a computable fingerprint over a nested object is not integrity proof.
invalidated bool Whether this version's evidence has been invalidated.
binding_invalid bool Whether its REPL binding is stale. Independent of availability: a stale binding does not mean the durable payload disappeared.
byte_size Optional[int] Recorded payload size in bytes.
shape Optional[Tuple[int, ...]] Captured shape, e.g. (rows, cols).
schema_summary Optional[Dict[str, Any]] Bounded captured schema description.
storage_ref Optional[str] Backend storage reference, when persisted.
repl_binding Optional[ReplBinding] Current REPL binding, when one exists.
created_at datetime When this version was registered.
invalidated_at Optional[datetime] When it was invalidated, if it was.

Class ArtifactKind

Evidence type of an artifact version.

Only DATAFRAME, JSON and TEXT are supported evidence: they have a reproducible canonical fingerprint. BINARY and OBJECT can be catalogued but never carry a verified fingerprint.

Attributes:

Attribute Type Description
is_supported_evidence bool Whether this kind can produce a verifiable fingerprint.

Class ArtifactPayload

Payload for artifact_registered / artifact_invalidated.

Attributes:

Attribute Type Description
kind Literal['artifact'] Discriminator.
ref EvidenceRef The exact artifact version.
alias Optional[str] The working-memory key it was published under.
artifact_kind Optional[ArtifactKind] Evidence type.
availability Optional[ArtifactAvailability] Where its bytes are.
fingerprint Optional[str] Canonical content fingerprint, when computable.
fingerprint_algorithm Optional[str] Algorithm identity and version.
evidence_verifiable bool Whether the fingerprint actually proves content integrity. False for nested mutable or otherwise unsupported values, even when a fingerprint was computable.
byte_size Optional[int] Recorded payload size.
reason Optional[str] Why it was invalidated, when it was.

Class Attribution

How an invocation was attributed to a step (D3).

Attribution never completes a step; it only records what the runtime could truthfully say about which step a call belonged to.

Class CallOutcome

Typed outcome of one physical dispatch attempt.

NOT_EXECUTED covers the manager's early returns (unknown tool, guard denial, authorization required): the dispatch was unsuccessful but no tool body ran. UNKNOWN covers a started call whose terminal result could not be established — it is never automatically retried.

Attributes:

Attribute Type Description
is_resolved bool Whether this outcome settles the attempt's disposition.

Class CompletionMode

How a step is allowed to be completed.

Class CompletionPolicy

How a step is permitted to be marked complete.

Attributes:

Attribute Type Description
mode CompletionMode validated runs every named validator and binds every expected output to an exact artifact version. agent_asserted requires at least one accessible evidence reference plus the required note, and is always labeled as the weaker source.
validators Tuple[str, ...] Code-registered validator names. Unknown names are rejected by the service, which owns the registry.
expected_outputs Tuple[str, ...] Aliases that must resolve to exact artifact versions at completion time.
require_note bool Whether a completion note is mandatory. Always True per spec §2 — kept explicit rather than implied.

Class CompletionSource

How a step actually was completed.

Recall always labels AGENT_ASSERTED as the weaker source.

Class Constraint

One standing constraint on a task.

Attributes:

Attribute Type Description
constraint_id str Runtime identity.
text str The constraint itself.
active bool Whether it still applies. Deactivated constraints are retained for history rather than deleted.
revision int Task revision at which this constraint last changed.

Class CursorError

A pagination cursor was malformed, out of scope, or out of bounds.

Class DeactivateConstraint

Retire a constraint without deleting it.

Attributes:

Attribute Type Description
op Literal['deactivate_constraint'] Discriminator.
constraint_id str The constraint to retire.
reason Optional[str] Why.

Class Decision

A recorded decision affecting the task.

Attributes:

Attribute Type Description
decision_id str Runtime identity.
text str What was decided.
reason str Why.
actor Actor Who decided.
affected_step_ids Tuple[str, ...] Steps the decision bears on.
revision int Task revision at which it was recorded.
active bool Whether it still stands. Superseded decisions are retained.

Class DecisionPayload

Payload for decision_recorded.

Attributes:

Attribute Type Description
kind Literal['decision'] Discriminator.
decision_id str Identity of the recorded decision.
text str What was decided.
reason str Why.
affected_step_ids Tuple[str, ...] Steps the decision bears on.
active bool Whether the decision stands or retires an earlier one.

Class DegradedPayload

Payload for tracking_degraded.

Recorded when best-effort tracking is explicitly enabled and a write could not be persisted. It is a truthful gap marker — it never invents the events that were lost.

Attributes:

Attribute Type Description
kind Literal['degraded'] Discriminator.
component str What degraded (journal, tee, association…).
detail str Human-readable explanation.
recovered bool Whether the gap was later reconciled.

Attribute EventPayload

Class EventType

Every journal event type (spec §2).

The list carries forward the proposal's events and adds the explicit task_blocked, step_cancelled and retention_scheduled variants for transitions that were otherwise unrepresented. Supersession is recorded inside plan_updated.

Attributes:

Attribute Type Description
is_reserved bool Whether this event may use the reserved journal headroom. Terminal, recovery and retention events must remain appendable even when the ordinary journal cap is exhausted (spec §2 Retention), so foreground work is refused before they are.

Class EvidenceRef

An immutable reference to one exact artifact version.

Bare aliases are rejected at the journal boundary: evidence must name artifact_id@version so that overwriting an alias later cannot retroactively change what a completed step proved.

Attributes:

Attribute Type Description
artifact_id str Stable identity of the artifact.
version int 1-based version number within that identity.

Method EvidenceRef.parse

Parse a canonical artifact_id@version string.

parse(value: str) -> 'EvidenceRef'

Parameter Type Default Description
value str The reference text.

Returns: 'EvidenceRef' — The parsed reference.

Raises:

  • ValueError — If value is a bare alias or otherwise malformed. A bare alias is rejected deliberately — it is mutable, and mutable aliases are not evidence.

Class InitialStepSpec

A step in an initial plan, addressed by a request-local label.

An initial plan cannot reference runtime step ids because none exist yet. Labels are resolved to runtime ids before anything is appended, so a malformed initial plan is rejected without mutating the task.

Attributes:

Attribute Type Description
label str Request-local label, unique within this request.
title str Short human-readable label.
description str Longer explanation.
required bool Whether the task can complete without this step.
depends_on_labels Tuple[str, ...] Labels of steps this one depends on. Resolved to runtime ids by the service.
completion_policy CompletionPolicy How the step may be completed.

Class InvocationRecord

One physical dispatch attempt, captured once by the observer (D5).

invocation is the existing compaction :class:~parrot.memory.compaction.models.ToolInvocation — preserved unchanged as the shared normalized payload. Correlation, cancellation and unknown outcomes live here, not as new members of that model's enum, because the same record feeds both the journal and ConversationTurn.tool_invocations.

The dataclass is kept as an opaque object rather than re-declared as a Pydantic model, so this module stays leaf-safe and the compaction serializer keeps ownership of its own shape.

Attributes:

Attribute Type Description
call_id str Identity of this physical attempt.
attempt int 1-based attempt number.
parent_call_id Optional[str] Parent aggregate call, when nested. A parent is distinguishable from its children and is not counted as a second execution of each child.
tool_name str The dispatched tool.
context TaskContext Frozen task context captured at dispatch.
outcome Optional[CallOutcome] Typed outcome of the attempt.
executed bool Whether a tool body actually ran.
error Optional[str] Condensed, redacted error text.
elapsed_ms Optional[int] Wall-clock duration.
started_at datetime When the attempt began.
finished_at Optional[datetime] When it terminated, if it did.
artifact_receipts Tuple[EvidenceRef, ...] Artifact versions this attempt produced.
invocation Optional[Any] The canonical compaction ToolInvocation, or None before the terminal result is known.
degraded bool Whether tracking for this attempt is degraded.
terminal_event_type Optional[EventType] The journal event type this attempt's outcome maps to.

Class JournalEvent

One immutable entry in a task's journal — the source of truth (D6).

Attributes:

Attribute Type Description
event_id str Globally unique runtime identity. The store deduplicates on this before allocating a sequence number: an identical redelivery is a no-op, and reuse with a different payload is rejected.
task_id str The task this event belongs to.
seq int Backend-assigned contiguous sequence. 0 means "not yet appended" — the backend, not the caller, allocates it.
occurred_at datetime Timezone-aware UTC timestamp.
event_type EventType What happened.
actor Actor Who caused it.
turn_id Optional[str] The conversation turn it happened in.
plan_revision int Plan revision in force when it happened.
step_id Optional[str] Step correlation, when known.
call_id Optional[str] Physical attempt correlation, when applicable.
parent_call_id Optional[str] Parent aggregate (e.g. a plan node) when nested.
attribution Attribution How the step correlation was established.
payload EventPayload The typed, bounded payload.

Class LimitExceeded

A bounded field or collection exceeded its configured limit.

Raised before any mutation is attempted, so a rejected command leaves the task exactly as it was.

Parameter Type Default Description
field str Name of the offending field or collection.
limit int The configured bound.
actual int The observed size.
detail str '' Optional extra explanation.

Attributes:

Attribute Type Description
field Name of the offending field or collection.
limit The configured bound.
actual The observed size.

Class Limits

Initial configurable limits from spec §2 Data Models.

These are the hard structural bounds enforced by the models themselves. Operational thresholds that an operator may tune per deployment live in :class:~parrot.tools.working_memory.task_memory. config.TaskMemoryConfig instead.

Attributes:

Attribute Type Description
MAX_OPEN_TASKS_PER_SCOPE int
MAX_STEPS_PER_TASK int
MAX_ACTIVE_CONSTRAINTS int
MAX_ACTIVE_DECISIONS int
MAX_STEP_DEPENDENCIES int
MAX_STEP_EVIDENCE_REFS int
MAX_IDENTIFIER int
MAX_REASON int
MAX_SCHEMA_SUMMARY_BYTES int
MAX_EVENT_PAYLOAD_BYTES int
MAX_GOAL int
MAX_CONSTRAINT_TEXT int
MAX_STEP_TITLE int
MAX_STEP_DESCRIPTION int
MAX_DECISION_TEXT int
MAX_HINT_TEXT int
MAX_POLICY_VALIDATORS int
MAX_POLICY_EXPECTED_OUTPUTS int
MAX_CURSOR int

Attribute PAYLOAD_FAMILY_BY_EVENT

Type: Dict[EventType, str]

Attribute PlanChange

Class PlanChanges

An ordered batch of plan changes, validated before any is applied.

Dependencies, criteria and inputs are validated across the whole batch first; a batch that would produce a cycle, a duplicate id or a missing dependency is rejected in full.

Attributes:

Attribute Type Description
changes Tuple[PlanChange, ...] The operations to apply, in order.
is_empty bool Whether the batch contains no operations.

Class PlanConstraintSpec

A constraint as recorded in a plan_updated event.

Attributes:

Attribute Type Description
constraint_id str Runtime identity, already resolved by the service.
text str The constraint.

Class PlanStepPatch

The fields a plan_updated event changes on an existing step.

None means "leave unchanged" — the patch records exactly what the revision altered, so replay reproduces the same result without needing the pre-image.

Attributes:

Attribute Type Description
step_id str The step to update. Identities are immutable.
title Optional[str] New title, when it changed.
description Optional[str] New description, when it changed.
required Optional[bool] New required flag, when it changed.
depends_on Optional[Tuple[str, ...]] Replacement dependency list, when it changed.
completion_policy Optional[CompletionPolicy] Replacement policy, when it changed.

Class PlanStepSpec

A step as recorded in a plan_updated event.

The journal is the source of truth (D6), so a plan event must carry enough to reconstruct the step. An id-only payload would make the projection, not the journal, the real source of truth — replay could not rebuild a step it had never seen defined.

Attributes:

Attribute Type Description
step_id str Runtime identity, already resolved by the service.
title str Short human-readable label.
description str Longer explanation.
required bool Whether the task can complete without this step.
depends_on Tuple[str, ...] Runtime step ids this one depends on.
completion_policy CompletionPolicy How the step may be completed.

Class PlanUpdatePayload

Payload for plan_updated.

Supersession is recorded here rather than as its own event type, so one plan revision is one event.

The payload carries full step and constraint definitions, not just ids, because the journal is the source of truth: a reducer replaying from an empty state must be able to rebuild the plan.

Attributes:

Attribute Type Description
kind Literal['plan_update'] Discriminator.
added_steps Tuple[PlanStepSpec, ...] Steps introduced by this revision, in order.
updated_steps Tuple[PlanStepPatch, ...] Patches applied to existing steps.
superseded_step_ids Tuple[str, ...] Steps retired by this revision. They keep their evidence and history and never satisfy a dependent's readiness afterwards.
added_constraints Tuple[PlanConstraintSpec, ...] Constraints introduced.
updated_constraints Tuple[PlanConstraintSpec, ...] Constraints reworded.
deactivated_constraint_ids Tuple[str, ...] Constraints retired. Retained for history rather than deleted.
plan_complete Optional[bool] New value of the plan-complete flag, when set.
reason Optional[str] Why the plan changed.
added_step_ids Tuple[str, ...] Ids of the steps this revision introduced.
updated_step_ids Tuple[str, ...] Ids of the steps this revision patched.
added_constraint_ids Tuple[str, ...] Ids of the constraints this revision introduced.
touched_step_ids Tuple[str, ...] Every step id this revision added, patched or superseded.
is_empty bool Whether this revision changes nothing at all.

Class PlanValidationError

A plan change was rejected: cycle, duplicate id, missing dependency, or illegal status.

Class ReducerError

An event could not be reduced: malformed, unsupported, or out of order.

Class ReplBinding

A live binding of an artifact version into a REPL worker.

A PID alone is not a generation identity: a recycled worker with the same PID would be treated as the same generation, so the worker's own session/generation id is what makes a binding checkable.

Attributes:

Attribute Type Description
worker_session_id str Identity of the worker process generation.
worker_generation int Monotonic generation counter within a session.
variable_name str Name the artifact is bound to inside the worker.
ref EvidenceRef The exact artifact version bound.

Class ResumeHint

The agent's own note about what to do next.

stale is derived, not authored: any later event touching the hint's step, that step's dependencies, or its evidence marks it stale. The reducer sets it; nothing else should.

Attributes:

Attribute Type Description
text str The next action.
step_id Optional[str] Optional step the hint refers to.
actor Actor Who recorded it.
revision int Task revision at which it was recorded.
stale bool Whether later events have invalidated it.

Class ResumeHintPayload

Payload for resume_hint_updated.

Attributes:

Attribute Type Description
kind Literal['resume_hint'] Discriminator.
text str The next action.
step_id Optional[str] Optional step the hint refers to.

Class RetentionPayload

Payload for retention_scheduled.

Retention appends its intent before doing destructive work, so the intent is auditable even though terminal deletion necessarily removes the journal that recorded it (spec §2 Retention).

Attributes:

Attribute Type Description
kind Literal['retention'] Discriminator.
policy str Which retention rule fired.
action str What it intends to do.
due_at Optional[datetime] When the action becomes due.
target_refs Tuple[EvidenceRef, ...] Artifact versions the action targets.
archive_uri Optional[str] Where the archive will be written, when configured.

Class RevisionConflict

An expected_revision did not match the task's current revision.

Parameter Type Default Description
task_id str The task the command targeted.
expected int The revision the caller believed was current.
current int The task's actual revision.

Attributes:

Attribute Type Description
task_id The task the command targeted.
expected The revision the caller believed was current.
current The task's actual revision.

Attribute SCHEMA_VERSION

Type: int

Class ScopeViolation

A read or write crossed a bot/user/session boundary.

Class SetPlanComplete

Declare the plan complete (or incomplete again).

Attributes:

Attribute Type Description
op Literal['set_plan_complete'] Discriminator.
plan_complete bool The new flag value.

Class StepPayload

Payload for a step-level transition.

Covers step_started/blocked/completed/failed/ reopened/cancelled.

Attributes:

Attribute Type Description
kind Literal['step'] Discriminator.
step_id str The step that transitioned.
status StepStatus The status it moved to.
evidence_refs Tuple[EvidenceRef, ...] Exact artifact versions bound at completion.
completion_source Optional[CompletionSource] How it was completed, when it was.
note Optional[str] The completion or transition note.
reason Optional[str] Why it blocked or failed (e.g. upstream_reopened).
validator_results Tuple[Tuple[str, bool], ...] Recorded validator outcomes. Replay consumes these; it never re-runs a validator.

Class StepStatus

Lifecycle state of a plan step (spec §2).

Attributes:

Attribute Type Description
is_terminal bool Whether this step will not transition again on its own.

Class SupersedeStep

Retire a step without deleting it.

A removed step becomes superseded and keeps its evidence and history. Superseded steps never satisfy a dependent's readiness.

Attributes:

Attribute Type Description
op Literal['supersede_step'] Discriminator.
step_id str The step to retire.
reason Optional[str] Why it was retired.
replaced_by_label Optional[str] Label of the step replacing it, when the same batch adds one.

Class TaskContext

Immutable per-invocation snapshot of the turn's task context (D3).

A frozen snapshot is taken at each dispatch. A later declaration does not retroactively change an earlier dispatch's snapshot — attribution is never guessed after the fact.

Attributes:

Attribute Type Description
scope TaskScope Trusted runtime scope.
task_id Optional[str] The selected task, when one is selected.
plan_revision int Plan revision in force at dispatch.
turn_id Optional[str] The conversation turn.
declared_step_ids Tuple[str, ...] Steps declared for this turn at dispatch time. Zero gives task-level none; exactly one gives declared; more than one gives task-level ambiguous.
parent_call_id Optional[str] Parent aggregate call, when nested.
plan_run_id Optional[str] Explicit plan-run correlation.
plan_node_id Optional[str] Explicit plan-node correlation. A plan node id is not automatically a domain step id.
plan_item_index Optional[int] Fan-out index within a plan node.
plan_attempt Optional[int] Attempt number within the plan node's retry policy.
mapped_step_id Optional[str] Step id an explicit plan-to-step mapping resolved to. Present only when such a mapping was configured.
attribution Attribution Resolve this snapshot's attribution. An explicit plan-to-task-step mapping overrides the declaration count. Without one, an unmapped plan call stays task-level with plan provenance rather than being attributed to a guessed step.
attributed_step_id Optional[str] The step this invocation is attributed to, if exactly one. Returns None for none, ambiguous and unmapped plan calls — all three are task-level, and attribution never completes a step regardless.

Class TaskLifecyclePayload

Payload for a task-level transition.

Covers task_started/paused/resumed/blocked/ completed/failed/cancelled.

Attributes:

Attribute Type Description
kind Literal['task_lifecycle'] Discriminator.
status TaskStatus The status the task moved to.
goal Optional[str] The goal, recorded on task_started.
reason Optional[str] Why the transition happened.

Class TaskMemoryError

Base class for every task-memory domain error.

Class TaskMemoryUnavailable

Durable task memory could not persist a required record.

Raised before execution when a durable tool_started cannot be written (D8). Best-effort operation requires explicit opt-in and reports tracking_degraded instead.

Class TaskScope

Trusted runtime identity every read and write is checked against.

Supplied by the runtime, never by a tool argument — a model-authored scope would be a cross-user read primitive. chatbot_id is the bot's stable memory_key_id, so attribution and storage location always agree.

Attributes:

Attribute Type Description
chatbot_id str The bot's stable memory_key_id.
user_id str Owner of the conversation.
session_id str The conversation session.

Method TaskScope.cache_key

Return a collision-safe encoded key for this scope.

Components are percent-encoded so that a value containing the separator cannot forge a different scope's key.

cache_key() -> str

Returns: str — An opaque, stable, collision-safe string.

Method TaskScope.matches

Whether other is exactly this scope.

matches(other: 'TaskScope') -> bool

Parameter Type Default Description
other 'TaskScope' The scope to compare against.

Returns: bool — True when every component is equal.

Class TaskState

The pure reducer projection of a task's journal (D6).

The journal is the source of truth; this is a derived, versioned view of it. Active and ready step ids are computed properties, never persisted fields — a stored duplicate would be a second source of truth that could disagree with steps.

Attributes:

Attribute Type Description
task_id str Runtime identity.
scope TaskScope The trusted scope this task belongs to.
goal str What the task is trying to achieve.
constraints Tuple[Constraint, ...] Standing constraints, active and retired.
status TaskStatus Task lifecycle state.
plan_complete bool Whether the plan is declared complete. A task cannot complete while this is False.
plan_revision int Advances only on a plan change.
revision int Advances on every accepted state-changing batch.
steps Tuple[TaskStep, ...] The plan, in insertion order.
decisions Tuple[Decision, ...] Recorded decisions, active and retired.
resume_hint Optional[ResumeHint] The current hint, if any.
created_at datetime When the task was started.
updated_at datetime When it last changed.
terminal_at Optional[datetime] When it reached a terminal status, if it has.
last_event_seq int Highest journal sequence folded into this state.
reducer_version int Version of the reducer that produced it.
steps_by_id Dict[str, TaskStep] Return the plan indexed by step id.
active_step_ids Tuple[str, ...] Ids of steps that are still live work. Derived, never stored: a step is active while it is neither terminal nor failed. failed is included because a failed step remains actionable — failure does not retire it.
ready_step_ids Tuple[str, ...] Ids of pending steps whose dependencies are all completed. Derived, never stored. Superseded, failed and blocked dependencies do not satisfy readiness (spec §2 Reducer Rules) — only completed does.
active_constraints Tuple[Constraint, ...] The constraints that still apply.
active_decisions Tuple[Decision, ...] The decisions that still stand.
can_complete bool Whether the completion guard would currently pass. A task completes only with plan_complete=True and every required, non-superseded step completed. An exhausted partial plan stays active and reports plan_incomplete.

Class TaskStatus

Lifecycle state of a task (spec §2).

Attributes:

Attribute Type Description
is_terminal bool Whether this status accepts no further ordinary mutation.

Class TaskStep

One step in a task's plan.

Attributes:

Attribute Type Description
step_id str Runtime identity. Immutable once created.
title str Short human-readable label.
description str Longer explanation of what the step must achieve.
required bool Whether the task can complete without this step.
depends_on Tuple[str, ...] Step ids that must be completed before this one is ready. Superseded, failed or blocked dependencies do not satisfy readiness.
status StepStatus Current lifecycle state.
completion_policy CompletionPolicy How this step may be completed.
evidence_refs Tuple[EvidenceRef, ...] Exact artifact versions bound as evidence.
attempt_count int Physical attributed attempts, counted once each on their terminal event.
blocked_reason Optional[str] Why the step is blocked, when it is.
created_revision int Task revision at which the step was added.
updated_revision int Task revision at which it last changed.
completion_source Optional[CompletionSource] How it was actually completed, when it was.
completion_note Optional[str] The note recorded at completion.

Class ToolCallPayload

Payload for a tool-call lifecycle event.

Covers tool_started/succeeded/failed/cancelled/ outcome_unknown.

Attributes:

Attribute Type Description
kind Literal['tool_call'] Discriminator.
call_id str Identity of this physical attempt.
tool_name str The dispatched tool.
attempt int 1-based attempt number.
executed bool Whether a tool body actually ran. False for an unknown tool, a guard denial or an authorization requirement.
outcome Optional[CallOutcome] Typed outcome, absent on tool_started.
error Optional[str] Condensed, redacted error text.
elapsed_ms Optional[int] Wall-clock duration.
artifact_refs Tuple[EvidenceRef, ...] Artifact versions produced by this attempt.
counted bool Whether this event is the one that increments the step's attempt count. Exactly one terminal event per physical attempt sets it.

Class UnknownValidatorError

A completion policy named a validator that is not code-registered.

Class UpdateConstraint

Reword an existing constraint.

Attributes:

Attribute Type Description
op Literal['update_constraint'] Discriminator.
constraint_id str The constraint to update.
text str Its new text.

Class UpdateStep

Update an existing step's mutable fields.

Completed criteria and inputs cannot be edited in place: the service rejects such an update and requires an explicit reopen instead.

Attributes:

Attribute Type Description
op Literal['update_step'] Discriminator.
step_id str The step to update. Immutable identity.
title Optional[str] New title, when changing it.
description Optional[str] New description, when changing it.
required Optional[bool] New required flag, when changing it.
depends_on Optional[Tuple[str, ...]] Replacement dependency list, when changing it.
completion_policy Optional[CompletionPolicy] Replacement policy, when changing it.

Function new_id

Return a fresh runtime identity.

new_id() -> str

Returns: str — A uuid4 hex string. Deliberately stdlib: Python 3.11 has no uuid7 and this feature introduces no ULID dependency.

Function serialized_bytes

Return the canonical serialized UTF-8 size of value in bytes.

Payload limits are byte limits, not Pydantic dictionary-item counts (spec §2). orjson with sorted keys is the canonical serializer used throughout the feature.

serialized_bytes(value: Any) -> int

Parameter Type Default Description
value Any Any JSON-serializable value.

Returns: int — Length in bytes of the canonical encoding.

Raises:

  • LimitExceeded — If the value cannot be serialized at all, which makes its size unbounded and therefore unacceptable.

Function utc_now

Return the current time as a timezone-aware UTC datetime.

utc_now() -> datetime

Returns: datetime — datetime.now(timezone.utc).

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally