Skip to content

refactor: AI provider architecture cleanup + bug fixes#58

Merged
luokerenx4 merged 2 commits intomasterfrom
dev
Mar 14, 2026
Merged

refactor: AI provider architecture cleanup + bug fixes#58
luokerenx4 merged 2 commits intomasterfrom
dev

Conversation

@luokerenx4
Copy link
Contributor

Summary

  • Fix double media extraction — text-kind providers (Claude Code, Agent SDK) were extracting media in both provider and AgentCenter, causing duplicate images in sessions
  • Fix parallel tool result batching — multiple tool results now correctly land in a single user message instead of separate ones
  • Fix orphaned tool-call crashtoModelMessages now sanitizes incomplete tool_use/tool_result pairs that caused Vercel AI SDK MissingToolResultsError
  • Push history serialization into providers — each provider now receives raw SessionEntry[] + prompt and decides how to format for its backend, removing inputKind branching from AgentCenter
  • Rename GenerateProviderAIProvider + add MockAIProvider for testing
  • Consolidate provider utils — merge provider-utils.ts + log-tool-call.ts into ai-providers/utils.ts
  • Rename ai-provider.tsai-provider-manager.ts to match project naming convention
  • Track CLAUDE.md in git — project instructions are public documentation, not local-only
  • Add vitest config with @/* path alias support
  • Expand test coverage from 62% to 74% statements (42 pipeline tests, 134 core unit tests)

Test plan

  • pnpm build — no TS errors
  • pnpm test — 715 tests passing (40 files)
  • Manual e2e: Vercel AI SDK with existing session (orphaned tool-call fix)
  • Manual e2e: Claude Code provider with tool calls
  • Manual e2e: Telegram + Web connectors

🤖 Generated with Claude Code

luokerenx4 and others added 2 commits March 14, 2026 18:26
…tKind

Each provider now receives raw SessionEntry[] + prompt and decides how
to serialize history for its backend (text string vs structured messages).
AgentCenter no longer branches on inputKind — just calls provider.generate().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Vercel AI SDK validates that every tool-call has a matching tool-result.
Sessions can have orphaned tool-calls when interrupted mid-tool-call or
when compaction truncates between a tool_use and its result. Now
toModelMessages strips these orphaned entries to prevent MissingToolResultsError.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@luokerenx4 luokerenx4 merged commit 9c17cea into master Mar 14, 2026
2 checks passed
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.

1 participant