Skip to content

fix(knowledge): keep scribes current after updates, with fresh runs and clear update prompts - #197391

Merged
jalehman merged 9 commits into
mainfrom
feat/knowledge-scribe-run-upgrades
Nov 13, 2026
Merged

jalehman merged 9 commits into
mainfrom
feat/knowledge-scribe-run-upgrades

Conversation

@jalehman

@jalehman jalehman commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: after an OpenClaw update, Knowledge scribes keep running the run message they were set up with and an ever-growing conversation. They miss new scribe behavior and follow stale copies of skill text; one consolidation conversation reached about 590k tokens, and a weekly run read about 13M. On main, scribes already switched to sessionTarget: current are not paired with their conversations on the Scribes page. Learn from Granola could also stop with meetings left pending for no external reason and still report on.

User Impact

Opening the Scribes tab brings existing ongoing scribes up to date. Each run now starts in a fresh session of the scribe's conversation, and an earlier generated run message that is unchanged is replaced with the new one. A saved run message that differs from what this version generates is never overwritten. When it still carries replaced wording, the scribe shows New run instructions, and Replace with new… shows only the lines that change. After an update, Replace or Repair turn, the scribe shows Updating… and refreshes when its automation changes, with a visible note if nothing changes within 3 minutes. The last-run summary shows only real scheduled or Run now results, never setup, repair or update answers. A Granola run that leaves meetings pending without an outside reason now reports Needs attention instead of On.

Why This Change Was Made

  • Versioned run message. scribes-catalog.ts keeps every wording a released run message was generated from in RUN_WORDINGS. checkRunMessage classifies the stored message as:

    • current
    • custom
    • outdated: an unchanged earlier message, upgraded automatically
    • differs: carries replaced wording, so new instructions are offered

    Adding the Granola needs-attention rule added a wording entry, so unchanged Granola messages upgrade too.

  • Fresh run per session: current session target. Each run is a new cron:<job>:run:<id> session. The automation still belongs to the scribe conversation, so the Scribes page pairs them, and Run now, Pause, Turn off and Repair act on the same job. Run transcripts no longer land in the conversation, so the page reads a run's status line from cron.runs / cron.history and links runs to Automations. Resetting the conversation before each run was rejected: it changes the conversation's lifecycle revision, which unlinks the automation and denies private Knowledge access.

  • The Scribes page owns the upgrade, through a turn in the scribe's conversation. A direct cron.update would drop the job's operator source on an executable edit and lose owner-private access. Instead the conversation re-declares its automation with the owner's turn authority, as setup does. The page asks once per automation revision, then watches cron.inventory.changed, with a 10s poll and a 3-minute bound, until the revision changes and the change landed. A target-only intermediate write doesn't count as done or trigger a second turn. Pending updates are tracked per Gateway connection and per agent. The watch stops when the tab is left or the page is closed.

  • Re-declaration keeps what it doesn't set, and stays in this agent. Re-declaring through applyDeclarativeJobSpec replaces the payload and drops omitted activeHours, pacing and idleOnly. Update and repair prompts therefore pass the automation's saved options back exactly as written: payload model, thinking and other run options, an explicit toolsAllow passed with toolsAllowMode: "exact" so it is not broadened (a generated default list is left to its owner), activeHours, pacing, idleOnly, trigger, delivery and failureAlert. An existing automation keeps its delivery and failure alert instead of getting new-job defaults. The cleanup step lists automations for the Runtime agent only, and leaves another or missing owner agent untouched. This applies the [Bug]: Knowledge scribe setup for one agent removes other agents' scheduled scribes #196224 scoping (same wording as fix(knowledge): preserve other agents' scribes during setup #196238), which matters more now that opening the tab can send the turn. A send that fails is retried on the next load. A turn that left the automation unchanged shows Try again after 3 minutes. Try again sends the turn as a new request (fresh idempotency identity), so the Gateway can't answer it from the first request's record. A transport retry after a failed send keeps the same identity, for automatic updates and for confirming Replace with new again in the same dialog. An update that is still landing is never asked twice.

  • Last-run result vs. state. The state still follows the newest answer, so a failed repair shows Failing. The shown result comes only from a run: the latest run's own transcript, or for legacy in-session jobs a status line answering a Scheduled run of the Knowledge scribe turn.

  • Granola pending rules (knowledge-meeting-ingest/references/scribe-runs.md and the Granola run message):

    • pending is only for reasons outside the run: still recording, no transcript yet, or verification that still fails after a fix attempt.
    • Acquiring or digesting a meeting is not a stopping point.
    • Checkpoint lines record outcomes, never resume notes or plans.
    • A run with only unexplained pending meetings ends Scribe status: needs attention, which the page parses as a new state.

    No "stop when context runs short" rule is reintroduced (fix(knowledge): drop the Granola scribe's stop-when-context-is-short rule #197890).

Evidence

Real isolated Gateway (separate state and port, real model), driven through the Control UI. Before is the previous PR build; after is this head with the same state.

Before After
Scribes list: last-run summary before after

Before, Learn from conversations showed an update turn's answer ("each run's message now has the updated access check…") as its last result. After, it shows the scheduled run's counts and New run instructions. Consolidation's earlier claims-only message was upgraded to the five-step one when the tab loaded.

Saved message that differs (earlier access wording plus one added line):

detail

Replace with new… shows only the changed lines:

dialog

After confirming, the page shows Updating…:

updating

The conversation re-declared the automation. The page refreshed on the cron change and cleared without a manual reload. The job now has the new message and sessionTarget: current.

settled

(Model values redacted.)

Checks:

  • scribes-state.test.ts, scribes-view.test.ts and skill-packaging.test.ts pass.
  • pnpm tsgo:extensions and pnpm tsgo:extensions:test pass.
  • oxlint on the touched files, oxfmt and git diff --check pass.
  • sync-skill-references.mjs --check passes.
  • The test-lines ratchet passes (+220 net within the allowance, so the allocation file is removed).

Upgrade compatibility on existing data: the isolated Gateway's state came from the previous PR build, and the jobs began as earlier releases created them (legacy session:<key> target, earlier generated messages, and one changed message). On this build they loaded and paired, then migrated or offered New run instructions as shown above, keeping schedule, enabled state, operator source and silent delivery. Scheduled runs succeeded both before and after.

ClawSweeper's review of 615bd0e found three issues, all fixed with regression tests:

  • P1: cleanup was not scoped to the agent.
  • P1: re-declaration dropped saved options.
  • P2: a failed send was never retried.

The re-review of 6e8156c added two more issues, both fixed with tests:

  • P1: trigger and delivery were not carried over.
  • P2: an unchanged update was not retried after reopening.

The re-review of 16825c7 found that reopening reused the same request identity. Retry is now an explicit Try again with a new identity, and the test asserts the second key differs.

The re-review of 3c29bd4 found two more issues, both fixed with tests:

  • P1: an explicit toolsAllow cap could be broadened.
  • P2: a re-confirmed Replace used a new identity. This test fails without the fix.

The re-review of c743638 found that a failed Try again send was shown as Updating. It now stays late, with the error, and can be tried again. The test fails without the fix.

The failed-send test fails without the fix. The CI assertion-safety ratchet failure was caused by this PR and is fixed (typed choicesOf with a SAFETY note). The eager-import-closure tooling-shard failure is inherited: #197697 broke the PR-wrapper inventory on main, #197976 fixed it, and it passes locally on current main (6c32a157).

Independent review found three P2 issues in the update watcher, all fixed:

  • It kept running after the page closed.
  • Viewing another agent dropped this agent's pending updates.
  • A target-only intermediate write could trigger a second update turn.

Accepted edge cases:

  • Scribes from the earliest setup (Oct 27, JSON setup) have model-authored run messages that can't be recognized; they read as custom.
  • If the model doesn't follow an update turn, the job stays unchanged. The page then says so after 3 minutes, and asks again once the page is reopened.

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation plugin: knowledge size: L labels Nov 11, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR refreshes scribe instructions, starts scheduled runs in fresh sessions, and shows update progress and actual run results.

Example: Learn from conversations has an earlier generated message and a daily 4:00 AM schedule.

  • Before: Runs reuse the conversation’s growing history, and an update answer can appear as the last-run result.
  • After: Runs use fresh child sessions, unchanged generated instructions update, and the page shows the scheduled run’s result.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful production-path UI evidence supports the approach, but a retry defect and incomplete Granola and stable-upgrade coverage prevent readiness.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Scheduled scribes retain obsolete instructions and growing history, and their page can present setup or update answers as run results.
Reason: The repair addresses observed maintenance failures through existing owners, and the supplied host facts establish maintainer-approved direction.

Merge readiness

⛔ Blocked before merge - 3 items remain

This PR addresses a current scribe lifecycle problem and fixes the prior failure-reporting finding, but retry identity handling still needs correction.

Priority: P2
Reviewed head: 92a542f00f9349b8e5265fc83961a04376277ab6

Before merge

  • Reuse the failed Try again request identity (P2) - After an automatic update becomes late, let Try again reach chat.send but lose its response, then click Try again again. The failure handler correctly restores the late entry, but this callback deletes the retained unsent attempt on every click, so update() creates another UUID and the Gateway can execute a duplicate update turn. The replacement retry callback similarly generates a new UUID on every invocation. Allocate a new identity when retrying a completed unchanged turn, then retain that identity across failed sends until acceptance. This is a late discovery: comparison with c743638 confirms the unconditional deletion and replacement UUID generation were already present.
  • Cite the incident behind the new Granola instructions (P2) - The new checkpoint, pending, and completion rules add instructions to a skill without citing their motivating incident. Root AGENTS.md and the instruction-rule policy require new skill rules to cite a PR, issue, or commit. Add a concise source citation for these rules, such as the relevant report and this PR, without changing generated run-message bytes unnecessarily. This is a late discovery: the skill file is unchanged from the previously reviewed c743638.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Reuse the failed Try again request identity — extensions/knowledge/src/scribes-updates.ts:87-89
  • [P2] Cite the incident behind the new Granola instructions — extensions/knowledge/skills/knowledge-meeting-ingest/references/scribe-runs.md:40-44

Tests

  • Missing end-to-end proof: Provide redacted real-Gateway evidence of Granola completing an acquired meeting and reporting unexplained pending work, plus a v2026.11.3-to-head upgrade preserving existing job settings and access.
Agent review details

How this fits together

The Knowledge plugin’s Scribes page reads conversations and scheduler records, sends owner-authorized setup or update turns, and displays automation state and run transcripts.

flowchart TD
  A[Scribes page] --> B[Conversation and job reads]
  B --> C[Instruction comparison]
  C --> D[Owner conversation update turn]
  D --> E[Existing automation]
  E --> F[Fresh run session]
  F --> G[Run history and status]
Loading

Technical review

Best possible solution:

Keep the existing conversation and scheduler owners, preserve failed retry identities, and complete the focused behavior and upgrade evidence.

Do we have a high-confidence way to reproduce the issue?

Current-main setup prompts install conversation-targeted runs without instruction reconciliation, establishing the reported stale-history path from source; no target code was executed during this review.

Is this the best way to solve the issue?

Using existing scheduler child sessions and owner-conversation redeclaration fits the established authority contract, while exact template matching protects edited messages; the remaining retry defect has a small repair within the existing attempt owner.

Full review comments:

  • [P2] Reuse the failed Try again request identity — extensions/knowledge/src/scribes-updates.ts:87-89
    After an automatic update becomes late, let Try again reach chat.send but lose its response, then click Try again again. The failure handler correctly restores the late entry, but this callback deletes the retained unsent attempt on every click, so update() creates another UUID and the Gateway can execute a duplicate update turn. The replacement retry callback similarly generates a new UUID on every invocation. Allocate a new identity when retrying a completed unchanged turn, then retain that identity across failed sends until acceptance. This is a late discovery: comparison with c743638 confirms the unconditional deletion and replacement UUID generation were already present.
    Confidence: 0.95
    Late finding: first raised on code an earlier review cycle already covered.
  • [P2] Cite the incident behind the new Granola instructions — extensions/knowledge/skills/knowledge-meeting-ingest/references/scribe-runs.md:40-44
    The new checkpoint, pending, and completion rules add instructions to a skill without citing their motivating incident. Root AGENTS.md and the instruction-rule policy require new skill rules to cite a PR, issue, or commit. Add a concise source citation for these rules, such as the relevant report and this PR, without changing generated run-message bytes unnecessarily. This is a late discovery: the skill file is unchanged from the previously reviewed c743638.
    Confidence: 0.99
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9cfa4b5ff744.

Provenance checked

  • Readable, operator-editable run messages keeps the original intent (ed23336: feat(knowledge): readable scribe prompts the operator can edit #185974 made prompts readable and editable and preserved saved messages during repair.)
  • Conversation targeting and fresh-run migration changes intended behavior with a stated reason (f69f246: The original Scribes tab paired an ordinary owner conversation with its automation; this PR explains that fresh child sessions preserve that ownership while preventing accumulated run history.)
  • Repair enabling and archived conversations keeps the original intent (3d96ad7: Repair intentionally restores archived conversations and enables their automation; the PR retains that behavior.)
  • Never-written-store access wording keeps the original intent (96dc3b7: The existing access check reflects real write availability; the PR retains it and recognizes the earlier generated wording for migration.)
  • Granola completion rules keeps the original intent (b10c9e1: fix(knowledge): drop the Granola scribe's stop-when-context-is-short rule #197890 removed context-based early stopping after an observed pending meeting; this PR preserves that removal and adds explicit outcome reporting.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test extensions/knowledge/src/scribes-state.test.ts extensions/knowledge/src/scribes-view.test.ts
  • pnpm tsgo:extensions
  • pnpm tsgo:extensions:test
  • git diff --check

What I checked:

Likely related people:

  • Josh Lehman: Raw commit ed23336 adds extensions/knowledge/src/scribes-catalog.ts:202 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ed2333640513; files: extensions/knowledge/src/scribes-catalog.ts)

PR surface

Source +776, Tests +339, Docs +65. Total +1180 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 838 62 +776
Tests 2 342 3 +339
Docs 3 101 36 +65
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 1281 101 +1180

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs Knowledge scribe freshness and reporting with a limited subsystem blast radius.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (7 earlier review cycles)
  • reviewed 2026-11-11T22:08:31.041Z sha bdcbc65 :: needs real behavior proof before merge. :: [P1] Scope automatic reconciliation to the viewed agent | [P1] Preserve saved automation options during automatic upgrades | [P2] Release the update marker when sending fails
  • reviewed 2026-11-13T00:11:01.689Z sha 615bd0e :: blocked before merge. :: [P1] Scope automatic update cleanup to the current agent | [P1] Preserve saved execution options during automatic redeclaration | [P2] Release the update marker when sending fails
  • reviewed 2026-11-13T00:18:57.225Z sha 615bd0e :: blocked before merge. :: [P1] Scope automatic update cleanup to the current agent | [P1] Preserve saved execution options during automatic redeclaration | [P2] Release the update marker when sending fails
  • reviewed 2026-11-13T00:34:10.025Z sha 6e8156c :: blocked before merge. :: [P1] Preserve saved trigger and delivery settings during upgrades | [P2] Allow an unchanged update to retry after reopening the page
  • reviewed 2026-11-13T00:51:05.544Z sha 16825c7 :: blocked before merge. :: [P2] Make reopening start a genuinely new update attempt
  • reviewed 2026-11-13T01:04:15.836Z sha 3c29bd4 :: blocked before merge. :: [P1] Preserve explicit automation tool restrictions during re-declaration | [P2] Reuse the replacement attempt identity after a failed send
  • reviewed 2026-11-13T01:17:37.834Z sha c743638 :: needs changes before merge. :: [P2] Propagate failed automatic retries before marking them as updating

Reviewed November 12, 2026, 8:27 PM ET / November 13, 2026, 01:27 UTC (Revision 8).

Base automatically changed from openclaw/mellow-barnacle to main November 12, 2026 09:39
@jalehman
jalehman force-pushed the feat/knowledge-scribe-run-upgrades branch from 8b24c64 to 40139e5 Compare November 12, 2026 21:02
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 13, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 13, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 13, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. plugin: knowledge rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant