Skip to content

fix(subagent): raise maintenance delegate token ceilings for dense archives - #97

Closed
Shimmernight wants to merge 1 commit into
omdsh-dev:mainfrom
Shimmernight:fix/subagent-maintenance-maxtokens
Closed

fix(subagent): raise maintenance delegate token ceilings for dense archives#97
Shimmernight wants to merge 1 commit into
omdsh-dev:mainfrom
Shimmernight:fix/subagent-maintenance-maxtokens

Conversation

@Shimmernight

Copy link
Copy Markdown

Problem

When runtime MEMORY.md is at capacity, every mnemon_runtime_memory add delegates to maintenance workers (archive routing / local compaction / metadata sampling). Those workers are capped at 8192 (and 4096 for metadata-maintenance) completion tokens. Reasoning models spend most of that budget on analysis before emitting the small structured result, so the worker stops with stopReason=max-tokens and the whole tool call aborts — with zero writes.

Reproducible with dense CJK content. Reported upstream as #70 (still fails on 0.3.0) and #83/#85 (same symptom, auto-closed for form issues).

Root cause

src/subagent.ts — static per-op ceilings override the host-resolved token budget:

const perOpMaxTokens = operation === 'migration' || operation === 'compaction' || operation === 'document-archive' ? 8_192
  : operation === 'metadata-maintenance' ? 4_096
  : undefined

Fix

Raise the ceilings to 32768 / 16384. The structured output of these workers is still small; the caps only bounded the analysis budget, which is the part that needs headroom. Fixes-class change: no new config surface, no issue gate required.

  • src/subagent.ts: 8_192 → 32_768, 4_096 → 16_384
  • tests/subagent.spec.ts: update the pinned expectations (metadata 4_096 → 16_384; migration/compaction/merge 8_192 → 32_768)

Verification

  • pnpm exec tsc --noEmit — clean
  • pnpm exec vitest run tests/subagent.spec.ts — 42/42 passing

Notes

The static ceilings remain finite. #70's deterministic bulk-import direction would remove the LLM dependency entirely; this PR is a targeted stopgap until that lands.

…chives

Maintenance delegations (migration/compaction/document-archive) were
capped at 8192 and metadata-maintenance at 4096 completion tokens.
Reasoning models spend most of that budget on analysis before emitting
the small structured result, so the whole capacity-overflow operation
aborted with stopReason=max-tokens (dense CJK archives, see omdsh-dev#70).

Raise the ceilings to 32768/16384. The structured output stays small;
the caps only bounded the analysis budget, which is the part that
needs headroom. Fixes-class change: no new config surface, no issue
gate required.

Co-Authored-By: none
@Grivn

Grivn commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

感谢提交。最新 main 已通过 #102 支持配置 Runtime 迁移和压缩的 token 预算,容量归档也已有确定性写入及模型路由失败回退,因此不再采用统一提高固定上限的方案,本次关闭此 PR。

文档归档和元数据维护仍使用固定预算。如果这些路径在最新 main 上仍出现 max-tokens,可以提供对应复现,再针对具体场景调整。

@Grivn Grivn closed this Aug 30, 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.

2 participants