Resolves #13981
Bounds REM graph structured-output generation for LMS/OpenAI-compatible chat calls so turn-boundary input chunking is not undermined by unbounded JSON output. The patch adds an ADR-19 AiConfig.localModels.chat.graphOutputLimitTokens leaf, applies it to Tri-Vector and topology graph extraction calls via max_tokens, preserves LMS streaming finish_reason metadata when present, and logs chunk-start details before each Tri-Vector provider call.
Evidence: L2 unit/static validation covers #13981 AC1-AC5. Residual: post-merge live REM backlog drain should confirm LMS no longer grows past the bounded chunk/output contract on the active backlog.
Deltas from ticket
- Used
max_tokens only for LMS/OpenAI-compatible payload compatibility; no wall-clock timeout was added.
- Kept provider envelope compatibility:
finish_reason fields are only added when LMS sends finish metadata.
- Applied the same graph output cap to topology inference because it is the second REM graph-provider call path.
Test Evidence
node --check ai/config.template.mjs
node --check ai/provider/OpenAiCompatible.mjs
node --check ai/services/graph/TopologyInferenceEngine.mjs
git diff --check
npm run test-unit -- test/playwright/unit/ai/provider/KeepAlive.spec.mjs — 22 passed, 1 skipped
npm run test-unit -- test/playwright/unit/ai/services/graph/SemanticGraphExtractor.spec.mjs — 12 passed
npm run test-unit -- test/playwright/unit/ai/config.template.spec.mjs — 8 passed
npm run agent-preflight -- ai/config.template.mjs ai/provider/OpenAiCompatible.mjs ai/services/graph/SemanticGraphExtractor.mjs ai/services/graph/TopologyInferenceEngine.mjs test/playwright/unit/ai/config.template.spec.mjs test/playwright/unit/ai/provider/KeepAlive.spec.mjs test/playwright/unit/ai/services/graph/SemanticGraphExtractor.spec.mjs
Post-Merge Validation
Commit
079858ee28 — fix(ai): bound LMS REM graph output (#13981)
Authored by Euclid (GPT-5, Codex Desktop). Session 019ef378-527d-7393-bc74-ec3a1d3f2ddf.
Resolves #13981
Bounds REM graph structured-output generation for LMS/OpenAI-compatible chat calls so turn-boundary input chunking is not undermined by unbounded JSON output. The patch adds an ADR-19
AiConfig.localModels.chat.graphOutputLimitTokensleaf, applies it to Tri-Vector and topology graph extraction calls viamax_tokens, preserves LMS streamingfinish_reasonmetadata when present, and logs chunk-start details before each Tri-Vector provider call.Evidence: L2 unit/static validation covers #13981 AC1-AC5. Residual: post-merge live REM backlog drain should confirm LMS no longer grows past the bounded chunk/output contract on the active backlog.
Deltas from ticket
max_tokensonly for LMS/OpenAI-compatible payload compatibility; no wall-clock timeout was added.finish_reasonfields are only added when LMS sends finish metadata.Test Evidence
node --check ai/config.template.mjsnode --check ai/provider/OpenAiCompatible.mjsnode --check ai/services/graph/TopologyInferenceEngine.mjsgit diff --checknpm run test-unit -- test/playwright/unit/ai/provider/KeepAlive.spec.mjs— 22 passed, 1 skippednpm run test-unit -- test/playwright/unit/ai/services/graph/SemanticGraphExtractor.spec.mjs— 12 passednpm run test-unit -- test/playwright/unit/ai/config.template.spec.mjs— 8 passednpm run agent-preflight -- ai/config.template.mjs ai/provider/OpenAiCompatible.mjs ai/services/graph/SemanticGraphExtractor.mjs ai/services/graph/TopologyInferenceEngine.mjs test/playwright/unit/ai/config.template.spec.mjs test/playwright/unit/ai/provider/KeepAlive.spec.mjs test/playwright/unit/ai/services/graph/SemanticGraphExtractor.spec.mjsPost-Merge Validation
dev, run the config overlay update script, restart the orchestrator, and confirm the pending REM backlog resumes with LMS chunk logs and without over-cap growth.Commit
079858ee28—fix(ai): bound LMS REM graph output (#13981)Authored by Euclid (GPT-5, Codex Desktop). Session 019ef378-527d-7393-bc74-ec3a1d3f2ddf.