Skip to content

fix(agents): filter runtime context from context engines#76251

Merged
vincentkoc merged 1 commit into
mainfrom
fix/context-engine-runtime-filter
May 5, 2026
Merged

fix(agents): filter runtime context from context engines#76251
vincentkoc merged 1 commit into
mainfrom
fix/context-engine-runtime-filter

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

  • filter hidden openclaw.runtime-context custom messages before harness context-engine assemble, afterTurn, and ingest fallback hooks
  • preserve the pre-prompt/new-turn boundary after filtering so fallback ingestion only receives actual new conversation messages
  • add regression coverage for assemble, afterTurn, and ingestBatch fallback behavior

Tests

  • pnpm test src/agents/harness/context-engine-lifecycle.test.ts -- --reporter=verbose
  • pnpm exec oxfmt --check --threads=1 src/agents/harness/context-engine-lifecycle.ts src/agents/harness/context-engine-lifecycle.test.ts CHANGELOG.md
  • git diff --check origin/main...HEAD
  • pnpm testbox:run --id tbx_01kqn6fkkfrhnm91n4d38s4h4s -- "OPENCLAW_TESTBOX=1 pnpm check:changed"

@vincentkoc vincentkoc self-assigned this May 2, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels May 2, 2026
@clawsweeper

clawsweeper Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The branch filters hidden openclaw.runtime-context custom messages before context-engine assemble, afterTurn, and ingest fallback hooks, then adds lifecycle regression tests and a changelog entry.

Reproducibility: yes. Source inspection on current main shows assembleHarnessContextEngine and finalizeHarnessContextEngineTurn pass unfiltered message arrays into context-engine hooks, so a hidden runtime-context custom message in those arrays reaches the hook.

Real behavior proof
Not applicable: The external-contributor proof gate does not apply because this is a MEMBER maintainer-labeled PR.

Next step before merge
Draft maintainer-labeled MEMBER PR needs maintainer undraft/review; there is no narrow ClawSweeper repair finding.

Security
Cleared: The diff only touches TypeScript lifecycle code, a colocated test, and the changelog; it does not change dependencies, CI, secrets, scripts, permissions, or package resolution.

Review details

Best possible solution:

Keep the lifecycle-boundary filter and regression coverage, then land after maintainer undraft/review and exact-head checks remain green.

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

Yes. Source inspection on current main shows assembleHarnessContextEngine and finalizeHarnessContextEngineTurn pass unfiltered message arrays into context-engine hooks, so a hidden runtime-context custom message in those arrays reaches the hook.

Is this the best way to solve the issue?

Yes. Reusing the existing runtime-context custom-message stripper at the harness lifecycle boundary is the narrow maintainable fix, and the proposed helper preserves the pre-prompt/new-turn boundary by filtering each side separately.

What I checked:

Likely related people:

  • @jalehman: GitHub commit history shows Josh Lehman introduced the app-server harness context-engine lifecycle in feat(codex): run context-engine lifecycle in app-server harness #70809 and is repeatedly credited/reviewed in context-engine contract history. (role: introduced and reviewed adjacent context-engine lifecycle work; confidence: high; commits: 51186d272543, 751d5b7849ca, 75e7fc97f804; files: src/agents/harness/context-engine-lifecycle.ts, src/context-engine/types.ts)
  • @steipete: Recent main history shows Peter Steinberger touching the harness lifecycle file, runtime-context helper file, and transcript hygiene/runtime-context behavior around this area. (role: recent maintainer of runtime-context and context-engine paths; confidence: high; commits: f7ed29e11812, 9a9fefd21fe2, 11e6928b3edc; files: src/agents/harness/context-engine-lifecycle.ts, src/agents/internal-runtime-context.ts, docs/reference/transcript-hygiene.md)
  • @vincentkoc: Beyond authoring this PR, current-main history shows Vincent Koc recently changed context-engine-related code and transcript-hygiene docs, making him relevant to follow-up review. (role: recent adjacent context-engine maintainer; confidence: medium; commits: 2988203a5e52, 5bba899a7062; files: src/context-engine/types.ts, docs/reference/transcript-hygiene.md)

Remaining risk / open question:

  • This read-only review did not execute the PR tests; it relies on source inspection and the test commands reported in the PR body.
  • The PR is draft and was recently force-pushed, so exact-head validation may need to be repeated before merge.

Codex review notes: model gpt-5.5, reasoning high; reviewed against c874c0863ada.

@vincentkoc vincentkoc force-pushed the fix/context-engine-runtime-filter branch from d06d436 to 4740481 Compare May 5, 2026 23:24
@vincentkoc vincentkoc force-pushed the fix/context-engine-runtime-filter branch from 4740481 to 1eed41b Compare May 5, 2026 23:47
@vincentkoc vincentkoc marked this pull request as ready for review May 5, 2026 23:47
@vincentkoc vincentkoc merged commit b3ab3cd into main May 5, 2026
115 of 117 checks passed
@vincentkoc vincentkoc deleted the fix/context-engine-runtime-filter branch May 5, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant