Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(backend/copilot): finish the memory stack's review follow-ups (#15834)

Nicholas Tindle37aeae3724d2
diff --git a/autogpt_platform/backend/backend/api/features/admin/memory_admin_routes.py b/autogpt_platform/backend/backend/api/features/admin/memory_admin_routes.py
index 699cbafe17..01d7ca67f7 100644
--- a/autogpt_platform/backend/backend/api/features/admin/memory_admin_routes.py
+++ b/autogpt_platform/backend/backend/api/features/admin/memory_admin_routes.py
@@ -1012,18 +1012,28 @@ class CommunityRebuildJobStatus(JobStatus[RebuildResult]):
"""JobStatus envelope for ``kind="rebuild"``."""
+class PublicDreamPassRecord(DreamPassRecord):
+ """Admin-visible pass record without the live lock credential."""
+
+ lease_token: str | None = Field(default=None, exclude=True)
+
+
+def _public_pass_record(record: DreamPassRecord) -> PublicDreamPassRecord:
+ return PublicDreamPassRecord.model_validate(record.model_dump())
+
+
class DreamPassRecordResponse(BaseModel):
"""One dream pass's durable record, and the ``DreamPassResult`` read off
it: what the eval driver scores, with usage for batch passes too."""
- record: DreamPassRecord
+ record: PublicDreamPassRecord
result: DreamPassResult
class DreamPassListResponse(BaseModel):
"""A user's dream passes, every scope, newest first."""
- passes: list[DreamPassRecord]
+ passes: list[PublicDreamPassRecord]
# What a cancelled pass's record says when the admin gave no reason.
@@ -1142,7 +1152,7 @@ async def list_dream_pass_records(
jwt_payload=jwt_payload,
)
passes = await read_user_passes(target, open_only=status == "open", limit=limit)
- return DreamPassListResponse(passes=passes)
+ return DreamPassListResponse(passes=[_public_pass_record(row) for row in passes])
@router.get(
@@ -1202,7 +1212,7 @@ async def get_dream_pass_record(
if record is None:
raise HTTPException(status_code=404, detail="dream pass not found")
return DreamPassRecordResponse(
- record=record, result=dream_pass_result_from_row(record)
+ record=_public_pass_record(record), result=dream_pass_result_from_row(record)
)
@@ -1244,7 +1254,8 @@ async def cancel_dream_pass_run(
ended = cancel.record.status.value.lower()
raise HTTPException(status_code=409, detail=f"dream pass already {ended}")
return DreamPassRecordResponse(
- record=cancel.record, result=dream_pass_result_from_row(cancel.record)
+ record=_public_pass_record(cancel.record),
+ result=dream_pass_result_from_row(cancel.record),
)
diff --git a/autogpt_platform/backend/backend/api/features/admin/memory_admin_routes_test.py b/autogpt_platform/backend/backend/api/features/admin/memory_admin_routes_test.py
index 35c7335ed3..ca13855c75 100644
--- a/autogpt_platform/backend/backend/api/features/admin/memory_admin_routes_test.py
+++ b/autogpt_platform/backend/backend/api/features/admin/memory_admin_routes_test.py
@@ -925,6 +925,7 @@ class TestDreamPassRecord:
read.assert_awaited_once_with("p1", user_id="abc")
body = resp.json()
assert body["record"]["id"] == "p1"
+ assert "lease_token" not in body["record"]
assert body["record"]["status"] == "COMPLETE"
assert body["record"]["trigger"] == "EVAL"
result = body["result"]
@@ -1033,6 +1034,7 @@ class TestCancelDreamPass:
"CANCELLED",
1,
)
+ assert "lease_token" not in body["record"]
assert body["result"]["error"] == "testing"
assert body["result"]["skipped"] is False
@@ -1139,6 +1141,15 @@ class TestDreamPassList:
assert [p["id"] for p in passes] == ["p2", "p1"]
assert passes[0]["status"] == "COMPLETE"
+ def test_list_omits_live_lease_tokens(self) -> None:
+ row = _dream_pass_row("abc")
+ with patch(
+ f"{_MOCK_MODULE}.read_user_passes", new=AsyncMock(return_value=[row])
+ ):
+ resp = client.get("/admin/memory/abc/dream/passes")
+ assert resp.status_code == 200
+ assert "lease_token" not in resp.json()["passes"][0]
+
def test_the_open_ones_only_and_a_limit_reach_the_read(self) -> None:
read = AsyncMock(return_value=[])
with patch(f"{_MOCK_MODULE}.read_user_passes", new=read):
diff --git a/autogpt_platform/backend/backend/copilot/db_dream_narrative_test.py b/autogpt_platform/backend/backend/copilot/db_dream_narrative_test.py
index e00ba96f31..735670c85c 100644
--- a/autogpt_platform/backend/backend/copilot/db_dream_narrative_test.py
+++ b/autogpt_platform/backend/backend/copilot/db_dream_narrative_test.py
@@ -12,7 +12,6 @@ the write leaves no narrative behind (the review's cancelled-apply race)."""
import asyncio
import logging
-import time
import uuid
from collections.abc import AsyncIterator, Awaitable, Callable
from datetime import datetime, timezone
@@ -28,7 +27,6 @@ from backend.util.json import SafeJson
from . import db as chat
from .db import (
DREAM_READ_UUIDS,
- NARRATIVE_BLANK_STATEMENT_TIMEOUT_MS,
add_dream_narrative,
blank_dream_narratives,
clear_session_pending_question,
@@ -409,11 +407,9 @@ async def test_a_write_that_lands_first_is_found_by_the_forgets_blank(make_user)
assert await _contents(session_id) == ["[forgotten]"]
-async def test_the_blank_over_3000_dream_sessions_is_in_time(make_user):
- """The cost check's other half: 3,000 dream sessions each holding a
- 550-uuid read set and a narrative, against 1,000 reached uuids read by
- none, then one read by every pass, well inside the statement's
- timeout."""
+async def test_the_blank_over_3000_dream_sessions_meets_database_deadline(make_user):
+ """The database statement timeout bounds 3,000 dream sessions, each
+ holding a 550-uuid read set, on both selective and all-match reads."""
owner = await make_user()
shared = "fact-read-by-every-pass"
await db.execute_raw_with_schema(
@@ -438,17 +434,11 @@ async def test_the_blank_over_3000_dream_sessions_is_in_time(make_user):
owner,
_NARRATIVE,
)
- budget = NARRATIVE_BLANK_STATEMENT_TIMEOUT_MS / 1000 / 2
unread = [str(uuid.uuid4()) for _ in range(1000)]
- started = time.monotonic()
assert await blank_dream_narratives(owner, None, [], unread, "[forgotten]") == 0
- selection = time.monotonic() - started
- started = time.monotonic()
blanked = await blank_dream_narratives(
owner, None, [], [*unread[1:], shared], "[forgotten]"
)
- every = time.monotonic() - started
assert blanked == 3000
- assert selection < budget and every < budget, (selection, every)
diff --git a/autogpt_platform/backend/backend/copilot/dream/batch_callbacks.py b/autogpt_platform/backend/backend/copilot/dream/batch_callbacks.py
index 7fe0aa0f45..f8c2800dee 100644
--- a/autogpt_platform/backend/backend/copilot/dream/batch_callbacks.py
+++ b/autogpt_platform/backend/backend/copilot/dream/batch_callbacks.py
@@ -38,6 +38,7 @@ from pydantic import BaseModel, ValidationError
from backend.copilot.graphiti.scope import MemoryScope
from backend.copilot.inference.context import InferenceError
+from backend.copilot.inference.parse_output import parse_json_with_prose_fallback
from backend.copilot.trial_cost_context import TrialCostContext, restore_cost_context
from backend.copilot.usage_activation import UsageActivationUnavailable
@@ -63,7 +64,6 @@ from .cancel import end_batch_pass_if_stopped, pass_closed
from .citations import fact_scopes
from .clamp import clamp_pass_operations
from .lease import ApplyLease, admit_batch_apply, renew_batch_lease
-from .llm import parse_json_with_prose_fallback
from .locks import DreamLockLostError
from .pass_errors import pass_error
from .provider_batch import anthropic_api_key
diff --git a/autogpt_platform/backend/backend/copilot/dream/batch_submit.py b/autogpt_platform/backend/backend/copilot/dream/batch_submit.py
index 762f070f63..aed8b8cc4e 100644
--- a/autogpt_platform/backend/backend/copilot/dream/batch_submit.py
+++ b/autogpt_platform/backend/backend/copilot/dream/batch_submit.py
@@ -25,6 +25,10 @@ from typing import TYPE_CHECKING, Literal
from pydantic import BaseModel
from backend.copilot.graphiti.scope import MemoryScope
+from backend.copilot.inference.structured_output import (
+ OUTPUT_TOOL_CALL_ONCE,
+ with_output_tool_instruction,
+)
from backend.copilot.model_normalize import normalize_model_for_anthropic
from backend.copilot.trial_cost_context import capture_cost_context
from backend.executor.batch_executor import (
@@ -54,7 +58,6 @@ from .prompts import (
build_sanitize_prompt,
)
from .schemas import ConsolidationOutput, DreamOperations, RecombinationOutput
-from .structured_output import OUTPUT_TOOL_CALL_ONCE, with_output_tool_instruction
if TYPE_CHECKING:
from backend.copilot.config import ChatConfig
@@ -370,9 +373,8 @@ async def persist_input_bundle(
explicitly — reading the live lock key here instead could capture a
*newer* pass's token (lock expired and was re-acquired between this
pass's acquire and the persist), letting this pass's callback release
- a lock it doesn't own hours later. Only when no token is supplied
- (eval harness calling the batch path without a lock) do we fall back
- to the live key.
+ a lock it doesn't own hours later. When no token is supplied we fall
+ back to the live key; apply requires a lease before writing.
"""
from backend.data.redis_client import get_redis_async
diff --git a/autogpt_platform/backend/backend/copilot/dream/batch_submit_test.py b/autogpt_platform/backend/backend/copilot/dream/batch_submit_test.py
index f82558be0d..4571babb6b 100644
--- a/autogpt_platform/backend/backend/copilot/dream/batch_submit_test.py
+++ b/autogpt_platform/backend/backend/copilot/dream/batch_submit_test.py
@@ -31,8 +31,8 @@ from backend.copilot.dream.batch_submit import (
)
from backend.copilot.dream.fetch import DreamInput
from backend.copilot.dream.schemas import ConsolidationOutput
-from backend.copilot.dream.structured_output import OUTPUT_TOOL_CALL_ONCE
from backend.copilot.graphiti.scope import DREAM_LOCK_KEY_PREFIX, MemoryScope
+from backend.copilot.inference.structured_output import OUTPUT_TOOL_CALL_ONCE
from backend.util.llm.providers import BatchSubmissionRef
from backend.util.llm.tool_use import (
auto_tool_choice,
diff --git a/autogpt_platform/backend/backend/copilot/dream/cancel.py b/autogpt_platform/backend/backend/copilot/dream/cancel.py
index 4acbc611b3..619f80d903 100644
--- a/autogpt_platform/backend/backend/copilot/dream/cancel.py
+++ b/autogpt_platform/backend/backend/copilot/dream/cancel.py
@@ -45,6 +45,7 @@ must not end work that nobody cancelled. The lock checks fail closed: a pass
that cannot confirm its lock does not apply.
"""
+import json
import logging
from collections.abc import Awaitable
from typing import Literal
@@ -101,7 +102,11 @@ async def cancel_dream_pass(
)
record = await read_dream_pass(pass_id, user_id=user_id)
if closed:
- logger.info(f"Dream pass {pass_id} cancelled: {reason}")
+ logger.info(
+ "Dream pass %s cancelled: %s",
+ pass_id,
+ json.dumps(reason, ensure_ascii=False),
+ )
if closed and record is not None and record.provider_batch_id:
await cancel_provider_batch(record.provider_batch_id)
return DreamPassCancel(cancelled=closed, record=record)
diff --git a/autogpt_platform/backend/backend/copilot/dream/cancel_test.py b/autogpt_platform/backend/backend/copilot/dream/cancel_test.py
index 5081a2103c..d4b13bf389 100644
--- a/autogpt_platform/backend/backend/copilot/dream/cancel_test.py
+++ b/autogpt_platform/backend/backend/copilot/dream/cancel_test.py
@@ -182,6 +182,17 @@ class TestCancelDreamPass:
assert update.error == "cancelled: by_admin"
assert "Alice runs Atlas" in caplog.text
+ async def test_an_admin_reason_cannot_forge_log_lines(self, db, caplog):
+ with caplog.at_level(logging.INFO, logger=cancel.logger.name):
+ await cancel_dream_pass(
+ "p1", user_id="u1", reason="requested\nERROR forged\x1b[31m"
+ )
+
+ assert len(caplog.records) == 1
+ message = caplog.records[0].getMessage()
+ assert "\n" not in message and "\x1b" not in message
+ assert r"\nERROR forged\u001b" in message
+
@pytest.mark.parametrize(
"stalled",
[lambda db: db.update_dream_pass, lambda db: db.get_dream_pass_for_user],
diff --git a/autogpt_platform/backend/backend/copilot/dream/citations.py b/autogpt_platform/backend/backend/copilot/dream/citations.py
index a05d82c3fd..30a7e04d2d 100644
--- a/autogpt_platform/backend/backend/copilot/dream/citations.py
+++ b/autogpt_platform/backend/backend/copilot/dream/citations.py
@@ -25,9 +25,9 @@ forgets made since the pass read the graph (``graphiti/recall_citations.py``)
and then records it on the dream's episode and on the facts only dream
episodes state (``graphiti/recall_derivation.py``). A later forget of
anything it cites retracts those facts (``graphiti/recall_cascade.py``). The
-episode's free-text ``source_description`` no longer lists what it cites:
-the marker and the records carry that, and only the derivation backfill
-reads the lists older descriptions hold
+episode's free-text ``source_description`` omits citations; the marker
+and the records carry them. The derivation backfill reads citation lists
+in older descriptions
(``graphiti/migrations/legacy_citations.py``).
"""
diff --git a/autogpt_platform/backend/backend/copilot/dream/llm_test.py b/autogpt_platform/backend/backend/copilot/dream/llm_test.py
index b31e38e5ac..c8d42573c8 100644
--- a/autogpt_platform/backend/backend/copilot/dream/llm_test.py
+++ b/autogpt_platform/backend/backend/copilot/dream/llm_test.py
@@ -16,18 +16,17 @@ import pytest
from pydantic import BaseModel
from backend.copilot.inference.context import InferenceError, InferenceUsage
-from backend.util.llm.tool_use import auto_tool_choice, force_tool_choice
-
-from .llm import (
+from backend.copilot.inference.parse_output import (
_extract_first_json_object,
_strip_json_code_fence,
parse_structured_output,
)
-from .structured_output import (
+from backend.copilot.inference.structured_output import (
output_tool_name,
structured_request,
with_output_tool_instruction,
)
+from backend.util.llm.tool_use import auto_tool_choice, force_tool_choice
@pytest.mark.parametrize(
diff --git a/autogpt_platform/backend/backend/copilot/dream/pass_record.py b/autogpt_platform/backend/backend/copilot/dream/pass_record.py
index 261de43462..666e163c3e 100644
--- a/autogpt_platform/backend/backend/copilot/dream/pass_record.py
+++ b/autogpt_platform/backend/backend/copilot/dream/pass_record.py
@@ -46,7 +46,13 @@ from .fetch import DreamInput
from .locks import DEFAULT_LOCK_TTL_SECONDS
from .pass_errors import is_pass_error, pass_error
from .routing import ExecutionPath
-from .schemas import DreamOperations, DreamPassResult, DreamPassUsage, DreamPhase
+from .schemas import (
+ DreamOperations,
+ DreamPassResult,
+ DreamPassUsage,
+ DreamPhase,
+ IngestionDrainStatus,
+)
# What started a pass: the nightly job, the admin trigger, or an eval run.
DreamTrigger = Literal["cron", "admin", "eval"]
@@ -343,6 +349,18 @@ def stop_error(row: DreamPassRecord) -> str | None:
return pass_error("expired", "stopped")
+def _drain_status(row: DreamPassRecord) -> IngestionDrainStatus:
+ """What *row* says of its writes' drain. Only an applied record knows.
+ Without one, a pass that never recorded apply starting (``applying``)
+ never applied; one that did may have applied before it ended, so its
+ drain is unknown."""
+ if row.operations.applied is not None:
+ return row.operations.applied.ingestion_drain_status
+ if row.operations.planned is None:
+ return IngestionDrainStatus.not_applied
+ return IngestionDrainStatus.unknown
+
+
def dream_pass_result_from_row(row: DreamPassRecord) -> DreamPassResult:
"""The ``DreamPassResult`` a pass's row describes, on either route.
@@ -372,7 +390,7 @@ def dream_pass_result_from_row(row: DreamPassRecord) -> DreamPassResult:
demotion_accounting_complete=applied.demotion_accounting_complete,
summary_for_user=applied.summary_for_user,
dream_session_id=applied.dream_session_id,
- ingestion_drain_status=applied.ingestion_drain_status,
+ ingestion_drain_status=_drain_status(row),
operations=applied.snapshot,
usage=row.usage,
error=row.error,
diff --git a/autogpt_platform/backend/backend/copilot/dream/routing.py b/autogpt_platform/backend/backend/copilot/dream/routing.py
index 4a965f6feb..2e62fbb8a5 100644
--- a/autogpt_platform/backend/backend/copilot/dream/routing.py
+++ b/autogpt_platform/backend/backend/copilot/dream/routing.py
@@ -10,17 +10,10 @@ existing ``copilot_executor``.
from __future__ import annotations
-from typing import Literal
-
from backend.copilot.config import TransportName
+from backend.copilot.inference.execution_path import ExecutionPath, batch_discount
-# The single source of truth for execution paths; ``billing``,
-# ``orchestrator`` and ``schemas`` import it from here.
-ExecutionPath = Literal["sync_baseline", "anthropic_batch"]
-
-# Anthropic's Message Batches API bills half the synchronous list price.
-_ANTHROPIC_BATCH_DISCOUNT = 0.5
-
+__all__ = ["ExecutionPath", "batch_discount", "resolve_dream_execution_path"]
# Transports that cannot honour the batch path even when an Anthropic key
# is configured separately.
@@ -64,13 +57,3 @@ def resolve_dream_execution_path(
if batch_processing_enabled and has_anthropic_key:
return "anthropic_batch"
return "sync_baseline"
-
-
-def batch_discount(path: ExecutionPath) -> float:
- """The share of the list price the provider takes off on *path*: half
- on Anthropic's Message Batches API, nothing on the sync path.
-
- Priced into the dream's cost rows and recorded next to them as
- ``discount_applied``.
- """
- return _ANTHROPIC_BATCH_DISCOUNT if path == "anthropic_batch" else 0.0
diff --git a/autogpt_platform/backend/backend/copilot/dream/schemas.py b/autogpt_platform/backend/backend/copilot/dream/schemas.py
index 668de2d4b8..ecb60be810 100644
--- a/autogpt_platform/backend/backend/copilot/dream/schemas.py
+++ b/autogpt_platform/backend/backend/copilot/dream/schemas.py
@@ -30,7 +30,7 @@ class IngestionDrainStatus(str, Enum):
"""Fate of a dream pass's enqueued graph writes at the moment the pass
was reported complete.
- Three distinct states, so consumers (and a future Memory Visualizer)
+ Five distinct states, so consumers (and a future Memory Visualizer)
can tell a healthy by-design skip from a real failure:
* ``drained`` — the worker finished every one of the pass's own
@@ -41,6 +41,11 @@ class IngestionDrainStatus(str, Enum):
a shared serial loop (batch path). The episodes process
fire-and-forget, counted pending; healthy by design, NOT a failure
signal.
+ * ``not_applied`` — this pass never began applying, so no drain ran.
+ * ``unknown`` — this pass began applying but recorded no outcome: it
+ may still be applying, or have applied before it ended (a cancel
+ after its last check does not stop an apply), or failed partway. Its
+ writes may have been enqueued, so whether they drained is not known.
* ``timed_out`` — the sync-path drain was attempted but did not finish
within its budget. The episodes not written yet are counted pending,
not written; they stay queued in-process, and are lost if the
@@ -48,6 +53,8 @@ class IngestionDrainStatus(str, Enum):
operator warning.
"""
+ not_applied = "not_applied"
+ unknown = "unknown"
drained = "drained"
skipped = "skipped"
timed_out = "timed_out"
diff --git a/autogpt_platform/backend/backend/copilot/dream/store.py b/autogpt_platform/backend/backend/copilot/dream/store.py
index 0f7cf025b7..c166cc8072 100644
--- a/autogpt_platform/backend/backend/copilot/dream/store.py
+++ b/autogpt_platform/backend/backend/copilot/dream/store.py
@@ -22,10 +22,10 @@ its first model call. So a stalled DatabaseManager costs
a pass at most that deadline per write, and the nightly fan-out and the batch
walker keep moving.
-The row is additive to the Redis state: the lock, the batch state and the
-admin job status keep their keys, TTLs, scripts and formats. What changed is
-timing: the pass now waits on these bounded writes before it locks, inside the
-lock, before it chains a batch or applies, and before it cleans up.
+The row coexists with Redis state: the lock, batch state and admin job status
+keep their keys, TTLs, scripts and formats. The pass waits on bounded record
+writes before it locks, while holding the lock, before it chains a batch or
+applies, and before it cleans up.
``read_dream_pass`` is the read side, for the admin API and the eval driver;
``read_cost_context`` reads the usage attribution every charge of a pass's
diff --git a/autogpt_platform/backend/backend/copilot/dream/store_test.py b/autogpt_platform/backend/backend/copilot/dream/store_test.py
index 6893d642e1..b7d9a7e12f 100644
--- a/autogpt_platform/backend/backend/copilot/dream/store_test.py
+++ b/autogpt_platform/backend/backend/copilot/dream/store_test.py
@@ -613,6 +613,29 @@ class TestReadSide:
False,
)
+ def test_a_pass_without_apply_did_not_drain(self):
+ for status in (
+ DreamPassStatus.SUBMITTED,
+ DreamPassStatus.SKIPPED,
+ DreamPassStatus.ERRORED,
+ ):
+ row = _row(status=status, operations=DreamPassOperations())
+ result = dream_pass_result_from_row(row)
+ assert result.ingestion_drain_status.value == "not_applied"
+
+ def test_a_pass_that_began_applying_without_an_outcome_is_unknown(self):
+ """Cancelled after its last check, or failed mid-apply: its writes may
+ have been enqueued, so neither "drained" nor "not applied" is true."""
+ planned = DreamPassOperations(planned=DreamOperations(summary_for_user="x"))
+ for status in (
+ DreamPassStatus.APPLYING,
+ DreamPassStatus.CANCELLED,
+ DreamPassStatus.ERRORED,
+ ):
+ row = _row(status=status, operations=planned)
+ result = dream_pass_result_from_row(row)
+ assert result.ingestion_drain_status.value == "unknown"
+
def test_a_pass_in_flight_has_no_end_yet(self):
row = _row(
route=DreamPassRoute.ANTHROPIC_BATCH,
diff --git a/autogpt_platform/backend/backend/copilot/graphiti/AGENTS.md b/autogpt_platform/backend/backend/copilot/graphiti/AGENTS.md
index 754f1df6c4..830e1960a7 100644
--- a/autogpt_platform/backend/backend/copilot/graphiti/AGENTS.md
+++ b/autogpt_platform/backend/backend/copilot/graphiti/AGENTS.md
@@ -36,7 +36,7 @@ Runtime prompt instructions live in `prompting.py:get_graphiti_supplement()`.
## Dream Schedules
-A memory scope (the account, or one hired expert) that has been registered has one `MemoryScopeSchedule` row. While that row is ACTIVE, the scope runs weekly community maintenance, `community_rebuild_{scope_key}` (weekly, 04:00 owner-local on Mondays: APScheduler reads the `0` in `0 4 * * 0` as Monday), and the independently flag-gated nightly dream, `dream_nightly_batch_{scope_key}` (daily, 03:00 owner-local). The account's scope key is its user id, so its job ids predate the table. The table decides whether a scope is scheduled; `copilot/dream/registry.py` keeps it in step:
+A memory scope (the account, or one hired expert) that has been registered has one `MemoryScopeSchedule` row. While that row is ACTIVE, the scope runs weekly community maintenance, `community_rebuild_{scope_key}` (weekly, 04:00 owner-local on Mondays: APScheduler reads the `0` in `0 4 * * 0` as Monday), and the independently flag-gated nightly dream, `dream_nightly_batch_{scope_key}` (daily, 03:00 owner-local). The account's scope also runs nightly skill learning, `skill_learning_nightly_{scope_key}` (daily, 03:00 owner-local; its recorded `learning_job_id`, gated by `Flag.DREAM_SKILL_LEARNING_ENABLED`). The account's scope key is its user id, so its job ids predate the table. The table decides whether a scope is scheduled; `copilot/dream/registry.py` keeps it in step:
- **Registration.** Ingest registers a scope when its group's queue is created: the group's first write in a process, and again whenever the queue comes back after retiring (60 s idle), with at most one registration in flight per group. A hire or raise registers the expert in the background. Registration never reactivates a PAUSED or WIPED scope. Community maintenance needs no feature flag; the dream and account-only skill learning keep their independent gates.
- **Lifecycle.** Archive and a schedule pause (including a budget breach) pause the expert's scope and remove its crons; the resume route and a revive resume a PAUSED scope (or register one that has no row). A lifecycle change the deadline cuts off is not retried: the cron gate still keeps an archived or paused expert's crons from running, and a later lifecycle change or the backfill settles the row (an ordinary registration does not look at the expert's lifecycle). `mark_wiped` is a seam for the wipe work: nothing calls it yet and it does not erase the graph. No registry operation takes a scope out of WIPED: registration and resume skip it, and pause or archive leave it WIPED (a pause only moves an ACTIVE or PAUSED row, checked in the same statement), so the wipe work decides what brings one back.
diff --git a/autogpt_platform/backend/backend/copilot/graphiti/client_test.py b/autogpt_platform/backend/backend/copilot/graphiti/client_test.py
index 0b220fdb81..a50eac30c6 100644
--- a/autogpt_platform/backend/backend/copilot/graphiti/client_test.py
+++ b/autogpt_platform/backend/backend/copilot/graphiti/client_test.py
@@ -356,6 +356,8 @@ class TestMakeFlexGraphitiClient:
monkeypatch,
ChatConfig(
use_openrouter=True,
+ use_claude_code_subscription=False,
+ use_local=False,
api_key="or-key",
base_url="https://openrouter.ai/api/v1",
),
diff --git a/autogpt_platform/backend/backend/copilot/graphiti/fact_attributes_integration_test.py b/autogpt_platform/backend/backend/copilot/graphiti/fact_attributes_integration_test.py
index c7a7426629..44de42761a 100644
--- a/autogpt_platform/backend/backend/copilot/graphiti/fact_attributes_integration_test.py
+++ b/autogpt_platform/backend/backend/copilot/graphiti/fact_attributes_integration_test.py
@@ -51,6 +51,7 @@ from .recall_integration_fixtures import (
stop_ingestion_workers,
)
from .scope import MemoryScope
+from .types import MemoryFact
_PARAPHRASE: Fact = ("Alice", "Atlas", "Alice is working on Atlas")
_TENTATIVE = {"status": "tentative", "scope": "real:global"}
@@ -185,6 +186,36 @@ async def test_a_merged_restatement_leaves_every_attribute_as_it_was(
assert "MemoryFact" not in asked
+async def test_an_attribute_less_stored_memory_fact_seeds_attributes_on_restatement(
+ scope_graph, stub_graphiti_client, ingest_worker_cleanup
+) -> None:
+ driver, scope = scope_graph
+ uuid = await _stamped_fact(driver, scope, stub_graphiti_client, "MemoryFact")
+ await driver.execute_query(
+ "MATCH ()-[e:RELATES_TO {uuid: $uuid}]->() SET e += $cleared",
+ uuid=uuid,
+ cleared={key: None for key in set(STAMPS) | set(MemoryFact.model_fields)},
+ )
+ before = await edge_properties(driver, uuid)
+ assert not (set(before) & (set(STAMPS) | set(MemoryFact.model_fields)))
+
+ episode, asked = await _restate(
+ driver, scope, stub_graphiti_client, _PARAPHRASE, duplicate_of={ALICE[2]}
+ )
+
+ after = await edge_properties(driver, uuid)
+ assert "MemoryFact" in asked
+ assert after["status"] == "tentative"
+ assert after["scope"] == "real:global"
+ assert episode in after["episodes"]
+ seeded = set(MemoryFact.model_fields) | {"episodes"}
+ assert {k: v for k, v in after.items() if k not in seeded} == {
+ k: v for k, v in before.items() if k not in seeded
+ }
+
+
@pytest.mark.integration
@pytest.mark.asyncio
async def test_the_same_sentence_again_leaves_every_attribute_as_it_was(
diff --git a/autogpt_platform/backend/backend/copilot/graphiti/guarded_writes.py b/autogpt_platform/backend/backend/copilot/graphiti/guarded_writes.py
index 5d1ef869a1..7ef7fb5b90 100644
--- a/autogpt_platform/backend/backend/copilot/graphiti/guarded_writes.py
+++ b/autogpt_platform/backend/backend/copilot/graphiti/guarded_writes.py
@@ -6,7 +6,7 @@ pass's demotions, and the ratification sweep's supersession of an unratified
proposal. ``invalidate_entity_direct_neighbors`` demotes every live fact on one
entity, single-hop, for the dream's entity invalidations. It has no degree
cap: a hub is invalidated whole, behind the ``dream-pass-invalidate-entity``
-flag, as before recall stamps.
+flag.
Each statement writes only over a live fact (``recall.live_fact_predicate``),
so it can never overwrite a user's forget. Each also tests
@@ -218,6 +218,8 @@ async def _supersede_one(
def _now_iso() -> str:
"""Now, as the ISO-8601 string written to ``expired_at``. FalkorDB has no
no-arg ``datetime()``, so the time is bound from Python."""
+ # Keep the plain datetime spelling for expired_at; stamp_time() belongs
+ # to recall stamps and has a different precision contract.
return datetime.now(timezone.utc).isoformat()
diff --git a/autogpt_platform/backend/backend/copilot/graphiti/ingest_recall_test.py b/autogpt_platform/backend/backend/copilot/graphiti/ingest_recall_test.py
index 27cb15f21d..74a267ef64 100644
--- a/autogpt_platform/backend/backend/copilot/graphiti/ingest_recall_test.py
+++ b/autogpt_platform/backend/backend/copilot/graphiti/ingest_recall_test.py
@@ -28,6 +28,12 @@ _LOCK = write_lock_key("user_test")
_STORED = [
{"uuid": "ep-newest", "redacted": False, "entity_edges": ["kept"]},
{"uuid": "ep-redacted", "redacted": True, "entity_edges": []},
+ {
+ "uuid": "ep-pending",
+ "redacted": False,
+ "entity_edges": [],
+ "write_pending": True,
+ },
{"uuid": "ep-cites-a-forgotten-fact", "redacted": False, "entity_edges": ["gone"]},
{"uuid": "ep-oldest", "redacted": False, "entity_edges": []},
]
@@ -41,7 +47,10 @@ async def _policy_filtered_store(query: str, **params: object):
{"uuid": episode["uuid"]}
for episode in _STORED
if is_recallable_episode(
- episode["entity_edges"], {"gone"}, redacted=episode["redacted"]
+ episode["entity_edges"],
+ {"gone"},
+ redacted=episode["redacted"],
+ write_pending=episode.get("write_pending", False),
)
]
return rows, [], None
diff --git a/autogpt_platform/backend/backend/copilot/graphiti/recall_citations.py b/autogpt_platform/backend/backend/copilot/graphiti/recall_citations.py
index 0986b8adff..0352879868 100644
--- a/autogpt_platform/backend/backend/copilot/graphiti/recall_citations.py
+++ b/autogpt_platform/backend/backend/copilot/graphiti/recall_citations.py
@@ -22,16 +22,14 @@ bounded like the cascade; a walk stopped by its bound drops the write too).
A forget's cascade walks through such a fact to what rests on it, and the
write would rest on it the same way, carrying that content.
-The ``statement`` comparison is kept as defence in depth. apply no longer
-sends a write that cites nothing: it drops one before it is queued
-(``dream/citations.py``), so nothing in the codebase sets ``statement``
-today. Should a write carrying only a ``statement`` reach the worker, it is
-compared with the sentence every forgotten fact keeps for audit, lower-cased
-and with its whitespace collapsed, as graphiti's own exact-match dedup
-compares. It has no endpoints until graphiti extracts it, so that comparison
-spans the graph: it drops more than a same-endpoints one would, never less.
-A sentence a hard forget erased (``recall_erase.py``) is no longer there to
-compare with.
+The ``statement`` comparison is defence in depth. Apply drops uncited
+writes before queueing them (``dream/citations.py``); a worker handed a
+write carrying only a ``statement`` compares it with the sentence every
+forgotten fact keeps for audit, lower-cased and with its whitespace collapsed,
+as graphiti's own exact-match dedup compares. It has no endpoints until
+graphiti extracts it, so that comparison spans the graph: it drops more
+than a same-endpoints one would, never less.
+A sentence a hard forget erased (``recall_erase.py``) is absent for comparison.
Once written, what a dream write cites is recorded where a later forget
finds it (``recall_derivation.py``).
diff --git a/autogpt_platform/backend/backend/copilot/graphiti/recall_sources.py b/autogpt_platform/backend/backend/copilot/graphiti/recall_sources.py
index d08a0587a2..6ceb4f4f27 100644
--- a/autogpt_platform/backend/backend/copilot/graphiti/recall_sources.py
+++ b/autogpt_platform/backend/backend/copilot/graphiti/recall_sources.py
@@ -123,6 +123,8 @@ async def ancestry(driver: GraphDriver, cited: list[dict[str, Any]]) -> Ancestry
if not frontier:
return found
parents = _named(frontier, origin, "facts", seen)
+ # Episodes are terminal sources in this upward walk, so there is no
+ # later frontier that could read one again.
episodes = _named(frontier, origin, "episodes", set())
read += len(parents)
if read > CASCADE_MAX_ITEMS:
@@ -137,7 +139,30 @@ async def ancestry(driver: GraphDriver, cited: list[dict[str, Any]]) -> Ancestry
seen.update(parents)
frontier = [states[u] for u in parents if u in states and walkable(states[u])]
origin.update({row["uuid"]: parents[row["uuid"]] for row in frontier})
- found.unfinished = bool(frontier)
+ # A trailing read-only round distinguishes an unfinished walk from a
+ # converging frontier, and can still find a forgotten terminal source.
+ parents = _named(frontier, origin, "facts", seen)
+ episodes = _named(frontier, origin, "episodes", set())
+ if read + len(parents) > CASCADE_MAX_ITEMS:
+ found.unfinished = True
+ return found
+ states = await fact_states(driver, list(parents))
+ for uuid, cited_uuid in parents.items():
+ if (reach := fact_reach(uuid, states.get(uuid))) is not None:
+ found.add(cited_uuid, reach)
+ for uuid, reach in (await reached_episodes(driver, list(episodes))).items():
+ found.add(episodes[uuid], reach)
+ seen.update(parents)
+ beyond = [states[u] for u in parents if u in states and walkable(states[u])]
+ origin.update({row["uuid"]: parents[row["uuid"]] for row in beyond})
+ # A walkable fact read there leaves the walk unfinished only when it
+ # names a fact not read yet; its episodes are terminal, so read them.
+ if _named(beyond, origin, "facts", seen):
+ found.unfinished = True
+ return found
+ terminal = _named(beyond, origin, "episodes", set())
+ for uuid, reach in (await reached_episodes(driver, list(terminal))).items():
+ found.add(terminal[uuid], reach)
return found
diff --git a/autogpt_platform/backend/backend/copilot/graphiti/recall_sources_test.py b/autogpt_platform/backend/backend/copilot/graphiti/recall_sources_test.py
index 5e14100066..3e0681d4df 100644
--- a/autogpt_platform/backend/backend/copilot/graphiti/recall_sources_test.py
+++ b/autogpt_platform/backend/backend/copilot/graphiti/recall_sources_test.py
@@ -163,17 +163,78 @@ class TestTheWalk:
class TestTheBound:
@pytest.mark.asyncio
- async def test_a_chain_deeper_than_the_cascades_rounds_is_unfinished(
+ async def test_a_converging_frontier_at_the_depth_limit_is_finished(self) -> None:
+ chain = {f"d{i}": fact(facts=(f"d{i + 1}",)) for i in range(CASCADE_MAX_ROUNDS)}
+ chain[f"d{CASCADE_MAX_ROUNDS}"] = fact(facts=("d1",))
+ driver = sources(chain)
+
+ walk = await _walk(driver, ["d0"])
+
+ assert walk.reached == {}
+ assert not walk.unfinished
+
+ @pytest.mark.asyncio
+ async def test_a_terminal_source_in_the_trailing_read_is_found(self) -> None:
+ chain = {f"d{i}": fact(facts=(f"d{i + 1}",)) for i in range(CASCADE_MAX_ROUNDS)}
+ chain[f"d{CASCADE_MAX_ROUNDS}"] = fact(facts=("forgotten",))
+ driver = sources({**chain, "forgotten": fact(forgotten=True)})
+
+ walk = await _walk(driver, ["d0"])
+
+ assert walk.reached == {"d0": Reach(root="forgotten", hard=False)}
+ assert not walk.unfinished
+
+ @pytest.mark.asyncio
+ async def test_a_hidden_episode_in_the_trailing_read_is_found(self) -> None:
+ chain = {f"d{i}": fact(facts=(f"d{i + 1}",)) for i in range(CASCADE_MAX_ROUNDS)}
+ chain[f"d{CASCADE_MAX_ROUNDS}"] = fact(episodes=("hidden",))
+ driver = sources(chain, {"hidden": episode(hidden=True)})
+
+ walk = await _walk(driver, ["d0"])
+
+ assert walk.reached == {"d0": Reach(root="hidden", hard=False)}
+ assert not walk.unfinished
+
+ @pytest.mark.asyncio
+ async def test_a_walkable_source_past_the_limit_naming_read_facts_is_finished(
self,
) -> None:
+ """The trailing read finds ``d11`` walkable, but every fact it names
+ was read: nothing is left, so the walk converged."""
+ depth = CASCADE_MAX_ROUNDS + 1
+ chain = {f"d{i}": fact(facts=(f"d{i + 1}",)) for i in range(depth)}
+ chain[f"d{depth}"] = fact(facts=("d1",))
+ driver = sources(chain)
+
+ walk = await _walk(driver, ["d0"])
+
+ assert (walk.reached, walk.unfinished) == ({}, False)
+
+ @pytest.mark.asyncio
+ async def test_a_hidden_episode_past_the_limit_is_found(self) -> None:
+ """Its episodes are terminal, so a converged walk reads them too."""
depth = CASCADE_MAX_ROUNDS + 1
chain = {f"d{i}": fact(facts=(f"d{i + 1}",)) for i in range(depth)}
+ chain[f"d{depth}"] = fact(facts=("d1",), episodes=("hidden",))
+ driver = sources(chain, {"hidden": episode(hidden=True)})
+
+ walk = await _walk(driver, ["d0"])
+
+ assert walk.reached == {"d0": Reach(root="hidden", hard=False)}
+ assert not walk.unfinished
+
+ @pytest.mark.asyncio
+ async def test_a_chain_deeper_than_the_cascades_rounds_is_unfinished(
+ self,
+ ) -> None:
+ depth = CASCADE_MAX_ROUNDS + 2
+ chain = {f"d{i}": fact(facts=(f"d{i + 1}",)) for i in range(depth)}
driver = sources({**chain, f"d{depth}": fact(forgotten=True)})
walk = await _walk(driver, ["d0"])
assert (walk.reached, walk.unfinished) == ({}, True)
- assert len(reads(driver, recall_sources.FACT_STATES_QUERY)) == 1 + (
+ assert len(reads(driver, recall_sources.FACT_STATES_QUERY)) == 2 + (
CASCADE_MAX_ROUNDS
)
diff --git a/autogpt_platform/backend/backend/copilot/inference/_test_data.py b/autogpt_platform/backend/backend/copilot/inference/_test_data.py
index c5f5ff1a4c..22722b2592 100644
--- a/autogpt_platform/backend/backend/copilot/inference/_test_data.py
+++ b/autogpt_platform/backend/backend/copilot/inference/_test_data.py
@@ -6,12 +6,12 @@ import anthropic
import httpx
from pydantic import BaseModel
-from backend.copilot.dream.structured_output import output_tool_name
from backend.copilot.transport_routing import ProviderRoutingKwargs
from backend.util.llm.conversions import ToolCall, ToolContentBlock
from backend.util.llm.providers import ProviderResponse
from .context import InferenceContext, InferenceJob, InferenceScope, RouteDecision
+from .structured_output import output_tool_name
# Where the tests patch the transport's key and the provider call.
ROUTING = "backend.copilot.inference.routing.routing_kwargs_for_chat_transport"
diff --git a/autogpt_platform/backend/backend/copilot/inference/complete.py b/autogpt_platform/backend/backend/copilot/inference/complete.py
index e893e7be48..25c344cd74 100644
--- a/autogpt_platform/backend/backend/copilot/inference/complete.py
+++ b/autogpt_platform/backend/backend/copilot/inference/complete.py
@@ -4,9 +4,9 @@
platform's key for the route's provider and parses the answer into a Pydantic
model. It asks for JSON mode on every provider but the native Anthropic API,
which ignores it and gets one tool built from the model instead
-(``dream/structured_output.py``): forced where the model accepts that, left
+(``inference/structured_output.py``): forced where the model accepts that, left
to the model (``auto``) where it doesn't. The parsing, and its recovery from
-fences and prose around the JSON, lives in ``dream/llm.py``.
+fences and prose around the JSON, lives in ``inference/parse_output.py``.
The dream's Anthropic batch path does not come through here: it submits via
``call_provider(execution_mode="batch")`` from ``dream/batch_submit.py``.
@@ -20,12 +20,6 @@ from urllib.parse import urlparse, urlunparse
import anthropic
from pydantic import BaseModel
-from backend.copilot.dream.llm import parse_structured_output
-from backend.copilot.dream.structured_output import (
- StructuredRequest,
- structured_payload,
- structured_request,
-)
from backend.copilot.transport_routing import ProviderRoutingKwargs
from backend.util.llm.providers import (
BatchSubmissionRef,
@@ -36,7 +30,9 @@ from backend.util.llm.providers import (
)
from .context import CostSource, InferenceContext, InferenceError, InferenceUsage
+from .parse_output import parse_structured_output
from .routing import platform_credentials
+from .structured_output import StructuredRequest, structured_payload, structured_request
logger = logging.getLogger(__name__)
diff --git a/autogpt_platform/backend/backend/copilot/inference/complete_anthropic_test.py b/autogpt_platform/backend/backend/copilot/inference/complete_anthropic_test.py
index d772cf95a7..16ea1262ba 100644
--- a/autogpt_platform/backend/backend/copilot/inference/complete_anthropic_test.py
+++ b/autogpt_platform/backend/backend/copilot/inference/complete_anthropic_test.py
@@ -11,7 +11,6 @@ from unittest.mock import AsyncMock, patch
import anthropic
import pytest
-from backend.copilot.dream.structured_output import output_tool_name
from backend.util.llm.providers import ProviderResponse
from backend.util.llm.tool_use import auto_tool_choice, force_tool_choice
@@ -27,6 +26,7 @@ from ._test_data import (
)
from .complete import structured_complete
from .context import InferenceError
+from .structured_output import output_tool_name
class TestAnthropicToolPath:
diff --git a/autogpt_platform/backend/backend/copilot/inference/complete_retry_test.py b/autogpt_platform/backend/backend/copilot/inference/complete_retry_test.py
index 538f6fb4f5..4ee5860738 100644
--- a/autogpt_platform/backend/backend/copilot/inference/complete_retry_test.py
+++ b/autogpt_platform/backend/backend/copilot/inference/complete_retry_test.py
@@ -9,7 +9,6 @@ from unittest.mock import AsyncMock, patch
import pytest
-from backend.copilot.dream.structured_output import output_tool_name
from backend.util.llm.tool_use import auto_tool_choice, force_tool_choice
from ._test_data import (
@@ -25,6 +24,7 @@ from ._test_data import (
)
from .complete import structured_complete
from .context import InferenceError
+from .structured_output import output_tool_name
class TestForcedToolRetry:
diff --git a/autogpt_platform/backend/backend/copilot/inference/context.py b/autogpt_platform/backend/backend/copilot/inference/context.py
index 53933b63fc..0d39742117 100644
--- a/autogpt_platform/backend/backend/copilot/inference/context.py
+++ b/autogpt_platform/backend/backend/copilot/inference/context.py
@@ -14,9 +14,10 @@ from typing import Literal
from pydantic import BaseModel, ConfigDict, Field, model_validator
-from backend.copilot.dream.routing import ExecutionPath
from backend.util.llm.providers import ProviderLiteral
+from .execution_path import ExecutionPath
+
InferenceKind = Literal[
"dream", "briefing_narrative", "consult", "eval_judge", "skill_learning"
]
diff --git a/autogpt_platform/backend/backend/copilot/inference/execution_path.py b/autogpt_platform/backend/backend/copilot/inference/execution_path.py
new file mode 100644
index 0000000000..9729696465
--- /dev/null
+++ b/autogpt_platform/backend/backend/copilot/inference/execution_path.py
@@ -0,0 +1,12 @@
+"""Execution-path types and pricing shared by background inference callers."""
+
+from typing import Literal
+
+ExecutionPath = Literal["sync_baseline", "anthropic_batch"]
+
+_ANTHROPIC_BATCH_DISCOUNT = 0.5
+
+
+def batch_discount(path: ExecutionPath) -> float:
+ """The provider discount for a background call's execution path."""
+ return _ANTHROPIC_BATCH_DISCOUNT if path == "anthropic_batch" else 0.0
diff --git a/autogpt_platform/backend/backend/copilot/dream/llm.py b/autogpt_platform/backend/backend/copilot/inference/parse_output.py
similarity index 97%
rename from autogpt_platform/backend/backend/copilot/dream/llm.py
rename to autogpt_platform/backend/backend/copilot/inference/parse_output.py
index f45cd72475..5fad610788 100644
--- a/autogpt_platform/backend/backend/copilot/dream/llm.py
+++ b/autogpt_platform/backend/backend/copilot/inference/parse_output.py
@@ -1,6 +1,6 @@
"""Parse a background LLM call's structured answer into its Pydantic model.
-``backend/copilot/inference/complete.py`` makes the call, and the dream's
+``complete.py`` makes the call, and the dream's
batch callbacks read their result rows; this module turns the text either
gets back into the typed value, recovering from the ways models wrap their
JSON:
@@ -25,7 +25,7 @@ from typing import TypeVar
from pydantic import BaseModel, ValidationError
-from backend.copilot.inference.context import InferenceError, InferenceUsage
+from .context import InferenceError, InferenceUsage
logger = logging.getLogger(__name__)
diff --git a/autogpt_platform/backend/backend/copilot/inference/record.py b/autogpt_platform/backend/backend/copilot/inference/record.py
index 3e1819be48..5434c639a0 100644
--- a/autogpt_platform/backend/backend/copilot/inference/record.py
+++ b/autogpt_platform/backend/backend/copilot/inference/record.py
@@ -14,7 +14,6 @@ from typing import Any, Literal
from pydantic import BaseModel, ConfigDict
-from backend.copilot.dream.routing import batch_discount
from backend.copilot.model import ChatSession
from backend.copilot.price_card import compute_cost_usd, price_for
from backend.copilot.token_tracking import persist_and_record_usage
@@ -27,6 +26,7 @@ from .context import (
Payer,
RouteDecision,
)
+from .execution_path import batch_discount
class _KindAccounting(BaseModel):
diff --git a/autogpt_platform/backend/backend/copilot/inference/routing.py b/autogpt_platform/backend/backend/copilot/inference/routing.py
index ae0c75b9bc..e4c96fac47 100644
--- a/autogpt_platform/backend/backend/copilot/inference/routing.py
+++ b/autogpt_platform/backend/backend/copilot/inference/routing.py
@@ -71,7 +71,7 @@ def resolve_route(
def anthropic_batch_route(model: str) -> RouteDecision:
"""The route of a dream phase the orchestrator sent to Anthropic's
Message Batches API: the platform's Anthropic key, at the batch discount
- (``dream/routing.batch_discount``), whatever the chat transport."""
+ (``inference/execution_path.batch_discount``), whatever the chat transport."""
return RouteDecision(
engine="provider_batch",
auth_provider="platform",
@@ -132,17 +132,16 @@ def _missing_api_key_message(provider: ProviderLiteral) -> str:
"""Per-provider friendly error for the no-API-key case.
Names the env var the operator needs to set and, for subscription mode,
- why the OAuth token is not enough. Surfaced through the dream's JobStatus
- ``error`` so an operator can fix it without a logs dive.
+ why the OAuth token is not enough. The calling job reports this error.
"""
if provider == "anthropic":
return (
"Anthropic API key not configured — set ANTHROPIC_API_KEY to "
- "enable the dream pass under subscription / direct-Anthropic "
+ "enable background inference under subscription / direct-Anthropic "
"mode. The Claude Code OAuth token cannot be used for direct "
"Messages API calls (see "
"docs/platform/copilot-local-llm.md#subscription-mode-caveat)."
)
if provider == "open_router":
return "OpenRouter API key not configured — set OPEN_ROUTER_API_KEY."
- return f"No API key configured for dream pass provider={provider!r}."
+ return f"No API key configured for background inference provider={provider!r}."
diff --git a/autogpt_platform/backend/backend/copilot/inference/routing_test.py b/autogpt_platform/backend/backend/copilot/inference/routing_test.py
index af1d1ccfca..eb10367481 100644
--- a/autogpt_platform/backend/backend/copilot/inference/routing_test.py
+++ b/autogpt_platform/backend/backend/copilot/inference/routing_test.py
@@ -8,6 +8,8 @@ Each case builds the transport's real ``ChatConfig`` and runs the real
``copilot/transport_routing_test.py``), so a change on either side shows up.
"""
+import ast
+from pathlib import Path
from typing import Any
from unittest.mock import MagicMock
@@ -49,17 +51,6 @@ _ANTHROPIC_SDK_MODELS = {
_SCOPE = InferenceScope(user_id="u1", expert_id="e1")
-# What the callers' old ``dream/llm.structured_completion`` raised for an
-# install whose transport dispatches to Anthropic without an Anthropic key,
-# word for word.
-_OLD_MISSING_ANTHROPIC_KEY = (
- "Anthropic API key not configured — set ANTHROPIC_API_KEY to "
- "enable the dream pass under subscription / direct-Anthropic "
- "mode. The Claude Code OAuth token cannot be used for direct "
- "Messages API calls (see "
- "docs/platform/copilot-local-llm.md#subscription-mode-caveat)."
-)
-
def _config(**settings: Any) -> ChatConfig:
"""A config built from these settings alone: no developer ``.env``
@@ -279,6 +270,23 @@ def test_the_batch_route_is_anthropic_at_the_platforms_expense():
assert route.model == "claude-opus-5-5"
+def test_shared_inference_does_not_import_dream() -> None:
+ for path in Path(__file__).parent.glob("*.py"):
+ module = ast.parse(path.read_text(encoding="utf-8"))
+ imports = [
+ node.module for node in ast.walk(module) if isinstance(node, ast.ImportFrom)
+ ]
+ imports.extend(
+ alias.name
+ for node in ast.walk(module)
+ if isinstance(node, ast.Import)
+ for alias in node.names
+ )
+ assert not any(
+ name and name.startswith("backend.copilot.dream") for name in imports
+ ), path.name
+
+
class TestPlatformCredentials:
def test_returns_the_transports_key(self, monkeypatch):
cfg = _subscription_with_key(monkeypatch)
@@ -329,7 +337,8 @@ class TestPlatformCredentials:
job = _job("aux", kind="briefing_narrative", phase=None)
with pytest.raises(InferenceError) as exc_info:
resolve_route(_SCOPE, job, config=cfg)
- assert str(exc_info.value) == _OLD_MISSING_ANTHROPIC_KEY
+ assert "dream pass" not in str(exc_info.value)
+ assert "background inference" in str(exc_info.value)
def test_a_local_backend_needs_no_key(self, monkeypatch):
cfg = _local(monkeypatch)
diff --git a/autogpt_platform/backend/backend/copilot/dream/structured_output.py b/autogpt_platform/backend/backend/copilot/inference/structured_output.py
similarity index 100%
rename from autogpt_platform/backend/backend/copilot/dream/structured_output.py
rename to autogpt_platform/backend/backend/copilot/inference/structured_output.py
diff --git a/autogpt_platform/backend/backend/copilot/service.py b/autogpt_platform/backend/backend/copilot/service.py
index 6b3ffab96c..2b1442ee69 100644
--- a/autogpt_platform/backend/backend/copilot/service.py
+++ b/autogpt_platform/backend/backend/copilot/service.py
@@ -162,15 +162,11 @@ def _get_langfuse():
# (which writes the tag). Keeping both in sync prevents drift.
USER_CONTEXT_TAG = "user_context"
-# Tag name the SDK engine wrapped the first turn's Graphiti warm context in
-# when it still stored that block in the first user message. Warm context now
-# goes into each turn's model input only, as a marked ``<temporal_context>``
-# block (``graphiti/context_marker.py``), and nothing writes this tag any
-# more. It stays server-only: user-supplied occurrences are stripped before
-# the message reaches the LLM, and the display strip hides it on messages
-# stored before the change. Those are read without it wherever they become
-# model input or a tool's output, and cleaned from storage and restored CLI
-# session files (``copilot/legacy_first_turn_memory.py``).
+# Legacy tag for warm-context blocks stored in the first user message by
+# older SDK sessions. Current turns put marked ``<temporal_context>`` only
+# in model input. This tag remains so old stored blocks can be identified and
+# stripped from model input, tool output, storage and restored CLI session files
+# (``copilot/legacy_first_turn_memory.py``).
MEMORY_CONTEXT_TAG = "memory_context"
# Tag name for the environment context block prepended on first turn.
diff --git a/autogpt_platform/backend/backend/copilot/tools/graphiti_forget.py b/autogpt_platform/backend/backend/copilot/tools/graphiti_forget.py
index f3c875c691..32fcdf7a09 100644
--- a/autogpt_platform/backend/backend/copilot/tools/graphiti_forget.py
+++ b/autogpt_platform/backend/backend/copilot/tools/graphiti_forget.py
@@ -302,7 +302,9 @@ def _build_confirm_message(
The facts the dream had derived from the forgotten ones, retracted with
them (``graphiti/recall_cascade.py``), are counted so the user hears of
them too, and so are the edges an earlier hard forget had already erased,
- whose derived facts this forget went on to retract and erase. A soft
+ whose derived facts this forget went on to retract and erase. With both
+ kinds of edge, one count covers what they derived, so the message credits
+ it to all of them. A soft
forget that retracted anything says it was not a permanent deletion, what
it did instead, and how to delete permanently (``SOFT_FORGET_NOTE``).
@@ -312,17 +314,57 @@ def _build_confirm_message(
full per-UUID list stays available in the structured ``failures`` field.
"""
mode = "permanently deleted" if hard else "retracted from memory"
- summary = f"{deleted_count} memory edge(s) {mode}."
- if derived_count:
+ # A fact counts as derived once retracted, before its text is erased
+ # (``recall_cascade._retire``), so erasure is claimed only when nothing
+ # failed.
+ erased = (
+ "retracted and erased"
+ if not failures
+ else "retracted; erasing their text may not have finished (see below)"
+ )
+ if deleted_count and resumed_count:
summary = (
- f"{deleted_count} memory edge(s) {mode}; {derived_count} fact(s) "
- "derived from them retracted too."
+ f"{deleted_count} memory edge(s) {mode}. {resumed_count} memory "
+ "edge(s) had already been erased."
)
- if resumed_count:
- summary += (
- f" {resumed_count} memory edge(s) had already been erased; what "
- "was derived from them was retracted and erased."
+ if derived_count:
+ # A resumed edge's cascade always erases (``recall_forget._forget``);
+ # a soft forget's own only retracts.
+ summary += f" {derived_count} fact(s) derived from these edges were "
+ if hard:
+ summary += f"{erased}."
+ elif not failures:
+ summary += (
+ "retracted, and those derived from the already-erased "
+ "edges were erased too."
+ )
+ else:
+ summary += (
+ "retracted; erasing those derived from the already-erased "
+ "edges may not have finished (see below)."
+ )
+ elif deleted_count:
+ summary = f"{deleted_count} memory edge(s) {mode}."
+ if derived_count:
+ summary = (
+ f"{deleted_count} memory edge(s) {mode}; {derived_count} fact(s) "
+ "derived from them retracted too."
+ )
+ elif resumed_count:
+ summary = f"{resumed_count} memory edge(s) had already been erased."
+ if derived_count:
+ summary += f" {derived_count} derived fact(s) {erased}."
+ elif derived_count:
+ # Facts derived with nothing deleted or resumed: the forget's cascade
+ # ran, then retracting or deleting the edges themselves failed
+ # (``recall_forget._forget``). The failures below say why.
+ derived = erased if hard else "retracted"
+ summary = (
+ f"The memory edge(s) could not be {mode}, but {derived_count} "
+ f"fact(s) derived from them were {derived}."
)
+ else:
+ summary = f"0 memory edge(s) {mode}."
if deleted_count and not hard:
summary += f" {SOFT_FORGET_NOTE}"
if not failures:
diff --git a/autogpt_platform/backend/backend/copilot/tools/graphiti_forget_test.py b/autogpt_platform/backend/backend/copilot/tools/graphiti_forget_test.py
index 98b3683350..8eef04ce0f 100644
--- a/autogpt_platform/backend/backend/copilot/tools/graphiti_forget_test.py
+++ b/autogpt_platform/backend/backend/copilot/tools/graphiti_forget_test.py
@@ -440,12 +440,112 @@ class TestBuildConfirmMessage:
def test_edges_already_erased_are_told_apart(self) -> None:
message = _build_confirm_message(0, False, [], 2, 1)
- assert message == (
- "0 memory edge(s) retracted from memory; "
- "2 fact(s) derived from them retracted too. "
- "1 memory edge(s) had already been erased; what was derived from "
- "them was retracted and erased."
+ assert message.startswith("1 memory edge(s) had already been erased.")
+ assert "0 memory edge(s) retracted from memory" not in message
+
+ def test_a_hard_forget_whose_deletion_failed_says_so(self) -> None:
+ """Its cascade ran, then deleting the edge failed: the edge and its
+ text are still there, so the message must not call it erased."""
+ failures = [
+ MemoryForgetFailure(
+ uuid="uuid-1",
+ code=MemoryForgetFailureCode.CLEANUP_ERROR,
+ reason="graph unavailable",
+ )
+ ]
+ message = _build_confirm_message(0, True, failures, 2)
+ assert message.startswith(
+ "The memory edge(s) could not be permanently deleted, but 2 fact(s) "
+ "derived from them were retracted; erasing their text may not have "
+ "finished (see below)."
+ )
+ assert "already" not in message
+ assert "uuid-1" in message
+
+ def test_resumed_edges_claim_derived_facts_only_when_there_were_any(
+ self,
+ ) -> None:
+ none_derived = _build_confirm_message(1, True, [], 0, 1)
+ assert none_derived == (
+ "1 memory edge(s) permanently deleted. "
+ "1 memory edge(s) had already been erased."
+ )
+ assert "derived" not in none_derived
+
+ derived = _build_confirm_message(1, True, [], 2, 1)
+ assert derived == (
+ "1 memory edge(s) permanently deleted. "
+ "1 memory edge(s) had already been erased. "
+ "2 fact(s) derived from these edges were retracted and erased."
+ )
+
+ def test_one_derived_count_is_credited_to_every_kind_of_edge(self) -> None:
+ """The count covers what the deleted and the already-erased edges
+ derived, so it is never credited to the deleted ones alone. A soft
+ forget erases only the already-erased edges' derived facts."""
+ hard = _build_confirm_message(2, True, [], 5, 1)
+ assert "derived from them" not in hard
+ assert hard.endswith(
+ "5 fact(s) derived from these edges were retracted and erased."
+ )
+
+ soft = _build_confirm_message(2, False, [], 5, 1)
+ assert soft.startswith(
+ "2 memory edge(s) retracted from memory. "
+ "1 memory edge(s) had already been erased. "
+ "5 fact(s) derived from these edges were retracted, and those "
+ "derived from the already-erased edges were erased too."
+ )
+ assert "retracted and erased" not in soft
+
+ failures = [
+ MemoryForgetFailure(
+ uuid="uuid-3",
+ code=MemoryForgetFailureCode.CLEANUP_ERROR,
+ reason="erase failed",
+ )
+ ]
+ failed = _build_confirm_message(2, False, failures, 5, 1)
+ assert (
+ "erasing those derived from the already-erased edges may not have "
+ "finished (see below)."
+ ) in failed
+ assert "erased too" not in failed
+
+ def test_erasure_is_claimed_only_when_nothing_failed(self) -> None:
+ """A derived fact is counted once retracted, before its text is erased,
+ so a failure means its text may still be there."""
+ clean = _build_confirm_message(0, True, [], 2, 1)
+ assert clean == (
+ "1 memory edge(s) had already been erased. "
+ "2 derived fact(s) retracted and erased."
+ )
+
+ failures = [
+ MemoryForgetFailure(
+ uuid="uuid-2",
+ code=MemoryForgetFailureCode.CLEANUP_ERROR,
+ reason="erase failed",
+ )
+ ]
+ resumed = _build_confirm_message(0, True, failures, 2, 1)
+ assert resumed.startswith(
+ "1 memory edge(s) had already been erased. 2 derived fact(s) "
+ "retracted; erasing their text may not have finished (see below)."
+ )
+ assert "retracted and erased" not in resumed
+
+ mixed = _build_confirm_message(1, True, failures, 2, 1)
+ assert "derived from these edges were retracted; erasing" in mixed
+ assert "retracted and erased" not in mixed
+
+ def test_a_soft_derived_only_result_never_claims_erasure(self) -> None:
+ soft = _build_confirm_message(0, False, [], 2)
+ assert soft == (
+ "The memory edge(s) could not be retracted from memory, but 2 fact(s) "
+ "derived from them were retracted."
)
+ assert "erased" not in soft
def test_a_soft_forget_says_it_is_not_a_permanent_deletion(self) -> None:
"""A model told a user who had asked for a permanent delete that a soft
diff --git a/autogpt_platform/backend/backend/data/dream_pass_update.py b/autogpt_platform/backend/backend/data/dream_pass_update.py
index a2ebcb367b..bd6845f326 100644
--- a/autogpt_platform/backend/backend/data/dream_pass_update.py
+++ b/autogpt_platform/backend/backend/data/dream_pass_update.py
@@ -19,8 +19,8 @@ statement against the row as it stands when the statement runs:
* ``readUuids`` gains the update's, never losing one;
* ``leaseExpiresAt`` only moves later: a renewal written late (a sync
renewal the store gave up on, landing after the batch submit's longer
- lease) never shortens the lease the row holds. Every renewal is now
- plus its route's TTL, so none needs to move it earlier;
+ lease) never shortens the lease the row holds. Every renewal sets an
+ expiry at the renewal time plus its route's TTL;
* ``leaseToken``, ``leaseExpiresAt``, ``inputBundle`` and
``cleanupPendingAt`` become NULL when the update names them in ``clear``
(a closing row drops its bundle, and its lease unless the close marks
diff --git a/autogpt_platform/backend/migrations/20261021120000_dream_pass_created_at_index/migration.sql b/autogpt_platform/backend/migrations/20261021120000_dream_pass_created_at_index/migration.sql
new file mode 100644
index 0000000000..93d9b27f7d
--- /dev/null
+++ b/autogpt_platform/backend/migrations/20261021120000_dream_pass_created_at_index/migration.sql
@@ -0,0 +1 @@
+CREATE INDEX IF NOT EXISTS "DreamPass_createdAt_idx" ON "DreamPass"("createdAt");
\ No newline at end of file
diff --git a/autogpt_platform/backend/poetry.lock b/autogpt_platform/backend/poetry.lock
index f719d0918e..7ea36490a9 100644
--- a/autogpt_platform/backend/poetry.lock
+++ b/autogpt_platform/backend/poetry.lock
@@ -8857,4 +8857,4 @@ cffi = ["cffi (>=1.17,<2.0) ; platform_python_implementation != \"PyPy\" and pyt
[metadata]
lock-version = "2.1"
python-versions = ">=3.11,<3.14"
-content-hash = "7f6c38e2efbf79053dbb4db916bc71b8c8fddcf557824a43459dcf77ec33f124"
+content-hash = "133d9f66e45f601a459943efdd82f9cd556e509165d22f78a31853de812b2eaa"
diff --git a/autogpt_platform/backend/pyproject.toml b/autogpt_platform/backend/pyproject.toml
index f7281968d6..eaaffc8647 100644
--- a/autogpt_platform/backend/pyproject.toml
+++ b/autogpt_platform/backend/pyproject.toml
@@ -27,7 +27,7 @@ discord-py = "^2.5.2"
e2b = "^2.15.2"
e2b-code-interpreter = "^2.0"
elevenlabs = "^1.50.0"
-falkordb = "^1.1.2"
+falkordb = "^1.7.0"
fastapi = "^0.128.6"
feedparser = "^6.0.11"
flake8 = "^7.3.0"
diff --git a/autogpt_platform/backend/schema.prisma b/autogpt_platform/backend/schema.prisma
index 73ac282832..75848befcb 100644
--- a/autogpt_platform/backend/schema.prisma
+++ b/autogpt_platform/backend/schema.prisma
@@ -706,6 +706,7 @@ model DreamPass {
@@index([scopeKey, status])
@@index([userId, createdAt])
+ @@index([createdAt])
// Deleting an expert cascades here; without it that scans every pass.
@@index([expertId])
// The reaper's scans: open passes whose lease lapsed, oldest first, and
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index 5ad2c1296b..cfeba72718 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -24062,7 +24062,7 @@
"DreamPassListResponse": {
"properties": {
"passes": {
- "items": { "$ref": "#/components/schemas/DreamPassRecord" },
+ "items": { "$ref": "#/components/schemas/PublicDreamPassRecord" },
"type": "array",
"title": "Passes"
}
@@ -24103,174 +24103,9 @@
],
"title": "DreamPassPhase"
},
- "DreamPassRecord": {
- "properties": {
- "id": { "type": "string", "title": "Id" },
- "user_id": { "type": "string", "title": "User Id" },
- "expert_id": {
- "anyOf": [{ "type": "string" }, { "type": "null" }],
- "title": "Expert Id"
- },
- "scope_key": { "type": "string", "title": "Scope Key" },
- "route": { "$ref": "#/components/schemas/DreamPassRoute" },
- "trigger": { "$ref": "#/components/schemas/DreamPassTrigger" },
- "phase": { "$ref": "#/components/schemas/DreamPassPhase" },
- "status": { "$ref": "#/components/schemas/DreamPassStatus" },
- "skip_reason": {
- "anyOf": [{ "type": "string" }, { "type": "null" }],
- "title": "Skip Reason"
- },
- "cancel_generation": {
- "type": "integer",
- "title": "Cancel Generation"
- },
- "provider_batch_id": {
- "anyOf": [{ "type": "string" }, { "type": "null" }],
- "title": "Provider Batch Id"
- },
- "lease_token": {
- "anyOf": [{ "type": "string" }, { "type": "null" }],
- "title": "Lease Token"
- },
- "lease_expires_at": {
- "anyOf": [
- { "type": "string", "format": "date-time" },
- { "type": "null" }
- ],
- "title": "Lease Expires At"
- },
- "cleanup_pending_at": {
- "anyOf": [
- { "type": "string", "format": "date-time" },
- { "type": "null" }
- ],
- "title": "Cleanup Pending At"
- },
- "cost_context": {
- "anyOf": [
- { "additionalProperties": true, "type": "object" },
- { "type": "null" }
- ],
- "title": "Cost Context"
- },
- "input_bundle": {
- "anyOf": [
- { "$ref": "#/components/schemas/DreamInput" },
- { "type": "null" }
- ]
- },
- "phase_outputs": { "$ref": "#/components/schemas/DreamPhaseOutputs" },
- "operations": { "$ref": "#/components/schemas/DreamPassOperations" },
- "usage": {
- "anyOf": [
- { "$ref": "#/components/schemas/DreamPassUsage" },
- { "type": "null" }
- ]
- },
- "window_start": {
- "anyOf": [
- { "type": "string", "format": "date-time" },
- { "type": "null" }
- ],
- "title": "Window Start"
- },
- "window_end": {
- "anyOf": [
- { "type": "string", "format": "date-time" },
- { "type": "null" }
- ],
- "title": "Window End"
- },
- "error": {
- "anyOf": [{ "type": "string" }, { "type": "null" }],
- "title": "Error"
- },
- "erased_at": {
- "anyOf": [
- { "type": "string", "format": "date-time" },
- { "type": "null" }
- ],
- "title": "Erased At"
- },
- "read_uuids": {
- "items": { "type": "string" },
- "type": "array",
- "title": "Read Uuids"
- },
- "created_at": {
- "type": "string",
- "format": "date-time",
- "title": "Created At"
- },
- "started_at": {
- "anyOf": [
- { "type": "string", "format": "date-time" },
- { "type": "null" }
- ],
- "title": "Started At"
- },
- "submitted_at": {
- "anyOf": [
- { "type": "string", "format": "date-time" },
- { "type": "null" }
- ],
- "title": "Submitted At"
- },
- "applied_at": {
- "anyOf": [
- { "type": "string", "format": "date-time" },
- { "type": "null" }
- ],
- "title": "Applied At"
- },
- "completed_at": {
- "anyOf": [
- { "type": "string", "format": "date-time" },
- { "type": "null" }
- ],
- "title": "Completed At"
- },
- "updated_at": {
- "type": "string",
- "format": "date-time",
- "title": "Updated At"
- }
- },
- "type": "object",
- "required": [
- "id",
- "user_id",
- "expert_id",
- "scope_key",
- "route",
- "trigger",
- "phase",
- "status",
- "skip_reason",
- "cancel_generation",
- "provider_batch_id",
- "lease_token",
- "lease_expires_at",
- "input_bundle",
- "phase_outputs",
- "operations",
- "usage",
- "window_start",
- "window_end",
- "error",
- "created_at",
- "started_at",
- "submitted_at",
- "applied_at",
- "completed_at",
- "updated_at"
- ],
- "title": "DreamPassRecord",
- "description": "One ``DreamPass`` row."
- },
"DreamPassRecordResponse": {
"properties": {
- "record": { "$ref": "#/components/schemas/DreamPassRecord" },
+ "record": { "$ref": "#/components/schemas/PublicDreamPassRecord" },
"result": { "$ref": "#/components/schemas/DreamPassResult" }
},
"type": "object",
@@ -28233,9 +28068,9 @@
},
"IngestionDrainStatus": {
"type": "string",
- "enum": ["drained", "skipped", "timed_out"],
+ "enum": ["not_applied", "unknown", "drained", "skipped", "timed_out"],
"title": "IngestionDrainStatus",
- "description": "Fate of a dream pass's enqueued graph writes at the moment the pass\nwas reported complete.\n\nThree distinct states, so consumers (and a future Memory Visualizer)\ncan tell a healthy by-design skip from a real failure:\n\n * ``drained`` — the worker finished every one of the pass's own\n episodes before the pass returned (sync path): each was written,\n dropped for resting on a forget (``dropped_forgotten``), or failed\n with a logged error; or the pass enqueued nothing to drain. Healthy.\n * ``skipped`` — the drain was intentionally not run to avoid stalling\n a shared serial loop (batch path). The episodes process\n fire-and-forget, counted pending; healthy by design, NOT a failure\n signal.\n * ``timed_out`` — the sync-path drain was attempted but did not finish\n within its budget. The episodes not written yet are counted pending,\n not written; they stay queued in-process, and are lost if the\n worker's pod restarts. This is the only value that warrants an\n operator warning."
+ "description": "Fate of a dream pass's enqueued graph writes at the moment the pass\nwas reported complete.\n\nFive distinct states, so consumers (and a future Memory Visualizer)\ncan tell a healthy by-design skip from a real failure:\n\n * ``drained`` — the worker finished every one of the pass's own\n episodes before the pass returned (sync path): each was written,\n dropped for resting on a forget (``dropped_forgotten``), or failed\n with a logged error; or the pass enqueued nothing to drain. Healthy.\n * ``skipped`` — the drain was intentionally not run to avoid stalling\n a shared serial loop (batch path). The episodes process\n fire-and-forget, counted pending; healthy by design, NOT a failure\n signal.\n * ``not_applied`` — this pass never began applying, so no drain ran.\n * ``unknown`` — this pass began applying but recorded no outcome: it\n may still be applying, or have applied before it ended (a cancel\n after its last check does not stop an apply), or failed partway. Its\n writes may have been enqueued, so whether they drained is not known.\n * ``timed_out`` — the sync-path drain was attempted but did not finish\n within its budget. The episodes not written yet are counted pending,\n not written; they stay queued in-process, and are lost if the\n worker's pod restarts. This is the only value that warrants an\n operator warning."
},
"InputValidationErrorResponse": {
"properties": {
@@ -32156,6 +31991,166 @@
"required": ["providers"],
"title": "ProviderTiersResponse"
},
+ "PublicDreamPassRecord": {
+ "properties": {
+ "id": { "type": "string", "title": "Id" },
+ "user_id": { "type": "string", "title": "User Id" },
+ "expert_id": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Expert Id"
+ },
+ "scope_key": { "type": "string", "title": "Scope Key" },
+ "route": { "$ref": "#/components/schemas/DreamPassRoute" },
+ "trigger": { "$ref": "#/components/schemas/DreamPassTrigger" },
+ "phase": { "$ref": "#/components/schemas/DreamPassPhase" },
+ "status": { "$ref": "#/components/schemas/DreamPassStatus" },
+ "skip_reason": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Skip Reason"
+ },
+ "cancel_generation": {
+ "type": "integer",
+ "title": "Cancel Generation"
+ },
+ "provider_batch_id": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Provider Batch Id"
+ },
+ "lease_expires_at": {
+ "anyOf": [
+ { "type": "string", "format": "date-time" },
+ { "type": "null" }
+ ],
+ "title": "Lease Expires At"
+ },
+ "cleanup_pending_at": {
+ "anyOf": [
+ { "type": "string", "format": "date-time" },
+ { "type": "null" }
+ ],
+ "title": "Cleanup Pending At"
+ },
+ "cost_context": {
+ "anyOf": [
+ { "additionalProperties": true, "type": "object" },
+ { "type": "null" }
+ ],
+ "title": "Cost Context"
+ },
+ "input_bundle": {
+ "anyOf": [
+ { "$ref": "#/components/schemas/DreamInput" },
+ { "type": "null" }
+ ]
+ },
+ "phase_outputs": { "$ref": "#/components/schemas/DreamPhaseOutputs" },
+ "operations": { "$ref": "#/components/schemas/DreamPassOperations" },
+ "usage": {
+ "anyOf": [
+ { "$ref": "#/components/schemas/DreamPassUsage" },
+ { "type": "null" }
+ ]
+ },
+ "window_start": {
+ "anyOf": [
+ { "type": "string", "format": "date-time" },
+ { "type": "null" }
+ ],
+ "title": "Window Start"
+ },
+ "window_end": {
+ "anyOf": [
+ { "type": "string", "format": "date-time" },
+ { "type": "null" }
+ ],
+ "title": "Window End"
+ },
+ "error": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Error"
+ },
+ "erased_at": {
+ "anyOf": [
+ { "type": "string", "format": "date-time" },
+ { "type": "null" }
+ ],
+ "title": "Erased At"
+ },
+ "read_uuids": {
+ "items": { "type": "string" },
+ "type": "array",
+ "title": "Read Uuids"
+ },
+ "created_at": {
+ "type": "string",
+ "format": "date-time",
+ "title": "Created At"
+ },
+ "started_at": {
+ "anyOf": [
+ { "type": "string", "format": "date-time" },
+ { "type": "null" }
+ ],
+ "title": "Started At"
+ },
+ "submitted_at": {
+ "anyOf": [
+ { "type": "string", "format": "date-time" },
+ { "type": "null" }
+ ],
+ "title": "Submitted At"
+ },
+ "applied_at": {
+ "anyOf": [
+ { "type": "string", "format": "date-time" },
+ { "type": "null" }
+ ],
+ "title": "Applied At"
+ },
+ "completed_at": {
+ "anyOf": [
+ { "type": "string", "format": "date-time" },
+ { "type": "null" }
+ ],
+ "title": "Completed At"
+ },
+ "updated_at": {
+ "type": "string",
+ "format": "date-time",
+ "title": "Updated At"
+ }
+ },
+ "type": "object",
+ "required": [
+ "id",
+ "user_id",
+ "expert_id",
+ "scope_key",
+ "route",
+ "trigger",
+ "phase",
+ "status",
+ "skip_reason",
+ "cancel_generation",
+ "provider_batch_id",
+ "lease_expires_at",
+ "input_bundle",
+ "phase_outputs",
+ "operations",
+ "usage",
+ "window_start",
+ "window_end",
+ "error",
+ "created_at",
+ "started_at",
+ "submitted_at",
+ "applied_at",
+ "completed_at",
+ "updated_at"
+ ],
+ "title": "PublicDreamPassRecord",
+ "description": "Admin-visible pass record without the live lock credential."
+ },
"PushSubscribeRequest": {
"properties": {
"endpoint": {