Skip to content

fix(memory): preserve system prompt in honcho_reasoning truncation (#59469) - #59664

Closed
SquabbyZ wants to merge 1 commit into
NousResearch:mainfrom
SquabbyZ:fix/medium-08-issue-59469
Closed

SquabbyZ wants to merge 1 commit into
NousResearch:mainfrom
SquabbyZ:fix/medium-08-issue-59469

Conversation

@SquabbyZ

@SquabbyZ SquabbyZ commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #59469

Problem

honcho_reasoning tool results longer than dialecticMaxChars (default 600) were silently truncated to the auto-injection budget. The model deliberately asked Honcho for a full synthesized answer but the response came back clipped mid-word with a trailing " …" and no warning — the system-prompt injection guardrail was wrongly applied to an explicit tool result.

Fix

dialectic_query() in plugins/memory/honcho/session.py now accepts apply_injection_cap: bool = True:

  • Auto-injection path (_run_dialectic_depthdialectic_query) keeps the default True so the per-turn system-prompt supplement is still bounded — this is the path the cap was originally designed for.
  • honcho_reasoning tool handler in plugins/memory/honcho/__init__.py passes apply_injection_cap=False so an explicit call returns Honcho's full synthesized answer untouched.

When the cap is applied and truncation occurs, the result now ends with … [truncated, full result in logs] instead of a bare ellipsis, and a WARN log names the original length and cap so operators can tune the budget or fix the over-long prompt. The full pre-truncation text is also emitted at DEBUG level. No more silent failure.

Backward compatible: the default kwarg preserves the existing auto-injection behavior, so the only caller-visible changes are the more explicit truncation marker and the warning log.

Tests

tests/plugins/test_honcho_truncation.py — 7 tests, all passing:

  1. Short result → no truncation regardless of cap setting.
  2. Long result with cap on (auto-injection path) → truncated, marker visible.
  3. Long result with cap off (honcho_reasoning tool path) → returned untouched.
  4. Truncation emits WARN with original length and cap value.
  5. Short result does not log a false-positive WARN.
  6. Long result with cap off does not log a WARN.
  7. Default apply_injection_cap=True preserves prior auto-injection behavior.

Existing honcho tests (22 passed, 1 skipped, no regressions) confirm the default-path semantics are unchanged.

Files

  • plugins/memory/honcho/session.pydialectic_query() signature + truncation logic
  • plugins/memory/honcho/__init__.pyhoncho_reasoning handler passes apply_injection_cap=False
  • tests/plugins/test_honcho_truncation.py — new test file

AI-assisted fix by https://github.com/SquabbyZ/peaks-loop

…ousResearch#59469)

The honcho_reasoning tool path was inheriting the auto-injection
dialecticMaxChars (default 600) cap. When the model explicitly asked
Honcho for a synthesized answer, the result was silently cut mid-word
with a trailing " …" — the system-prompt injection budget had no
business clipping an explicit tool result.

Fix:
* dialectic_query() gains apply_injection_cap: bool = True. The auto-
  injection path (_run_dialectic_depth → dialectic_query) keeps the
  default cap; honcho_reasoning passes False.
* When the cap IS applied and truncation occurs, the result now ends
  with " … [truncated, full result in logs]" instead of a bare
  ellipsis, and a WARN log names the original length and cap so the
  operator can tune the budget or fix the over-long prompt. The full
  pre-truncation text is also emitted at DEBUG level.

Backward compatible: default kwarg preserves the existing auto-
injection behavior; the only caller-visible change is the more
explicit truncation marker and the warning log.

Tests in tests/plugins/test_honcho_truncation.py cover: short result
pass-through, long result truncated with marker, long result preserved
when cap is off, WARN logged with original length, no false-positive
WARNs on short results or when cap is disabled, default kwarg preserves
existing behavior.

Fixes NousResearch#59469
AI-assisted fix by https://github.com/SquabbyZ/peaks-loop

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jul 6, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Duplicate of #59471 — same mechanism (apply_injection_cap flag on dialectic_query() scoping the dialecticMaxChars truncation to the auto-injection path only; the honcho_reasoning tool handler passes apply_injection_cap=False) and same code sites fixing #59469; #59471 was opened earlier and is canonical. The clearer truncation marker + WARN log here don't change the underlying fix. Related: #59470 / #59665 (the distinct 250-token tier-selection facet).

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the focused fix. The underlying premise is live on current main: plugins/memory/honcho/session.py:658-660 applies dialecticMaxChars to all dialectic queries, while plugins/memory/honcho/__init__.py:1358-1362 sends explicit honcho_reasoning through that method.

Problems

  • In plugins/memory/honcho/session.py:683, the code slices up to cap and then appends … [truncated, full result in logs]. That can exceed the configured injection budget, whose documented contract is a maximum at website/docs/user-guide/features/honcho.md:124.
  • tests/plugins/test_honcho_truncation.py tests manager calls directly, but does not prove the tool handler supplies apply_injection_cap=False. The existing handler-level assertion is tests/honcho_plugin/test_session.py:488-506.

Suggested changes

  • Reserve suffix space before slicing, or retain the compact existing suffix, and assert the capped result remains within the configured budget.
  • Extend the existing honcho_reasoning dispatch test to assert apply_injection_cap=False.

Automated hermes-sweeper review.

original_full = result
truncated_len = len(result)
cap = self._dialectic_max_chars
result = result[:cap].rsplit(" ", 1)[0] + (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

dialecticMaxChars is documented as the maximum injected result length, but this slices to cap and then appends a much longer marker. Please reserve suffix capacity before slicing (and add a cap-boundary assertion) so the auto-injection guardrail remains bounded.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@teknium1

Copy link
Copy Markdown
Collaborator

This is now fixed on main via #62290 (commit 8d1c96f), which adopted the earliest submission for #59469 (#59471 by @vizi0uz). dialecticMaxChars is now scoped to automatic context injection, so explicit honcho_reasoning results return Honcho's full answer rather than being truncated at all. Thanks for the fix, sorry it collided with an earlier duplicate.

@teknium1 teknium1 closed this Jul 16, 2026
@teknium1 teknium1 added the area/memory Memory subsystem: store, providers, sync, background reviews label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/memory Memory subsystem: store, providers, sync, background reviews comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: honcho_reasoning results silently truncated to dialecticMaxChars (system-prompt injection budget wrongly applied to explicit tool results)

3 participants