Skip to content

Refusal hint and consolidation proposals render row-derived text unflattened #299

Closed

Description

@ocsi-architect

Part of #292.

Problem

Two model-facing renderers interpolate row-derived text without flattenMemoryText, so a control character stored earlier survives into tool output as a real line break:

  1. The refusal hint embeds the tombstone reason unflattened: src/gate/gate.ts:822 builds why from redactSecrets(rejection.tombstone.reason) and splices it into reason: ${why} (src/gate/gate.ts:835-836). ForgetArgs.reason is a plain z.string() (src/tools/schema.ts:112) and flows through pruneMemory → tombstoneMany (src/store/files/prune.ts:129-135) untouched, so a forget reason containing \n re-enters a later matching write's hint with a real newline.
  2. renderProposals slices row content as stored: src/consolidate/render.ts:16-17 interpolates p.survivor.content.slice(0, 160) and loser content directly, while memory_recall flattens the same rows through flattenMemoryText (src/inject/format.ts:27-30).

The repo's own rule is stated in src/tools/schema.ts:26-29: content stays multiline in the store and "is flattened only when rendered" — these two render sites miss the flatten. Impact is formatting hygiene only: the tool result is already free-form text, the store file stays one record per line, and nothing reaches the system prompt. #35 deliberately put the reason in the hint, so only the unflattened splice is in question.

Fix direction

Flatten at the render seam in both places: flattenMemoryText(redactSecrets(rejection.tombstone.reason)) at src/gate/gate.ts:822, and flattenMemoryText(...) around the two content slices in src/consolidate/render.ts:16-17. Add pins: a tombstoned reason with an embedded newline yields a single-line hint; a multi-line survivor/loser row renders one output line per row.

Acceptance

RED: on main 7405dc61d919e7eee7033dea6e4324eda58ee669, (a) tombstone content with reason "a\nb" (direct tombstone() call, bypassing the schema) then trigger a matching write — the returned hint contains a real line break; (b) renderProposals over a plan whose survivor content contains \n emits more than one line for that row — both tests fail.
GREEN: bun run test passes; both outputs are single-line per record; credential redaction in the hint is unchanged.

Activity

  1. added
    severity:low
    spec:draft
    on Nov 4, 2026
  2. added
    agent:ready
    on Nov 5, 2026
  3. abogartz-opencode-self-improvement commented on Nov 9, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.22.1 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:readyreleasedseverity:lowspec:draft

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions