Skip to content

fix(harness): preserve exact Assistant history provenance [SAP-3292] - #1021

Closed
ynadge wants to merge 1 commit into
assistant-prepared-contextfrom
assistant-history-review-fixes
Closed

ynadge wants to merge 1 commit into
assistant-prepared-contextfrom
assistant-history-review-fixes

Conversation

@ynadge

@ynadge ynadge commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Bug fix

Problem and motivation

Oversized retained turns could lose the latest Assistant result, and a contradictory sibling legacy association could suppress the original native import.

Summary and scope

Reduce briefs structurally while preserving user context and the newest useful Assistant messages/parts, with deterministic omission markers. Reject a matching native scope whose saved workspace contradicts the requested binding before any replacement creation.

Related work

Related issue: https://linear.app/sapiom/issue/SAP-3292

Depends on #1020. Native stack target: main.

Validation

46 focused tests passed, including association, Resume receipt, brief and Continue integration cases. Full Harness server/web TypeScript, scoped ESLint and diff checks passed.

Tests and documentation

Added newest-message/part/empty-message pressure cases and legitimate-vs-contradictory sibling association cases. Updated assistant-history.md. Increment:200 changed lines including tests/docs/changeset; SDK pr:size is absent.

Compatibility and release impact

  • Recorded excerpts stay within the same limits and retain explicit incompleteness/provenance.
  • Changeset: @sapiom/harness patch.
  • Fix-forward: preserve exact native identity and newest useful recorded state while correcting bounded projection.

Security

  • No secrets, credentials, private data, or unsanitized logs included.
  • No suspected vulnerability disclosed publicly.

AI assistance

  • AI assistance used: Codex implemented and reviewed the change with the validation described above.

Checklist

  • CONTRIBUTING.md read; maintainer-authorized issue work.
  • One focused increment, checks, documentation and release impact addressed.
  • I can explain and maintain the submitted changes.

Devin Review

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 0238d918-0a05-4f3d-9c94-d8f4dcd47451

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment on lines +46 to +49
const selected =
message.role === "assistant"
? message.parts.slice(-12)
: message.parts.slice(0, 12);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Trailing placeholders erase Assistant state

When 12 trailing placeholders follow useful state, selected drops the latest useful Assistant part. The continuation retains placeholders and labels the useful state as omitted.

Learn more

Assistant messages can contain blank text and omitted parts for native bookkeeping. The 12-part cap currently selects by position alone. Therefore, 12 trailing placeholders displace every useful text, tool, or file part before them. The later useful flag examines the complete message, so it still marks this now-empty excerpt useful and preserves it during message reduction.

Example: An Assistant message contains one text part saying Verification still pending, followed by 12 step-finish parts projected as omitted. The brief includes 12 omission placeholders and 1 earlier parts omitted, but loses the verification state.

Recommended fix: Select the newest 12 useful Assistant parts while retaining any necessary omission marker. Define usefulness consistently with the message-level predicate, and add coverage where useful text precedes at least 12 blank or omitted parts.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@ynadge ynadge closed this Sep 15, 2026
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