Skip to content

API Reference parrot.tools.working_memory.task_memory.tools

github-actions[bot] edited this page Nov 10, 2026 · 4 revisions

parrot.tools.working_memory.task_memory.tools

View source

The ten LLM-facing task-memory tools (FEAT-538, spec §2).

Two things live here:

:class:TaskMemory The composition root the toolkit holds privately — config, scope, stores, service, recall reader, and the currently selected task. It is not a tool and is never exposed to a model.

:class:TaskMemoryToolsMixin The ten public async methods the toolkit's existing wm prefix turns into wm_begin_task, wm_update_plan, and so on. Python method names omit the prefix; _resolve_tool_name adds it.

Every one of these is hidden entirely when task memory is disabled: the toolkit appends :data:TASK_TOOL_METHODS to exclude_tools, which _generate_tools already honours. A disabled deployment therefore publishes exactly the tool set it always did (AC13).

Three rules that shape the code below:

  • Reads never mutate. Recall and the two listing tools append no journal events and — importantly — never implicitly select a task. Selecting as a side effect of reading would make a read silently change what every later command means (AC10).
  • An omitted task id resolves only from the authoritative selected association (spec §2). With several open tasks and no selection the answer is needs_task_selection plus a bounded page to choose from. Never similarity, never "the most recent one". Only wm_recall_task accepts an omitted id at all; every command requires an explicit one.
  • Failures are returned as typed data, not raised. A model reacts to a structured answer far better than to a traceback, and the error discriminator is what tells it whether to retry, re-read, or stop.

Class BeginTaskInput

Input for wm_begin_task.

Fields:

Field Type Default Description
goal str What this task must achieve
constraints List[str] Standing constraints that apply throughout
steps List[_StepSpecInput] Initial plan
plan_complete bool False Whether the plan is already complete

Class ListTaskArtifactsInput

Input for wm_list_task_artifacts.

Fields:

Field Type Default Description
task_id str
limit int 50
cursor Optional[str] None Cursor from a previous page

Class ListTaskEventsInput

Input for wm_list_task_events.

Fields:

Field Type Default Description
task_id str
after_seq int 0 Return events strictly after this sequence
limit int 50

Class RecallTaskInput

Input for wm_recall_task.

Fields:

Field Type Default Description
task_id Optional[str] None Task to recall. Omit to use the selected task; never inferred by similarity.
max_tokens int 2500 Budget for the snapshot
recent_calls_limit int 8

Class RecordDecisionInput

Input for wm_record_decision.

Fields:

Field Type Default Description
task_id str
text str What was decided
reason str '' Why
affected_step_ids List[str] Steps the decision bears on

Class SelectTaskInput

Input for wm_select_task.

Fields:

Field Type Default Description
task_id str Task to select for this session

Class SetResumeHintInput

Input for wm_set_resume_hint.

Fields:

Field Type Default Description
task_id str
next_action str What to do next
step_id Optional[str] None

Attribute TASK_TOOL_METHODS

Type: tuple

Class TaskMemory

Private composition root for a task-memory-enabled toolkit.

Deliberately not a tool and never exposed to a model. It bundles the collaborators the toolkit needs and owns the selected-task association.

Selection is read through the turn session when one is bound, so a selection made inside a turn is visible to every child task and thread of that turn — the same reason the session holds its declaration registry by reference rather than in a ContextVar.

Parameter Type Default Description
store Any The task store.
artifacts Any The artifact store.
scope TaskScope Trusted runtime scope. Never taken from a tool argument.
config Optional[TaskMemoryConfig] None Configuration; defaults to :class:TaskMemoryConfig.
association Any None Optional durable association store. Without one the selection is in-process only — which is all Delivery A claims, and is why it must never be advertised as durable.
cache Any None Optional recall cache.
omission_store Any None Optional omission store for recall to probe.

Attributes:

Attribute Type Description
session Any The turn session bound to this context, or None.
task_id Optional[str] The selected task id, or None. Prefers the turn session's selection: it is the object every concurrent branch of a turn shares, so while a turn is in progress it is the authoritative answer.

Method TaskMemory.select

Record the selected task on both the toolkit and the turn.

In-process only. Persisting to the durable association is a separate, awaitable step (:meth:persist_selection) because it does I/O and can fail — and a failure there must not look like a failure to select.

select(task_id: Optional[str]) -> None

Parameter Type Default Description
task_id Optional[str] The task to select, or None to clear.

Method TaskMemory.persist_selection

Record the selection in the durable association, if one is wired.

persist_selection(task_id: str, *, new_task: bool = False) -> bool

Parameter Type Default Description
task_id str The committed task to associate.
new_task bool False Whether this is a freshly created task, which must also join the open set.

Returns: bool — True when the association is authoritative, False when it is degraded or absent. A False here is never a reason to refuse the command: the task is already committed, and the caller must be able to recover it rather than create a second one.

Method TaskMemory.release_selection

Remove a finished task from the durable open set, if one is wired.

release_selection(task_id: str) -> None

Parameter Type Default Description
task_id str The task that reached a terminal status.

Class TaskMemoryToolsMixin

The ten task-memory tools, mixed into the working-memory toolkit.

Every method assumes self._task_memory is a :class:TaskMemory. The toolkit hides all of them when it is None, so they are unreachable in a disabled deployment.

Method TaskMemoryToolsMixin.begin_task

Start a new task with a goal, constraints and an initial plan.

Use this before multi-step work you may need to resume after losing conversational context. The new task becomes the selected one, so later commands can address it without repeating its id.

begin_task(goal: str, constraints: Optional[List[str]] = None, steps: Optional[List[dict]] = None, plan_complete: bool = False) -> dict

Parameter Type Default Description
goal str What this task must achieve.
constraints Optional[List[str]] None Standing constraints that apply throughout.
steps Optional[List[dict]] None Initial plan. Each step carries a request-local label, a title, and optional depends_on_labels referring to other labels here.
plan_complete bool False Whether the plan is already complete. A task cannot complete while its plan is not.

Returns: dict — The runtime task and step ids, the revision, and a compact state summary.

Method TaskMemoryToolsMixin.update_plan

Revise a task's plan: add, update or retire steps and constraints.

The whole batch is validated before anything is written, so a set of changes that would only produce a cycle in combination is rejected without mutating the plan.

update_plan(task_id: str, expected_revision: int, changes: List[dict], reason: Optional[str] = None) -> dict

Parameter Type Default Description
task_id str Task to revise.
expected_revision int The revision you believe is current. A mismatch is reported with the current state rather than silently overwriting someone else's work.
changes List[dict] Operations to apply, in order. Each is discriminated by its op field.
reason Optional[str] None Why the plan is changing.

Returns: dict — The new revision and compact state, or a typed conflict.

Method TaskMemoryToolsMixin.update_step

Move a step to a new status, optionally binding evidence.

Completing a step goes through evidence validation: the refs you give are resolved to exact artifact versions and checked. A tool call that merely succeeded is never on its own evidence that a step is done.

update_step(task_id: str, step_id: str, expected_revision: int, status: str, evidence_refs: Optional[List[str]] = None, note: Optional[str] = None, reason: Optional[str] = None) -> dict

Parameter Type Default Description
task_id str Owning task.
step_id str Step to transition.
expected_revision int The revision you believe is current.
status str Target status.
evidence_refs Optional[List[str]] None Exact artifact_id@version references.
note Optional[str] None Completion or transition note.
reason Optional[str] None Why it blocked or failed.

Returns: dict — The accepted transition, or a typed validation failure.

Method TaskMemoryToolsMixin.record_decision

Record a decision so it survives losing conversational context.

record_decision(task_id: str, text: str, reason: str = '', affected_step_ids: Optional[List[str]] = None) -> dict

Parameter Type Default Description
task_id str Owning task.
text str What was decided.
reason str '' Why.
affected_step_ids Optional[List[str]] None Steps the decision bears on.

Returns: dict — The decision id and the new revision.

Method TaskMemoryToolsMixin.set_resume_hint

Record what to do next, for whoever resumes this task.

set_resume_hint(task_id: str, next_action: str, step_id: Optional[str] = None) -> dict

Parameter Type Default Description
task_id str Owning task.
next_action str The next action to take.
step_id Optional[str] None The step it refers to.

Returns: dict — The saved hint and the new revision.

Method TaskMemoryToolsMixin.select_task

Select which task subsequent commands and recall apply to.

This is the explicit repair for a lost association. Recall never selects a task for you and never guesses one by similarity, so this tool is the only way to re-point the session.

select_task(task_id: str) -> dict

Parameter Type Default Description
task_id str Task to select. Validated to exist in this scope before the association is changed.

Returns: dict — The validated selection and a compact state summary.

Method TaskMemoryToolsMixin.update_task

Pause, resume, block, fail, cancel or complete a task.

Completion is gated by the reducer: a task completes only once its plan is declared complete and every required step is done.

update_task(task_id: str, expected_revision: int, status: str, reason: Optional[str] = None) -> dict

Parameter Type Default Description
task_id str Task to transition.
expected_revision int The revision you believe is current.
status str Target status.
reason Optional[str] None Why.

Returns: dict — The new status and revision, or a typed refusal.

Method TaskMemoryToolsMixin.recall_task

Recover a task's actionable state in one bounded read.

Read-only: appends nothing, loads no payloads, runs no tools, and does not select a task. Omitting task_id uses the already selected task; when several are open and none is selected you are asked to choose from a bounded list — never guessed at.

recall_task(task_id: Optional[str] = None, max_tokens: int = 2500, recent_calls_limit: int = 8) -> dict

Parameter Type Default Description
task_id Optional[str] None Task to recall, or None for the selected one.
max_tokens int 2500 Budget for the snapshot.
recent_calls_limit int 8 How many recent tool calls to include.

Returns: dict — A budgeted snapshot with truncation accounting, or a typed needs_task_selection / budget_too_small answer.

Method TaskMemoryToolsMixin.list_task_events

Page a task's journal in sequence order. Read-only.

list_task_events(task_id: str, after_seq: int = 0, limit: int = 50) -> dict

Parameter Type Default Description
task_id str Task to read.
after_seq int 0 Return events strictly after this sequence.
limit int 50 Bounded page size.

Returns: dict — The events and the next sequence to resume from.

Method TaskMemoryToolsMixin.list_task_artifacts

Page a task's artifact versions. Read-only, metadata only.

Returns descriptors — never rows, payloads or summaries.

list_task_artifacts(task_id: str, limit: int = 50, cursor: Optional[str] = None) -> dict

Parameter Type Default Description
task_id str Task to read.
limit int 50 Bounded page size.
cursor Optional[str] None Opaque cursor from a previous page.

Returns: dict — Version descriptors and the next cursor.

Class UpdatePlanInput

Input for wm_update_plan.

Fields:

Field Type Default Description
task_id str Task to revise
expected_revision int The revision you believe is current
changes List[dict] Operations to apply, in order. Each carries an 'op' of: add_step, update_step, supersede_step, add_constraint, update_constraint, deactivate_constraint, set_plan_complete.
reason Optional[str] None Why the plan is changing

Class UpdateStepInput

Input for wm_update_step.

Fields:

Field Type Default Description
task_id str
step_id str
expected_revision int The revision you believe is current
status str One of: pending, running, blocked, completed, failed, cancelled, superseded
evidence_refs List[str] Exact artifact versions as 'artifact_id@version'. A bare alias is rejected.
note Optional[str] None Completion or transition note
reason Optional[str] None Why it blocked or failed

Class UpdateTaskInput

Input for wm_update_task.

Fields:

Field Type Default Description
task_id str
expected_revision int The revision you believe is current
status str One of: active, paused, blocked, completed, failed, cancelled
reason Optional[str] None

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