Skip to content

fix: 9 critical bugs for robustness and reliability#2

Merged
chinmaymk merged 1 commit intomainfrom
claude/fix-critical-bugs-eeAhZ
Mar 8, 2026
Merged

fix: 9 critical bugs for robustness and reliability#2
chinmaymk merged 1 commit intomainfrom
claude/fix-critical-bugs-eeAhZ

Conversation

@chinmaymk
Copy link
Copy Markdown
Owner

  1. Context compaction message tracking: After compaction truncates the messages array, REPL/CLI lost track of new messages. Added inputMessageCount to LoopResult so consumers can correctly slice new messages regardless of compaction.

  2. Missing isError on IMessage type: The agent loop sets isError on tool error messages but IMessage didn't declare the field. Added optional isError to the type definition.

  3. Ollama done emission: Stream could end without chunk.done=true, leaving no done event emitted. Added fallback emission after loop.

  4. MCP server transport race: Transport was registered AFTER handleRequest, so concurrent requests couldn't find the session. Now registered before handling, with cleanup on error.

  5. Google provider empty parts: Empty message content produced an empty parts array that Gemini API rejects. Now ensures at least one part per message.

  6. toolTimeout on middleware: Tool timeout was applied to all middleware chains including compaction (which makes provider.chat calls). Removed timeout from middleware chains — only actual tool executions are timed out now.

  7. SIGINT/SIGTERM error handling: Async shutdown errors in signal handlers could become unhandled rejections. Added try/catch for best-effort cleanup.

  8. HTTP body validation: parseBody didn't validate that messages was an array or handle missing fields. Added proper type checking.

  9. Tilde path resolution: Config and middleware loader matched bare ~ (e.g., ~username/path) instead of only ~/. Fixed to check ~/ specifically.

https://claude.ai/code/session_019Ey19uR78tJQ98Ue2vrgKf

@chinmaymk chinmaymk force-pushed the claude/fix-critical-bugs-eeAhZ branch 2 times, most recently from 4e627ec to c3f81d5 Compare March 8, 2026 01:33
1. Context compaction message tracking: After compaction truncates the
   messages array, REPL/CLI lost track of new messages. Added
   inputMessageCount to LoopResult so consumers can correctly slice
   new messages regardless of compaction.

2. Missing isError on IMessage type: The agent loop sets isError on
   tool error messages but IMessage didn't declare the field. Added
   optional isError to the type definition.

3. Ollama done emission: Stream could end without chunk.done=true,
   leaving no done event emitted. Added fallback emission after loop.

4. MCP server transport race: Transport was registered AFTER
   handleRequest, so concurrent requests couldn't find the session.
   Now registered before handling, with cleanup on error.

5. Google provider empty parts: Empty message content produced an
   empty parts array that Gemini API rejects. Now ensures at least
   one part per message.

6. toolTimeout on middleware: Tool timeout was applied to all
   middleware chains including compaction (which makes provider.chat
   calls). Removed timeout from middleware chains — only actual tool
   executions are timed out now.

7. SIGINT/SIGTERM error handling: Async shutdown errors in signal
   handlers could become unhandled rejections. Added try/catch for
   best-effort cleanup.

8. HTTP body validation: parseBody didn't validate that messages was
   an array or handle missing fields. Added proper type checking.

9. Tilde path resolution: Config and middleware loader matched bare
   ~ (e.g., ~username/path) instead of only ~/. Fixed to check ~/
   specifically.

https://claude.ai/code/session_019Ey19uR78tJQ98Ue2vrgKf
@chinmaymk chinmaymk force-pushed the claude/fix-critical-bugs-eeAhZ branch from c3f81d5 to 3dec70e Compare March 8, 2026 02:03
@chinmaymk chinmaymk merged commit 2baec56 into main Mar 8, 2026
1 check passed
@chinmaymk chinmaymk deleted the claude/fix-critical-bugs-eeAhZ branch March 8, 2026 05:18
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