[PR #5695] [MERGED] agents: let a caller hand an agent prose to read, and report what a run changed #6888

Closed
opened 2026-10-23 04:14:37 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5695
Author: @GetBeholder
Created: 8/31/2026
Status: ✅ Merged
Merged: 8/31/2026
Merged by: @GetBeholder

Base: staging ← Head: feat/beholder-directive


📝 Commits (9)

  • 2c5b738 agents: let a caller hand an agent prose to read instead of the recent messages
  • fb84693 agents: expose a summary of one agent's recent runs in a chat
  • 71b83f6 agents: report what each Beholder run changed, not what it holds
  • 8bcb74c agents: report removals, and keep the boundary on a historical retry
  • 63d75ba Merge remote-tracking branch 'origin/staging' into feat/beholder-directive
  • 1328d91 agents: a character appearing or disappearing is itself a change
  • bcf1e56 agents: identify a character the way the normalizer does
  • fc0e14b Merge remote-tracking branch 'origin/staging' into feat/beholder-directive
  • 57dd32c Merge remote-tracking branch 'origin/staging' into feat/beholder-directive

📊 Changes

6 files changed (+211 additions, -2 deletions)

View changed files

📝 packages/server/src/routes/agents.routes.ts (+88 -0)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+43 -1)
📝 packages/server/src/services/agents/agent-executor.ts (+3 -1)
📝 packages/server/src/services/storage/agents.storage.ts (+26 -0)
📝 packages/shared/src/types/agent.ts (+9 -0)
➕ scripts/regressions/beholder-directive.regression.ts (+42 -0)

📄 Description

Three small additions supporting the Beholder capability package
(Pasta-Devs/Marinara-Agents#664). 168 lines added, 2 changed, across agent
context, the retry route, storage and one new read route. Nothing that exists
today behaves differently — the new paths only run when something sets them.

1. Prose to read instead of the recent messages

State-tracking agents read the story. That is the right default, but it leaves
no way to simply state a fact — "her sword is broken" — without writing a
paragraph for the agent to find it in.

AgentContext gains an optional narrationOverride, honoured in the executor
between the explicit argument and the story itself. The retry-agents route
accepts a matching beholderDirective, bounded and trimmed like any other free
text on the way in.

The subtle part is which prior state the run starts from. A retry re-runs a
message, so it correctly starts from the state as it was BEFORE that message and
re-derives it. A directive is not a re-run: it states a fact on top of what is
already there. Excluding the last message for a directive discarded everything
that turn had established — observed as a directive about one character wiping
every other character out of the panel — so the exclusion now applies to
retries only.

2. Recent runs of one agent type in a chat

getLastSuccessfulRunByType answers "what is the state now". A diagnostic panel
needs the other question — "what has this agent been doing" — because "it is not
working" is usually one of three things that look identical from the outside: it
never ran, it ran and failed, or it ran fine and found nothing.

listRunsByTypeForChat returns the recent runs newest first, failures included.
A run that errored is the most interesting row on such a list, and dropping it
would make a broken agent look idle rather than broken.

3. What each run changed

A run's stored result is the whole state as of that message, so a caller asking
"what did this turn do" got the running total and had to diff it themselves — or,
more likely, showed the total and called it the change. The route compares each
run against the one before it and returns the changed slots per character. It
reads one extra run beyond the requested window so the oldest entry still has a
predecessor, and where there is genuinely no earlier run it returns null rather
than a change list: the first extraction in a chat did not change a body, it
established one, and reporting every slot as changed would be wrong in the one
place it is most visible.

The route is deliberately narrow — Beholder-scoped, matching the beholder-state
routes already here, rate-limited alongside them, and returning shapes only:
slot names, counts, timings and errors, never the extracted content. The panel
already holds the current state, so this stays a health signal rather than a
second copy of the chat.

Verification

scripts/regressions/beholder-directive.regression.ts pins the narration
precedence order, the length bound, and that an empty directive falls through to
the story rather than becoming empty narration. Picked up automatically by
pnpm regression. Server typecheck clean.

Exercised end to end against a local build through the capability package: a
directive updates the state it names and leaves every other character intact,
and the runs route reports the two hand slots a directive changed rather than
the four slots the state holds.

🤖 Generated with Claude Code

https://claude.ai/code/session_01992DGH2exasKGaJiqRnteC

Summary by CodeRabbit

  • New Features

    • Added diagnostic summaries for recent Beholder runs, including timing, outcomes, counts, errors, and detected character or slot changes.
    • Added optional directives when retrying agents to guide Beholder processing with custom instructions.
    • Directives are trimmed and limited to 2,000 characters.
  • Bug Fixes

    • Improved narration selection so explicit directives take priority.
    • Initial runs now correctly report no prior changes.
  • Tests

    • Added regression coverage for directive handling and fallback behavior.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/5695 **Author:** [@GetBeholder](https://github.com/GetBeholder) **Created:** 8/31/2026 **Status:** ✅ Merged **Merged:** 8/31/2026 **Merged by:** [@GetBeholder](https://github.com/GetBeholder) **Base:** `staging` ← **Head:** `feat/beholder-directive` --- ### 📝 Commits (9) - [`2c5b738`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2c5b738189fd8593d2230c1a6c42d8da167b7a38) agents: let a caller hand an agent prose to read instead of the recent messages - [`fb84693`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fb8469362a35c74de130f250b53e76d9d04b9d54) agents: expose a summary of one agent's recent runs in a chat - [`71b83f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/71b83f6647d64e83cd6e869e9a006d6448a642bc) agents: report what each Beholder run changed, not what it holds - [`8bcb74c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8bcb74cbd189dbe18db18ae7550fddb19f441114) agents: report removals, and keep the boundary on a historical retry - [`63d75ba`](https://github.com/Pasta-Devs/Marinara-Engine/commit/63d75ba1d91ab2e651ef06224f691c2657a270e6) Merge remote-tracking branch 'origin/staging' into feat/beholder-directive - [`1328d91`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1328d91e8458e568a9838a6051b3ffbe6ce440e7) agents: a character appearing or disappearing is itself a change - [`bcf1e56`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bcf1e5643cf30133f28bc107a06a2e0b9b272012) agents: identify a character the way the normalizer does - [`fc0e14b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fc0e14bbe4685be567014314a4172ea5a89dd3e3) Merge remote-tracking branch 'origin/staging' into feat/beholder-directive - [`57dd32c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/57dd32ce4fe3c7648670caac4f4a10045b4f1ac0) Merge remote-tracking branch 'origin/staging' into feat/beholder-directive ### 📊 Changes **6 files changed** (+211 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/agents.routes.ts` (+88 -0) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+43 -1) 📝 `packages/server/src/services/agents/agent-executor.ts` (+3 -1) 📝 `packages/server/src/services/storage/agents.storage.ts` (+26 -0) 📝 `packages/shared/src/types/agent.ts` (+9 -0) ➕ `scripts/regressions/beholder-directive.regression.ts` (+42 -0) </details> ### 📄 Description Three small additions supporting the Beholder capability package (Pasta-Devs/Marinara-Agents#664). 168 lines added, 2 changed, across agent context, the retry route, storage and one new read route. Nothing that exists today behaves differently — the new paths only run when something sets them. ## 1. Prose to read instead of the recent messages State-tracking agents read the story. That is the right default, but it leaves no way to simply state a fact — "her sword is broken" — without writing a paragraph for the agent to find it in. `AgentContext` gains an optional `narrationOverride`, honoured in the executor between the explicit argument and the story itself. The retry-agents route accepts a matching `beholderDirective`, bounded and trimmed like any other free text on the way in. The subtle part is which prior state the run starts from. A retry re-runs a message, so it correctly starts from the state as it was BEFORE that message and re-derives it. A directive is not a re-run: it states a fact on top of what is already there. Excluding the last message for a directive discarded everything that turn had established — observed as a directive about one character wiping every other character out of the panel — so the exclusion now applies to retries only. ## 2. Recent runs of one agent type in a chat `getLastSuccessfulRunByType` answers "what is the state now". A diagnostic panel needs the other question — "what has this agent been doing" — because "it is not working" is usually one of three things that look identical from the outside: it never ran, it ran and failed, or it ran fine and found nothing. `listRunsByTypeForChat` returns the recent runs newest first, failures included. A run that errored is the most interesting row on such a list, and dropping it would make a broken agent look idle rather than broken. ## 3. What each run changed A run's stored result is the whole state as of that message, so a caller asking "what did this turn do" got the running total and had to diff it themselves — or, more likely, showed the total and called it the change. The route compares each run against the one before it and returns the changed slots per character. It reads one extra run beyond the requested window so the oldest entry still has a predecessor, and where there is genuinely no earlier run it returns `null` rather than a change list: the first extraction in a chat did not change a body, it established one, and reporting every slot as changed would be wrong in the one place it is most visible. The route is deliberately narrow — Beholder-scoped, matching the beholder-state routes already here, rate-limited alongside them, and returning shapes only: slot names, counts, timings and errors, never the extracted content. The panel already holds the current state, so this stays a health signal rather than a second copy of the chat. ## Verification `scripts/regressions/beholder-directive.regression.ts` pins the narration precedence order, the length bound, and that an empty directive falls through to the story rather than becoming empty narration. Picked up automatically by `pnpm regression`. Server typecheck clean. Exercised end to end against a local build through the capability package: a directive updates the state it names and leaves every other character intact, and the runs route reports the two hand slots a directive changed rather than the four slots the state holds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01992DGH2exasKGaJiqRnteC <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added diagnostic summaries for recent Beholder runs, including timing, outcomes, counts, errors, and detected character or slot changes. - Added optional directives when retrying agents to guide Beholder processing with custom instructions. - Directives are trimmed and limited to 2,000 characters. - **Bug Fixes** - Improved narration selection so explicit directives take priority. - Initial runs now correctly report no prior changes. - **Tests** - Added regression coverage for directive handling and fallback behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:14:37 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6888
No description provided.