[PR #4761] [MERGED] Fix assigned context, JSON repair, and background cache issues #6490

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

📋 Pull Request Information

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

Base: staging ← Head: agent/fix-4752-4753-4757


📝 Commits (4)

  • 714b11c chore: coordinate assigned issue sweep
  • be6112a fix: resolve assigned context and agent regressions
  • 720f904 fix: reject array-shaped agent responses
  • 3abf111 Merge branch 'staging' into agent/fix-4752-4753-4757

📊 Changes

12 files changed (+412 additions, -175 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 e2e/core-flows.e2e.ts (+131 -0)
📝 packages/client/src/components/chat/HomeProfessorMariChat.tsx (+49 -0)
➕ packages/client/src/lib/professor-mari-context-budget.ts (+56 -0)
📝 packages/client/src/localization/locales/en.json (+3 -0)
➕ packages/server/src/lib/json-repair.ts (+65 -0)
📝 packages/server/src/routes/backgrounds.routes.ts (+1 -1)
📝 packages/server/src/services/agents/agent-executor.ts (+13 -107)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+29 -67)
📝 packages/shared/src/types/professor-mari-workspace.ts (+1 -0)
📝 scripts/regressions/agent-runtime.regression.ts (+31 -0)
📝 scripts/regressions/open-issues.regression.ts (+30 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issues

Closes #4752
Closes #4753
Closes #4757

Why this change

  • Professor Mari Workspace recorded model usage but did not show how much of the selected model's context window the latest turn occupied.
  • Structured downloadable agents used a weaker malformed-JSON repair path than Professor Mari Workspace, causing avoidable retries and failures.
  • User backgrounds were cached as immutable for one year even though users can delete and replace a file at the same URL.

What changed

  • Added a compact, localized Workspace context bar behind the existing Show token usage on messages preference. It uses the latest provider-reported prompt and completion counts, the selected connection's context limit, and a legacy metadata fallback.
  • Persisted Professor Mari's latest usage in the canonical message generation fields while retaining aggregate turn usage for compatibility.
  • Extracted the existing jsonrepair and container-closing waterfall into one server helper and reused it for all structured agent responses, including incomplete Markdown fences.
  • Changed user background responses from one-year immutable caching to mandatory revalidation.
  • Added positive and negative JSON repair regressions, pure context-budget coverage, and desktop/mobile browser proofs for both new UI and same-URL background replacement.
  • Added Unreleased changelog entries for all three issues.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Automated evidence completed:

  • pnpm check
  • scripts/regressions/agent-runtime.regression.ts
  • scripts/regressions/open-issues.regression.ts
  • Focused desktop and mobile Chromium coverage for the context indicator and same-filename background replacement (4 passed)

All boxes remain intentionally unchecked for human verification.

Manual verification notes

  • Manually verify the context indicator with a real provider after a multi-command Professor Mari Workspace turn.
  • Manually replace a deleted background with a different image using the same filename in a previously affected Windows browser.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

  • Automated desktop and mobile Chromium assertions cover the localized label, compact token value, and accessible progressbar values.

Summary by CodeRabbit

  • New Features

    • Added a context-budget indicator to Professor Mari Workspace when token usage is enabled.
    • Displays used and maximum tokens with accessible labels and compact formatting.
  • Bug Fixes

    • Improved recovery from malformed structured responses, reducing unnecessary retries.
    • Re-uploaded backgrounds now reliably display fresh image content instead of stale cached versions.
  • Tests

    • Added end-to-end and regression coverage for context usage, JSON recovery, and background replacement 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/4761 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/8/2026 **Status:** ✅ Merged **Merged:** 8/8/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `agent/fix-4752-4753-4757` --- ### 📝 Commits (4) - [`714b11c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/714b11c5e66e14c82a3d63cdd045c2f5ff9eb543) chore: coordinate assigned issue sweep - [`be6112a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/be6112a70aa16854291a47a4ebc9c19a6ef1c96d) fix: resolve assigned context and agent regressions - [`720f904`](https://github.com/Pasta-Devs/Marinara-Engine/commit/720f9043c177032a3616994fa4e2190ff4cfa06f) fix: reject array-shaped agent responses - [`3abf111`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3abf111c493fd1e5bacea310ecf5b6bd9da67c6f) Merge branch 'staging' into agent/fix-4752-4753-4757 ### 📊 Changes **12 files changed** (+412 additions, -175 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `e2e/core-flows.e2e.ts` (+131 -0) 📝 `packages/client/src/components/chat/HomeProfessorMariChat.tsx` (+49 -0) ➕ `packages/client/src/lib/professor-mari-context-budget.ts` (+56 -0) 📝 `packages/client/src/localization/locales/en.json` (+3 -0) ➕ `packages/server/src/lib/json-repair.ts` (+65 -0) 📝 `packages/server/src/routes/backgrounds.routes.ts` (+1 -1) 📝 `packages/server/src/services/agents/agent-executor.ts` (+13 -107) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+29 -67) 📝 `packages/shared/src/types/professor-mari-workspace.ts` (+1 -0) 📝 `scripts/regressions/agent-runtime.regression.ts` (+31 -0) 📝 `scripts/regressions/open-issues.regression.ts` (+30 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issues Closes #4752 Closes #4753 Closes #4757 ## Why this change - Professor Mari Workspace recorded model usage but did not show how much of the selected model's context window the latest turn occupied. - Structured downloadable agents used a weaker malformed-JSON repair path than Professor Mari Workspace, causing avoidable retries and failures. - User backgrounds were cached as immutable for one year even though users can delete and replace a file at the same URL. ## What changed - Added a compact, localized Workspace context bar behind the existing **Show token usage on messages** preference. It uses the latest provider-reported prompt and completion counts, the selected connection's context limit, and a legacy metadata fallback. - Persisted Professor Mari's latest usage in the canonical message generation fields while retaining aggregate turn usage for compatibility. - Extracted the existing `jsonrepair` and container-closing waterfall into one server helper and reused it for all structured agent responses, including incomplete Markdown fences. - Changed user background responses from one-year immutable caching to mandatory revalidation. - Added positive and negative JSON repair regressions, pure context-budget coverage, and desktop/mobile browser proofs for both new UI and same-URL background replacement. - Added Unreleased changelog entries for all three issues. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Automated evidence completed: - `pnpm check` - `scripts/regressions/agent-runtime.regression.ts` - `scripts/regressions/open-issues.regression.ts` - Focused desktop and mobile Chromium coverage for the context indicator and same-filename background replacement (4 passed) All boxes remain intentionally unchecked for human verification. ### Manual verification notes - Manually verify the context indicator with a real provider after a multi-command Professor Mari Workspace turn. - Manually replace a deleted background with a different image using the same filename in a previously affected Windows browser. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) - Automated desktop and mobile Chromium assertions cover the localized label, compact token value, and accessible progressbar values. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a context-budget indicator to Professor Mari Workspace when token usage is enabled. * Displays used and maximum tokens with accessible labels and compact formatting. * **Bug Fixes** * Improved recovery from malformed structured responses, reducing unnecessary retries. * Re-uploaded backgrounds now reliably display fresh image content instead of stale cached versions. * **Tests** * Added end-to-end and regression coverage for context usage, JSON recovery, and background replacement 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:10:54 +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#6490
No description provided.