Skip to content

refactor: share agent runtime hygiene helpers#25

Open
vaskarvelas wants to merge 1 commit intoagent0ai:mainfrom
vaskarvelas:refactor/shared-runtime-hygiene
Open

refactor: share agent runtime hygiene helpers#25
vaskarvelas wants to merge 1 commit intoagent0ai:mainfrom
vaskarvelas:refactor/shared-runtime-hygiene

Conversation

@vaskarvelas
Copy link
Copy Markdown

@vaskarvelas vaskarvelas commented Apr 23, 2026

Summary

Extract shared runtime-hygiene helpers for the first-party agent stores and route both admin and onscreen lifecycle message processing through the same helper layer.

TL;DR;
It helps the agent save tokens even more.

Why

Both stores were carrying overlapping logic for:

  • cloning conversation messages
  • sanitizing assistant-message evaluation input
  • applying processed message mutations safely
  • routing processed lifecycle messages through the existing extension seams

That duplication made it easier for the two runtimes to drift and harder to add new lifecycle processing consistently.

What changed

  • add _core/agent-chat/runtime-hygiene.js
  • move shared message clone/apply/normalize/resolve/create helpers there
  • update admin store to use shared helpers for:
    • submit
    • assistant-response
    • history-compact
    • protocol-retry
    • execution-output
  • update onscreen store to use the same shared helper flow
  • keep existing processAdminAgentMessage / processOnscreenAgentMessage seams intact
  • add tests/runtime_hygiene_test.mjs
  • update owning docs and supplemental runtime docs for the new shared helper contract

Safety / behavior notes

This is intended as a refactor and seam consolidation, not a product behavior change. The existing extension seams remain in place; the new helper layer only centralizes shared runtime hygiene and mutation isolation.

Test plan

Passed:

  • node --test tests/runtime_hygiene_test.mjs tests/assistant_message_evaluation_test.mjs
  • node --check app/L0/_all/mod/_core/admin/views/agent/store.js
  • node --check app/L0/_all/mod/_core/onscreen_agent/store.js
  • node --check app/L0/_all/mod/_core/agent-chat/runtime-hygiene.js

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant